insert data into table

  • Thread starter Thread starter cerr
  • Start date Start date
C

cerr

Hi There,

I'm using following code to insert data into my DB but it doesn't
work:
try
{
int tmp = 0;
tmp =
this.routeTableAdapter1.InsertRoute(Int32.Parse(this.DestNum.Text),
this.Destination.Text, Int32.Parse(this.LineNum.Text));
MessageBox.Show("inserted " + tmp.ToString() + "
elements into the route table.");
MessageBox.Show("Update() returns: " +
routeTableAdapter1.Update(myPID_DB_DataSet).ToString());
myPID_DB_DataSet.AcceptChanges();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
My Upsdate(_) call always returns 0 even tho i get a 1 returnmed from
my InsetRoute method. How come?
What am i missing?

Thanks!
 
The problem is maybe with your subroutine InsertRoute.

I prefer to use the first , or the third, method described at
http://msdn.microsoft.com/en-us/library/ms233812(VS.80).aspx

I never used the second method (the table adapter Insert method) but it
seems that it requires a value for EACH field ... in an order that depends
of your actual definition... hard to maintain). The first and third method
are more robust since you specify which fields get which value.

Can you, for debugging purposes, use the third method, ie, create an ad hoc
INSERT command, to see if the record CAN be accepted by the database in the
first place ... if your connection string works.


Vanderghast, Access MVP
 
Back
Top