Insert is < 100% reliable

  • Thread starter Thread starter mg
  • Start date Start date
M

mg

The following code inserts a row into an Oracle database
most, but not all, of the time. What code can I use to get
this to work 100% of the time?

private void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
oracleDataAdapter1.Fill(dataSet21);
DataRow dr = dataSet21.Tables[0].NewRow();
dr["deptno"]= TextBox1.Text;
dr["dname"]= TextBox2.Text;
dr["loc"]= TextBox3.Text;
dataSet21.Tables[0].Rows.Add(dr);
oracleDataAdapter1.Update(dataSet21);
}
 
The following code inserts a row into an Oracle database
most, but not all, of the time. What code can I use to get
this to work 100% of the time?

private void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
oracleDataAdapter1.Fill(dataSet21);
DataRow dr = dataSet21.Tables[0].NewRow();
dr["deptno"]= TextBox1.Text;
dr["dname"]= TextBox2.Text;
dr["loc"]= TextBox3.Text;
dataSet21.Tables[0].Rows.Add(dr);
oracleDataAdapter1.Update(dataSet21);
}

Assuming that your table has some required columns, you could check
that the contents of the textboxes are not null and also not too long
for the column. deptno presumably should be a number so you could
check that it is.

You could also check for any exceptions generated.

You could have your dba trace your session until you get a failure.
You can then examine the trace and see what went wrong.
 
Back
Top