Log in

View Full Version : ADO.NET 2.0 Beta 2 Question


gstelmack
06-26-2005, 03:09 PM
I'm trying to do a bit of ADO.NET programming using C# in the Visual Studio.NET 2005 Beta 2 edition. I've got an Access database that I am reading into a DataGridView that displays all the rows nicely. My problem is that I cannot actually CHANGE the contents of the database. I'm attempting to manually add and delete rows, but while I can get the DataSet to change (and the corresponding GridView to update), I can't get my changes committed back to the database. Calling "AcceptAllChanges" does not seem to have any effect. Deleting rows within the GridView has no effect either.

This is my first foray into ADO.NET, so I'm probably missing something obvious (if not running into a bug in Beta 2). My only book at the moment is "Introducing Microsoft ASP.NET 2.0", so it's ADO chapters are geared more towards web development.

I figure I'll come across the answer within 15 minutes of posting this (half the time this is the best way to figure something out http://dynamic.gamespy.com/%7Efof/forums/images/smilies/wink.gif ), but if anyone has more experience with ADO.NET that can point me in the right direction, I'd be grateful.

Joe
06-26-2005, 03:15 PM
in english please?

gstelmack
06-26-2005, 03:46 PM
in english please?
I'm trying to get my FBCB -> TPB draft file converter working, but I can't save out any of the players.

Fidatelo
06-26-2005, 09:51 PM
You need to use a DataAdapter and write code to handle the update statement (either to call a stored proc, generate update SQL, or whatever). Then call the DataAdapter and pass in the DataSet.

Here is a link that may help, although it's 1.1 and I'm not certain what has changed to 2.0.

http://www.devx.com/vb2themax/Tip/19429

gstelmack
06-27-2005, 10:08 AM
I've got an Adapter, just for some reason changes in the GridView and the DataSet are not being propagated to the database through the Adapter. If I call the Adapter.Insert method directly, the database is updated.

I've created most of this through the wizards in VS.NET 2005, only weird thing was that I had to manually create a DELETE query. But there appears to be one other piece missing, as at the very least I expected manual editing in the GridView to update the database.

gstelmack
06-27-2005, 10:26 AM
Okay, I've got this working by manually making the database calls on the Adapter. That's good enough for me for the moment, maybe later I can figure out the GridView bits...