SQL, Dataview, DataTable and DataAdapter.Update

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

SQL, Dataview, DataTable and DataAdapter.Update

 
0
  #1
Jun 14th, 2007
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:

  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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: SQL, Dataview, DataTable and DataAdapter.Update

 
0
  #2
Jun 15th, 2007
the SQL SELECT Query is now
  1. "SELECT DISTINCT * FROM tblUser"
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 13
Reputation: chan_lemo is an unknown quantity at this point 
Solved Threads: 1
chan_lemo chan_lemo is offline Offline
Newbie Poster

Re: SQL, Dataview, DataTable and DataAdapter.Update

 
0
  #3
Nov 3rd, 2008
Is your User Name Unique ?
Check that first .

Try this also for update.

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

lemo.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC