Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > ADO Data > INSERT Problem
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 4228 of 4320
Post > Topic >>

INSERT Problem

by "Tom" <tom.smith.123@[EMAIL PROTECTED] > May 8, 2008 at 09:46 PM

This is driving me crazy ...

I have a typed dataset that I created using VS2008.  I created an Insert 
statement:

"INSERT INTO x (v1, v2, v3, ..., vN) VALUES (?, ?, ?, ... N?)"

Then I add parameters to the Insert command (OleDbCommand BTW, going into
an 
Access database):

myOldDbCommandInsert.Parameters.Add(new OleDbParameter("columnName", 
OleDbType.DBTimeStamp));
myOldDbCommandInsert.Parameters.Add(new OleDbParameter("columnName2", 
OleDbType.Char));
....
myOldDbCommandInsert.Parameters.Add(new OleDbParameter("columnNameN", 
OleDbType.UnsignedInt));

Now I set my default values:
myOldDbCommandInsert.Parameters["c1"].Value = defaultValue1;
myOldDbCommandInsert.Parameters["c2"].Value = defaultValue2;
....
myOldDbCommandInsert.Parameters["cN"].Value = defaultValueN;

Then I create my data adapter:
OleDbDataAdapter a = new OleDbDataAdapter("SELECT * FROM x", myConn);

Then the dataset:
MyCustomDataSet ds = new MyCustomDataSet();
a.Fill(ds.MyCustomTable);

So far, everything has worked fine up until this point.  So now, I simply 
want to add rows to MyCustomTable:
SomeLoopWith5ValuesOrWhatever
{
  MyCustomDataSet.MyCustomRowA r = (cast) 
MyCustomDataSet.MyCustomTable.NewRow();
  r.v1 = x;
  r.v2 = y;
  r.v3 = z;
  r.nN = N;
  myDataSet.myDataTable.Rows.Add(r);
}

Stepping through the debugger, that appears to do exactly what I expect. 
I 
can see that the table gets the new rows, and they have the correct
values.

However, when I do the following:
myDataAdapter.Update(myDataSet, "NameOfCorrectTable");

The correct number of rows are added to the correct table, but they do not

have the new values?!!  They are keeping the default values that I set 
earlier in my code.  Why is my INSERT statement using these default
values?

It's been a while since I messed with database stuff.
Thanks.
 




 3 Posts in Topic:
INSERT Problem
"Tom" <tom.s  2008-05-08 21:46:25 
Re: INSERT Problem
"Bob Barrows [MVP]&q  2008-05-09 06:06:00 
Re: INSERT Problem
"Tom" <johnt  2008-05-09 08:52:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 14:13:54 CST 2008.