예제 #1
0
 public DataAnalyzer()
 {
     form2 = new Form_DataGrid();
 }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox2.Text == null)
            {
                MessageBox.Show("No se selecciono ninguna base de datos.");
            }
            else
            {
                try
                {
                    ConnectDatabase(comboBox1.Text, comboBox2.Text);
                    SqlCommand sqlCommand = new SqlCommand(textBox1.Text, sqlConnection);
                    SqlDataAdapter da = new SqlDataAdapter(sqlCommand);

                    if (dt != null)         //Re-inicializa la dt para que se vea bien en el dataGridView
                    {
                        dt.Rows.Clear();
                        dt.Columns.Clear();
                    }
                    da.Fill(dt);
                    sqlConnection.Close();
                    da.Dispose();
                    if (dataGrid.IsDisposed)
                    {
                        dataGrid = new Form_DataGrid();
                    }
                    dataGrid.ReadDataTable(dt);
                    dataGrid.Show();
                }
                catch (Exception ex)        //Checkear errores en la ejecucion de cualquier script y describirlos
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (sqlConnection == null)
                    {
                        sqlConnection.Dispose();
                    }
                }
            }
        }