Пример #1
0
        private void BtBorrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                string         sql     = "Select * from Renta WHERE IdRenta = " + "'" + TxtIdRenta.Text + "'" + "";
                SqlCommand     comando = new SqlCommand(sql, con);
                SqlDataAdapter da      = new SqlDataAdapter(sql, con);

                DataTable dt = new DataTable();

                da.Fill(dt);
                DgvRenta.DataSource = dt;
                DgvRenta.Refresh();
                comando.ExecuteNonQuery();

                con.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Ha ocurrido un error");
            }
        }
Пример #2
0
        private void CargarTabla()
        {
            try
            {
                con = new SqlConnection("Data Source=DESKTOP-7UG5AJD\\SQLEXPRESS02;Initial Catalog=RentCar;Integrated Security=True");
                con.Open();
                string         sql = "select * from Renta";
                SqlDataAdapter da  = new SqlDataAdapter(sql, con);
                DataTable      dt  = new DataTable();
                da.Fill(dt);
                DgvRenta.DataSource = dt;
                DgvRenta.Refresh();

                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error" + ex);
            }
        }
Пример #3
0
        private void CargarTabla()
        {
            try
            {
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                string         sql = "select * from Renta";
                SqlDataAdapter da  = new SqlDataAdapter(sql, con);
                DataTable      dt  = new DataTable();
                da.Fill(dt);
                DgvRenta.DataSource = dt;
                DgvRenta.Refresh();

                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error" + ex);
            }
        }
Пример #4
0
        private void BtBorrar_Click(object sender, EventArgs e)
        {
            try
            {
                con = new SqlConnection("Data Source=DESKTOP-7UG5AJD\\SQLEXPRESS02;Initial Catalog=RentCar;Integrated Security=True");
                con.Open();
                string         sql     = "Select * from Renta WHERE IdRenta = " + "'" + TxtIdRenta.Text + "'" + "";
                SqlCommand     comando = new SqlCommand(sql, con);
                SqlDataAdapter da      = new SqlDataAdapter(sql, con);

                DataTable dt = new DataTable();

                da.Fill(dt);
                DgvRenta.DataSource = dt;
                DgvRenta.Refresh();
                comando.ExecuteNonQuery();

                con.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Ha ocurrido un error");
            }
        }