Hi,
i am having problem in updating my database although i can upadate my dataset
private void btnSave_Click(object sender, EventArgs e)
{
DataRow dRow = ds1.Tables["ContainerID"].NewRow();
dRow[1] = textBox1.Text;
dRow[2] = textBox2.Text;
dRow[3] = textBox3.Text;
ds1.Tables["ContainerID"].Rows.Add(dRow);
MaxRows = MaxRows + 1;
inc = MaxRows - 1;
MessageBox.Show("Entry Added");
}
but while updating database it gives an error
The ConnectionString property has not been initialized.
private void btnSave_Click(object sender, EventArgs e)
{
System.Data.SqlClient.SqlCommandBuilder cb;
cb = new System.Data.SqlClient.SqlCommandBuilder(da);
DataRow dRow = ds1.Tables["ContainerID"].NewRow();
dRow[1] = textBox1.Text;
dRow[2] = textBox2.Text;
dRow[3] = textBox3.Text;
ds1.Tables["ContainerID"].Rows.Add(dRow);
MaxRows = MaxRows + 1;
inc = MaxRows - 1;
da.Update(ds1, "ContainerID");
//ds1.AcceptChanges();
MessageBox.Show("Entry Added");
}
how can i Update my database?
Thanks.