roy himanshu

roy himanshu

  • NA
  • 126
  • 0

how to store the text box values to data table in asp

Oct 14 2009 1:07 AM

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");

Answers (2)