473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

INSERT Problem

Tom
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.

Jun 27 '08 #1
2 976
Tom wrote:
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"
Jun 27 '08 #2
Tom
Thanks Bob. I've since posted to the adonet newsgroup.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:ug**************@TK2MSFTNGP03.phx.gbl...
Tom wrote:
>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"
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
0
by: jtocci | last post by:
I'm having a big problem with CREATE RULE...ON INSERT...INSERT INTO...SELECT...FROM...WHERE when I want to INSERT several (20~50) records based on a single INSERT to a view. Either I get a 'too...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
8
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with...
2
by: alexmaster_2004 | last post by:
hi i have made an application using C# that access sql2000. this application is just used to insert data to the database. i use something like this in my code: // string colmnA = TextBox1.Text;...
7
by: Lorenzino | last post by:
Hi, I have a problem with bindings in a formview. I have a formview; in the insert template i've created a wizard control and inside it i have an HTML table with some textboxes bound to the...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
6
by: sgulciny | last post by:
hi friends; I have problem about sql server insert and update in client side. I am coding windows application with c#.When I run my code in database server computer all is fine.I can see data,...
8
by: Red | last post by:
If auto-format is turned off in VS2008, there is apparently no way to indent a line. Under Tools->Options->Text Editor->C#->Formatting, there are three checkboxes. Unchecking those seems to cause...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.