emaduddeen
Well-known member
- Joined
- May 5, 2010
- Messages
- 171
- Location
- Lowell, MA & Occasionally Indonesia
- Programming Experience
- Beginner
Hi Everyone,
I'm using this code to do an update to the database but get this error:
"Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information"
The primary key is on the ID column of the table and that value is stored in intParentID. When I ran the debugger I found the intParentID variable did have a value in it so at least that was not a problem.
Later in the code I use this:
This is where the error is displayed.
Can you help resolve this one?
Thanks.
Truly,
Emad
I'm using this code to do an update to the database but get this error:
"Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information"
The primary key is on the ID column of the table and that value is stored in intParentID. When I ran the debugger I found the intParentID variable did have a value in it so at least that was not a problem.
VB.NET:
strSQL = "Select * " & _
"From Parents " & _
"Where ID = @ParentID"
' Create the data adapter for the Parent Details.
'------------------------------------------------
objDataAdapterSingleParent = New SqlDataAdapter(strSQL, _
(BuildConnectionString("EMAD-PC\SQLEXPRESS", "Islamic Academy Of Peace")))
' Add the parameter to the parameters collection of the Parent Details Data Adapter.
'-----------------------------------------------------------------------------------
objDataAdapterSingleParent.SelectCommand.Parameters.Add("@ParentID", SqlDbType.Int)
Later in the code I use this:
VB.NET:
' Store the selected customer ID into the parameter slot of the SQL data adapter.
'--------------------------------------------------------------------------------
objDataAdapterSingleParent.SelectCommand.Parameters("@ParentID").Value = intParentID
' Have the command builder create an update SQL command.
'-------------------------------------------------------
objDataAdapterSingleParent.UpdateCommand = objCommandBuilderParentDetails.GetUpdateCommand
This is where the error is displayed.
Can you help resolve this one?
Thanks.
Truly,
Emad