Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - INSERT Problem

Reply
 
Old 05-08-2008   #1 (permalink)
Tom


 
 

INSERT Problem

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.


My System SpecsSystem Spec
Old 05-09-2008   #2 (permalink)
Bob Barrows [MVP]


 
 

Re: INSERT Problem

Tom wrote:
Quote:

> This is driving me crazy ...
>
> I have a typed dataset that I created using VS2008. I created an
> Insert statement:
>
There was no way for you to know it (except maybe by browsing through some
of the previous questions in this newsgroup before posting yours - always a
recommended practice) , but this is a classic (COM-based) ADO newsgroup.
ADO.Net bears very little resemblance to classic ADO so, while you may be
lucky enough to find a dotnet-knowledgeable person here who can answer your
question, you can eliminate the luck factor by posting your question to a
group where those dotnet-knowledgeable people hang out. I suggest
microsoft.public.dotnet.framework.adonet.

Oops, I've just noticed you crossposted to several groups. I'm replying from
the data.ado group.The only relevant group you chose was the dotnet group.
They might be able to help you there. if not, try the adonet group.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


My System SpecsSystem Spec
Old 05-09-2008   #3 (permalink)
Tom


 
 

Re: INSERT Problem

Thanks Bob. I've since posted to the adonet newsgroup.


"Bob Barrows [MVP]" <reb01501@xxxxxx> wrote in message
news:ugIUHxbsIHA.1768@xxxxxx
Quote:

> Tom wrote:
Quote:

>> This is driving me crazy ...
>>
>> I have a typed dataset that I created using VS2008. I created an
>> Insert statement:
>>
> There was no way for you to know it (except maybe by browsing through some
> of the previous questions in this newsgroup before posting yours - always
> a
> recommended practice) , but this is a classic (COM-based) ADO newsgroup.
> ADO.Net bears very little resemblance to classic ADO so, while you may be
> lucky enough to find a dotnet-knowledgeable person here who can answer
> your
> question, you can eliminate the luck factor by posting your question to a
> group where those dotnet-knowledgeable people hang out. I suggest
> microsoft.public.dotnet.framework.adonet.
>
> Oops, I've just noticed you crossposted to several groups. I'm replying
> from the data.ado group.The only relevant group you chose was the dotnet
> group. They might be able to help you there. if not, try the adonet group.
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
SATA problem? "Please insert disc in drive D:" General Discussion
how to insert pic? Live Mail
insert cd Vista music pictures video
CD Insert/Jewel Case Insert Maker ignored? Vista music pictures video
Halflife 2 and Halflife 2 Episode One, insert disc problem before I even installed! Vista Games


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46