944,205 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 40453
  • VB.NET RSS
Jun 14th, 2007
0

SQL, Dataview, DataTable and DataAdapter.Update

Expand Post »
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:

VB.NET Syntax (Toggle Plain Text)
  1. Private dt as new datatable
  2. private dv as new dataview
  3.  
  4. Public sub GetData
  5. dim da as new SqlDataAdapter("SELECT * FROM tblUser", sqlconn.connectionstring)
  6. da.fill(dt)
  7. dt.TableName = "tblUser
  8.  
  9. dv.table = dt
  10. dgUserData.datasource = dv
  11. end sub
  12.  
  13. private sub setdata()
  14. Dim Row As DataRow
  15. Row = dv.Item(dgUserData.CurrentRow.Index).Row
  16.  
  17. Row("username") = txtUsername.text
  18. end sub
  19.  
  20. private sub SaveDataToServer()
  21. dim da as new SqlDataAdapter("SELECT * FROM tblUser", sqlconn.connectionstring)
  22.  
  23. da.update(dt)
  24.  
  25. end sub
  26.  
Last edited by ptaylor965; Jun 14th, 2007 at 12:41 pm.
Similar Threads
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Jun 15th, 2007
0

Re: SQL, Dataview, DataTable and DataAdapter.Update

the SQL SELECT Query is now
VB.NET Syntax (Toggle Plain Text)
  1. "SELECT DISTINCT * FROM tblUser"
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Nov 3rd, 2008
0

Re: SQL, Dataview, DataTable and DataAdapter.Update

Is your User Name Unique ?
Check that first .

Try this also for update.

http://vb.net-informations.com/dataa...-sqlserver.htm

lemo.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
chan_lemo is offline Offline
17 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Panel Opacity
Next Thread in VB.NET Forum Timeline: Help Web Browser Open File Dialog Problems





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC