Results 1 to 3 of 3

Thread: problem in DataGrid...

  1. #1

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

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

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    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?

  3. #3

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    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
  •  



Click Here to Expand Forum to Full Width