|
-
Nov 20th, 2003, 11:45 AM
#1
Thread Starter
New Member
Updating Dataset
Hi,
I'm having a problem updating my dataset. I'm using the following procedure:
Private Sub updateDB()
Try
Me.BindingContext(DataSet11, "Supervisors").EndCurrentEdit()
Me.OleDbDataAdapter1.Update(DataSet11)
Catch ex As Exception
MessageBox.Show("An error has occured!Error: "&ex.Message, _
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
When I run the program I get the following error message when trying to alter a record:
Update requires a valid update command when passed datarow collection with modified rows.
Any pointers as to where I'm going wrong or what I need to do would be very much appreciated.
-
Nov 20th, 2003, 12:47 PM
#2
Addicted Member
In what event are you calling this sub "updateDB"?
-
Nov 20th, 2003, 03:37 PM
#3
PowerPoster
The data adapter needs you to specify an update command in order for it to update the database with the changes in the dataset. You have probably specified the Select command to get the data, but you need to specify the Update command to update data.
-
Nov 21st, 2003, 10:05 AM
#4
Thread Starter
New Member
I specified the SELECT command in the DataAdapter wizard. I have tried to specify the UPDATE command in code but I am not getting anywhere. I've also tried to use the CommandBuilder with the dataAdapter as the arguement. Nothing seems to be working.
Still don't quite understand where I'm going wrong. I've followed an example from a book and it states that the code in my first post should be all I need to update the database. Any more pointers??
-
Nov 21st, 2003, 01:04 PM
#5
Addicted Member
On the last page of the wizard, was there checks next to all the generated commands?
If you dont have a primary key in your table or you have relationships between tables, the wizard will only generate a select command.
In previous projects of mine, if you dont actually change any data, I've gotten error meassages when trying to update because theres nothing to update.
-
Nov 24th, 2003, 05:28 AM
#6
Thread Starter
New Member
Thanks, think i've solved it now. It was because the database I was using had relationships. Decided to use the Data Form wizard in the end. Better spend more time studying!
Thanks everyone.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|