Update SQLdataBase w/ VB 2005 Beta2

When using VB.Net 2003 updating a database is fairly straightforward. You drag the table onto the form, a sqlConnection & sqlDataAdaptor are automatically generated. You then configure these objects and then generate and configure a data set. All that's left is to write the code for the update.

In VB 2005 it doesn't like it if you try to drag a table. I have tried using the Add Data Source ,configuring, and coding an update statement. I can see the data in the dataset. However, when I go back to the database it is not updating.

Briefly, what is the correct procedure to do this. I guess I'm missing something or my update statement is not correct.

Any help would be greatly appreciated.

Thank You,

Ed

[723 byte] By [zahnej] at [2007-12-16]
# 1
Hi,

Here is a simple procedure to update a table...

Create a datasource
Drag it into the form
Goto *.xsd file
Click the TableAdapter
In the properties create a UpdateCommand by selecting the dropdownlist and selecting new.
Expand the UpdateCommand and fill-in the necessary SQLStatements and parameters...
cheers,
Paul June A. Domag

PaulDomag at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
Thanks so much for the quick reply Paul. I'll try when I get home tonight. I basically have followed your procedure, however I let VB2005 generate the Update, Insert, and Delete statements. Those generated statements looked good to me. When I run the program it just doesn't update. No codes, no breaks.

I'll try putting in a new update statement and see if that works.

Paul, thanks again and,

Best Regards,

Ed

zahnej at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
Paul - tried your procedure- no luck. I was trying to use SQL Server 2005 April CTP. When I installed SQL Server 2000 it worked fine. I did not write my own Update Statement, I used the one that was automatically generated.

I guess there is something that I don't understand when trying to reference the SQL 2005. I'll just have to figure it out.

Thanks again - you got me thinking in the right direction.

Best Regards,

Ed

zahnej at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
If you figure this out please post the answer. I have been having the same problem with Beta 2 and the April CTP. Dataset updates fine and all is good while the app is running, but when closed there's no data in the database.

Gene

GeneQ at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5
May be related to this possible bug I submitted.

http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=7ad5edc4-3b3e-4db5-9529-f364d24b0955

My work around is to attach the database to SQLExpress rather than have it in the project as a local file. Update and insert work fine then.

GS at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 6
Hi,

I have been having this problem also, however my problem was just with a simple local connection to an Access Database.

I was having same problem where the data would not update in the original database source but would during running of the project.

Having just read the previous article, i have just created a new project and created a new datasource to the sample Northwind database, HOWEVER this time when prompted if i want to include the file with my project, I answered NO and everything is now working as expected!!! Previously I had included it with my Project and it would never work.

Tested again with another database, just in case it was a fluke :-) and that worked also, so the answer seems to be not to include the source with the project.

Andy Perry

AndrewPerry at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...