Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,190 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,154 people online right now. Registration is fast and FREE... Join Now!




Error when changing data in sql-database

 
Reply to this topicStart new topic

Error when changing data in sql-database, databases

Hanzie
19 Aug, 2007 - 09:02 AM
Post #1

D.I.C Head
**

Joined: 19 Aug, 2007
Posts: 92


My Contributions
I have made a contacts-database (sql) and placed this in a form.
I placed a button on it to get back to another form (the main menu)
When i add contacts in the programs-contactsdatabase and push the button it must save the placed data and get back to the main menu. This works! But when i go back to the contacts data and want to change existing data i get the folowing error:

Update requires a valid updatecommand when passed datarow collection with modified rows.

This is my code for saving the data and get back to the main menu"

Private Sub BtnToMainmenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnToMainMenu.Click
Me.Validate()
Me.ContactenBindingSource.EndEdit()
Me.ContactenTableAdapter.Update(Me.ContactenDataSet.Contacten)

Me.Visible = False
My.Forms.Mainmenu.Show()

End Sub
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Error When Changing Data In Sql-database
19 Aug, 2007 - 10:55 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,199



Thanked: 213 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
That error is a general "catch all" error which could mean various things. One thing could be that your table in the database doesn't have a primary key. So make sure that it has one set. You may also want to try the following...

Go to edit dataset with designer (you can go there from the "Data" menu then "show data sources" and "Edit dataset with designer".

Right click the adapter and select "Configure". Click "Advanced options". Make sure the "Refresh the data table" is selected. Click OK and Finish.

Lastly make sure you are specifying a correct and valid update command on your tableadapter.

Hope these options work for you.
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Error When Changing Data In Sql-database
19 Aug, 2007 - 11:03 AM
Post #3

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
PS: This is a VB.Net question, not VB6 smile.gif Mods can you move this please
User is offlineProfile CardPM
+Quote Post

Hanzie
RE: Error When Changing Data In Sql-database
22 Aug, 2007 - 04:47 AM
Post #4

D.I.C Head
**

Joined: 19 Aug, 2007
Posts: 92


My Contributions
This helped:

Make sure the "Refresh the data table" is selected. Click OK and Finish.

Tnx!! This is great!

Now i can move further!!

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 01:28AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month