hi
iam working on asp web form .how to store the text box values to data table.my code is past below.i didnot get any error.but values are not saved in table.why?where is it problem?plz tell me.
protected void Add_btn_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("data source=server2;user id=sa;password=sa;database=costing1");
da1 = new SqlDataAdapter("select *from CATABLE001", cn);
da1.Fill(ds, "CATABLE001");
DataRow dr = ds.Tables["CATABLE001"].NewRow();
dr[1] = textBox1.Text;
dr[2] = textBox2.Text;
dr[3] = textBox3.Text;
dr[4] = DropDownList1.SelectedValue;
dr[5] = textBox5.Text;
dr[6] = textBox6.Text;
dr[7] = TextBox7_CalendarExtender.SelectedDate;
dr[8] = textBox8.Text;
dr[9] = textBox9.Text;
dr[10] = textBox10.Text;
dr[11] = textBox11.Text;
dr[12] = textBox12.Text;
dr[13] = textBox13.Text;
dr[14] = textBox14.Text;
ds.Tables["CATABLE001"].Rows.Add(dr);
cb = new SqlCommandBuilder(da1);
da1.Update(ds, "CATABLE001");
Loading

Kirtan PatelRank #292 · 8.6K reputationPosted Oct 13, 2009, 9:13 PM EDT
protected void Add_btn_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("data source=server2;user id=sa;password=sa;database=costing1");
da1 = new SqlDataAdapter("select *from CATABLE001", cn);
da1.Fill(ds, "CATABLE001");
DataRow dr = ds.Tables["CATABLE001"].NewRow();
dr[0] = textBox1.Text;
dr[1] = textBox2.Text;
dr[2] = textBox3.Text;
dr[3] = DropDownList1.SelectedValue;
dr[4] = textBox5.Text;
dr[5] = textBox6.Text;
dr[6] = TextBox7_CalendarExtender.SelectedDate;
dr[7] = textBox8.Text;
dr[8] = textBox9.Text;
dr[9] = textBox10.Text;
dr[10] = textBox11.Text;
dr[11] = textBox12.Text;
dr[12] = textBox13.Text;
dr[13] = textBox14.Text;
ds.Tables["CATABLE001"].Rows.Add(dr);
// Whats meaning of this Code ????
cb = new SqlCommandBuilder(da1);
da1.Update(ds, "CATABLE001");
jingeRank #2,527 · 554 reputationPosted Oct 14, 2009, 12:27 AM EDT