コード例 #1
0
ファイル: Menu.cs プロジェクト: Andres420/ProyectoBaseDatos
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Char[] cont;
                string consulta = rtboxConsulta.Text.Trim();
                cont = consulta.ToCharArray();
                string            s = cont[0].ToString() + cont[1].ToString() + cont[2].ToString() + cont[3].ToString() + cont[4].ToString() + cont[5].ToString();
                NpgsqlDataAdapter a = dbbol.ConsultaSelect(consulta, cbBases.SelectedItem.ToString());
                if (s.ToLower().Equals("select"))
                {
                    Tables t = new Tables(cbBases.SelectedItem.ToString(), consulta);
                    t.Show();
                }

                else if (a != null)
                {
                    Tables t = new Tables(a);
                    t.Show();
                }
                else if (dbbol.Consulta(consulta, cbBases.SelectedItem.ToString()))
                {
                    rcOutPut.Text = "Query successfully complete";
                    ActualizarArbol();
                }
                dbbol.CerrarConsulta();
            }
            catch (Exception ex)
            {
                dbbol.CerrarConsulta();
                rcOutPut.Text = ex.Message;
            }
        }
コード例 #2
0
 private void Tables_Load(object sender, EventArgs e)
 {
     try
     {
         if (ad == null)
         {
             bdbol = new bdBOL();
             ds    = new DataSet();
             DataTable table = new DataTable();
             ds.Tables.Add(table);
             bdbol.ConsultaSelect(consulta, bd).Fill(table);
             dataGridView1.DataSource = table;
             bdbol.CerrarConsulta();
         }
         else
         {
             ds = new DataSet();
             DataTable table = new DataTable();
             ds.Tables.Add(table);
             ad.Fill(table);
             dataGridView1.DataSource = table;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         this.Close();
     }
 }