473,499 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TableAdapter not updating records

JT
In Visual Studio 2005, I used the Data - Add New Data Source wizard to
create a new Table Adapter data set to interface to my SQL Server 2005
database.

Then I wrote this C# code to add new records to the database:

TradeRecordsDataSet TDataSet = new TradeRecordsDataSet();

DataRow NewRow = TDataSet.Tables["Trades"].NewRow();

NewRow["Symbol"] = Symbol;

NewRow["Mkt#"] = MktNo;

NewRow["MktType"] = MktType;

TDataSet.Tables["Trades"].Rows.Add(NewRow);

TDataSet.Tables["Trades"].AcceptChanges();

Everything executes properly, but when I open the table, there are no new
records. Does anybody know why my new records are not being committed to
the database?

Thanks in advance for any ideas.


Feb 22 '07 #1
1 3130
TradeRecordsDataSet TDataSet = new TradeRecordsDataSet();
DataRow NewRow = TDataSet.Tables["Trades"].NewRow();
NewRow["Symbol"] = Symbol;
NewRow["Mkt#"] = MktNo;
NewRow["MktType"] = MktType;
TDataSet.Tables["Trades"].Rows.Add(NewRow);
TradesTableAdapter ta = new TradesTableAdaper();
ta.Update(TDataSet,"Trades");
TDataSet.Tables["Trades"].AcceptChanges();
Several points:

1) After you work with table adapters, you will discover that it is best to
stay far away from them.
2) You will want to replace them with data adapters. After working with
these for awhile, you will discover that designing them in the VS 2005 / VS
2003 designer is problematic at best.
3) It's not that hard to write your own designer that correctly writes all
the underlying Sql and correctly configures all the parameters.


Feb 22 '07 #2

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

Similar topics

9
2878
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
3
7187
by: Mike | last post by:
Dear Group, When I add a DataTable to a Typed Dataset, and a TableAdapter to the DataTable, I am able to create methods to send updates directly to the database (GenerateDBDirectMethods),...
2
10566
by: Rob Dob | last post by:
Hi, in the old days, pre .Net 2.0 I could just modify the SQLCommand of the SQlDataAdapter to reflect a different where clause and then issue a .Fill(), and Whamo!!! everything worked.. How am...
1
2280
by: Magnus | last post by:
My situation compares to this: I have two tables parentTable(id, foreignId) and childTable(id, value). "foreignId" in the "parentTable" references "id" in "childTable". The constraint is by default...
1
13790
by: gmccallum | last post by:
I would have expected to be able to find this easily, but I couldn't. I am using the TableAdapter.Insert command to insert a record. I would like to then get an ID field from that record after...
3
18794
by: =?Utf-8?B?UmljaCBIdXRjaGlucw==?= | last post by:
I'm not really sure how to ask this question because I'm still getting my feet wet with data access and VB.NET, but here goes: To start off with, I'm using VB 2005 Express to connect to an Access...
7
2963
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm not sure whether I'm missing something or not. I reviewed the SQL Statements generated by tableadapter when the selectcommand is select *. It seems they are extremely bad. The updatecommand...
0
3094
jas16183
by: jas16183 | last post by:
Hi Guys, need some help here, Im working on a project in vb.net, the problem im facing is that my tableadapter.update(dataset.datatable) is not functioning, the datatable has a relation with...
1
2252
by: Sreekanth | last post by:
I have a dataset with TableAdapter A and TableAdapter B. B has a foreign key which refer backs to A. I add a row to table A and then add several rows to Table B. I update ID of table A of table...
0
7174
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
7220
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...
1
6894
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...
0
7388
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...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1427
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 ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.