zhouy 5 Newbie Poster

Dear All,

I have a small probelm with updating my database. Here are my codes

Module AphidSimVar
    Dim myCon As SqlCeConnection = New SqlCeConnection("Data Source=|DataDirectory|\AphidModel.sdf")
    Dim myCmd As SqlCeCommand
    Dim myAdap As SqlCeDataAdapter
    Dim myDataSet As DataSet
    Dim myTable As DataTable
    Dim myBuilder As SqlCeCommandBuilder

    Public Sub ShowData()
        myCmd = New SqlCeCommand("Select * FROM AphidPop", myCon)
        If myCon.State = ConnectionState.Closed Then myCon.Open()
        myAdap = New SqlCeDataAdapter(myCmd)
        myDataSet = New DataSet()
        myAdap.Fill(myDataSet, "AphidData")
        frmPredatorPop.DataGridView1.DataSource = myDataSet.Tables("AphidData").DefaultView
        myTable = myDataSet.Tables("AphidData")
        myCon.Close()
        myCon = Nothing
    End Sub
    Public Sub myUpdate()
        myBuilder = New SqlCeCommandBuilder(myAdap)
        myAdap.Update(myTable)
    End Sub
End Module

I use VB.NET 2010 and SQL Server Compact 3.5 database. I want to load existing data in the database and change/add and then update. My "View Data" button will call "ShowData" and its working. Then I can add new data but cannot change existing data using above "myUpdate" procedure. Please help me. I am new to VB.NET and database. Error message is "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."
Thanks