473,756 Members | 6,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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):

myOldDbCommandI nsert.Parameter s.Add(new OleDbParameter( "columnName ",
OleDbType.DBTim eStamp));
myOldDbCommandI nsert.Parameter s.Add(new OleDbParameter( "columnName 2",
OleDbType.Char) );
....
myOldDbCommandI nsert.Parameter s.Add(new OleDbParameter( "columnName N",
OleDbType.Unsig nedInt));

Now I set my default values:
myOldDbCommandI nsert.Parameter s["c1"].Value = defaultValue1;
myOldDbCommandI nsert.Parameter s["c2"].Value = defaultValue2;
....
myOldDbCommandI nsert.Parameter s["cN"].Value = defaultValueN;

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

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

So far, everything has worked fine up until this point. So now, I simply
want to add rows to MyCustomTable:
SomeLoopWith5Va luesOrWhatever
{
MyCustomDataSet .MyCustomRowA r = (cast)
MyCustomDataSet .MyCustomTable. NewRow();
r.v1 = x;
r.v2 = y;
r.v3 = z;
r.nN = N;
myDataSet.myDat aTable.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.U pdate(myDataSet , "NameOfCorrectT able");

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 991
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.publi c.dotnet.framew ork.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******@NOyah oo.SPAMcomwrote in message
news:ug******** ******@TK2MSFTN GP03.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.publi c.dotnet.framew ork.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
5648
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 first name, last name, email, etc. The data are then sent to a PHP script (reg.php). The data are then inserted into a table (reg) in MS SQL server. I have declared the variables like this: if (!(isset($_POST))) { $FirstName = "" ;
14
4299
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 salvage the records from the many table and without going into detail, one of the reasons I can't do the opposite as there are records in the ONE table that I need to keep even if they don't have any child records in the MANY table. Below I created...
0
3147
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 much data for field' or the query just runs on and on til I have to restart the postmaster. I have found rules to compare mine to but people limit the resulting insert to one record (the WHERE generally limits the result of the SELECT to one...
16
17017
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 must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
8
6293
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 one-to-one relationship but on this occasion I must keep username/password details within a seperate table. Here's the basic specs and database schema: -------------------------------------------
2
2035
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; string comlnB = TextBox2.Text; string sqlstatment = "INSERT INTO TABLENAME VALUES(" +"'"+colmnA+"'" + "," + "'" + colmnB + "'" + ")";
7
4353
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 sqldatasource of the formview. If i put this textboxes outside the table everything works well, but as soon as i put them inside the table (in order to organize the layout in the right way) they doesn't work. They works only as eval() and not bind()...
4
4862
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 sql DataAdapter (da) da.SelectCommand.CommandText = "Select * from Servertbl1" da.Fill(ds, "tbl1") so far, so good. If I add a row to the datagridview I use the following sqlDataAdapter code to update the server table - which works OK when...
6
3682
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, insert and update.But when I run same code in client side I can see data but not insert not update what can I do about this problem .I use sql server 2000 database.Client side connections ok. :( thanks for all
8
5027
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 this behavior. I'd simply like to have the tab key insert a tab at the beginning of a line. I believe that there were publlished macros for doing this in earlier VS versions, but I expected this to be 'fixed' in VS2008. Yes, I realize someone...
0
9454
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10028
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9868
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9836
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9707
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3352
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.