|
-
Sep 24th, 2007, 06:10 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Datagridview update error
I am using the following update command in the button click event:
Code:
ElseIf TypeOf Me.ActiveMdiChild Is WkPayment Then
Dim ChildForm As WkPayment = DirectCast(Me.ActiveMdiChild, WkPayment)
ChildForm.Validate()
ChildForm.EMPDRAWBindingSource.EndEdit()
ChildForm.EMPDRAWTableAdapter.Update(ChildForm.EmPaY.EMPDRAW)
MsgBox(" Update successful ")
and i am getting the following error:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
What could possibly be wrong ?
Last edited by LuxCoder; Sep 24th, 2007 at 06:17 AM.
-
Sep 24th, 2007, 07:29 AM
#2
Re: [2005] Datagridview update error
It's telling you exactly what you need to do: you need to provide the update commandtext for your table adapter.
-
Sep 24th, 2007, 08:18 AM
#3
Fanatic Member
Re: [2005] Datagridview update error
I agree with stanav. Can you provide the code to setup your Table Adapter? There is probably a SelectCommand property without an UpdateCommand property.
My.Settings.Signature = String.Empty
-
Sep 24th, 2007, 08:23 AM
#4
Re: [2005] Datagridview update error
If your TableAdapter has no UpdateCommand then either your query does not return a primary key or it contains join. Either way the wizard cannot generate an UpdateCommand automatically.
How did you create this TableAdapter? Does it correspond directly to a table in your database? If so then that table must not have a primary key. How can you update a record if you can't uniquely identify it? How can you uniquely identify a record without a primary key?
If you created the query yourself then you must either have not included the table's primary key or else the query references more than one table. In that case you will have to create the UpdateCommand yourself because the wizard can't do it.
-
Sep 25th, 2007, 01:51 AM
#5
Thread Starter
Hyperactive Member
Re: [2005] Datagridview update error
Now that i have to set primary key, how should i do it? From the Dataset designer or should i create the same table again with the primary key in the database?
-
Sep 25th, 2007, 02:08 AM
#6
Thread Starter
Hyperactive Member
Re: [2005] Datagridview update error
Okies, issue resolved ! Have created new table with the primary key ! Thanks.
-
Apr 27th, 2009, 04:14 AM
#7
Lively Member
Re: [RESOLVED] [2005] Datagridview update error
I need to know how to do this as well. Lux can you please provide the code? What do I put for Update and Delete commandtext ?
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
|