when trying to update a sql database i get the following error message on Update

Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information

the column UserID is the PrimaryKey

any ideas would be appreciated

Thanks
Peter


example code:

Private dt as new datatable
private dv as new dataview

Public sub GetData
    dim da as new SqlDataAdapter("SELECT * FROM tblUser", sqlconn.connectionstring)
    da.fill(dt)
    dt.TableName = "tblUser

    dv.table = dt
    dgUserData.datasource = dv
end sub

private sub setdata()
    Dim Row As DataRow
    Row = dv.Item(dgUserData.CurrentRow.Index).Row

    Row("username") = txtUsername.text
end sub

private sub SaveDataToServer()
    dim da as new SqlDataAdapter("SELECT * FROM tblUser", sqlconn.connectionstring)

da.update(dt)

end sub

the SQL SELECT Query is now

"SELECT DISTINCT * FROM tblUser"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.