|
-
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..
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
|