roy himanshu

roy himanshu

  • NA
  • 126
  • 0

how to insert the values from one table to another table using Gridview?In C#

Sep 14 2009 8:00 AM

hi,
Iam working in windows form application in C#,i have a grid view ,2 sql tables,in that grid view i double clicked in the cell,then open an input box,then i entered item code click ok button.then retrive the data from one table.after that i edit that values click add button that values are saved in second table.is it possible?plz give me code.my code past bellow.
private void Form6_Load(object sender, EventArgs e)
{
cn =
new SqlConnection("data source=server2;database=costing1;user id=sa;password=sa");
da1 =
new SqlDataAdapter("select *from CATABLE019", cn);
da2 =
new SqlDataAdapter("select *from CATABLE0021", cn);
ds =
new DataSet();
da1.Fill(ds,
"CATABLE019");
da2.Fill(ds, "CATABLE0021");
cmd =
new SqlCommand();
cmd.Connection = cn;
cmd.CommandType =
CommandType.StoredProcedure;
BomMasterGridView1.DataSource = ds.Tables[
"CATABLE019"];
}
private
void Add_btn_Click(object sender, EventArgs e)
{
cb =
new SqlCommandBuilder(da2);
da2.Fill(ds,
"CATABLE0021");
MessageBox.Show("saved");

}