Esempio n. 1
0
        private void PreencheDataGrid()
        {
            ConnetionPostgres connectionPostgres = new ConnetionPostgres();
            NpgsqlConnection  conn = new NpgsqlConnection(connectionPostgres.ConnString);

            string        sql = "SELECT * FROM public.\"KitCapsulas\"";
            NpgsqlCommand cmd;
            DataTable     dt;

            try
            {
                conn.Open();
                cmd = new NpgsqlCommand(sql, conn);
                dt  = new DataTable();
                dt.Load(cmd.ExecuteReader());
                dgvKitCapsulas.DataSource = dt;
                conn.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Não conseguimos conectar ao servidor, por favor verifique os parametros de configuração!");
                FormConnectionConfig form = new FormConnectionConfig();
                form.Show();
                form.Activate();
            }
        }
Esempio n. 2
0
 private void FormPrincipal_Shown(object sender, EventArgs e)
 {
     try
     {
         ConnetionPostgres connectionPostgres = new ConnetionPostgres();
         NpgsqlConnection  conn = new NpgsqlConnection(connectionPostgres.ConnString);
         string            sql  = "SELECT * FROM public.\"Capsulas\"";
         NpgsqlCommand     cmd;
         conn.Open();
         cmd = new NpgsqlCommand(sql, conn);
         cmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception)
     {
         MessageBox.Show("Não conseguimos conectar ao servidor, por favor verifique os parametros de configuração!");
         FormConnectionConfig form = new FormConnectionConfig();
         form.Show();
         form.Activate();
     }
 }