|
-
May 26th, 2004, 01:54 AM
#1
Thread Starter
Frenzied Member
problem in DataGrid...
halu...im 3 months aspirant in vb.net i have problem about DataGrid..
i encountered error such as this:
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
and here my sample code:
Private ds as DataSet
dim da as SqlDataAdapter
dim cmdtext as string
//form load
ds = new DataSet("customertable")
cmdtext="select * from customertable"
Dim da As New SqlDataAdapter()
da.SelectCommand = New SqlCommand(cmdText, cn)
da.Fill(ds)
DataGrid1.DataSource = ds
//
Private Sub water_reservation_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If ds.HasChanges Then
Dim cb As SqlCommandBuilder
Dim cmd As String = cmdText
da = New SqlDataAdapter(cmd, cn)
cb = New SqlCommandBuilder(da)
Debug.WriteLine(cb.GetInsertCommand.CommandText)
Debug.WriteLine(cb.GetUpdateCommand.CommandText)
Debug.WriteLine(cb.GetDeleteCommand.CommandText)
da.Update(ds)
End If
End Sub
tanx...in advance..
-
May 26th, 2004, 07:39 AM
#2
Hyperactive Member
First: The obvious question is, does the customertable have a key column?
Second: Since you have already associated a SelectCommand with your dataadapter in the form_load event, why are you doing it again in the water_reservation_Closing event?
-
May 26th, 2004, 08:19 PM
#3
Thread Starter
Frenzied Member
halu...cyberhawke..
tanx for answering my question w/ a question...
i already got it right...
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
|