Add row SQL Server from C#.net

Jun 1 2008 9:12 PM

The code below is bugging out with the error below,  new to C# what I am trying to do is add a new record, hey, if there is a better way, need the help, thanks

 

NullRefrenceExpection was unHandle

 

private void bntSave_Click(object sender, EventArgs e)

{

System.Data.SqlClient.SqlCommandBuilder cb;

cb = new System.Data.SqlClient.SqlCommandBuilder(da);

DataRow dRow = ds1.Tables["Customers"].NewRow();      ****  Bugging out here

dRow[1] = textBox1.Text;

dRow[2] = textBox2.Text;

ds1.Tables["Customers"].Rows.Add(dRow);

da.Update(ds1, "Customers");

MessageBox.Show("Entry Added");


Answers (1)