I have two tables that I join sims and transactionlog and display in a Asp GridView using a SQLDatasource
Then I have an ASP GridView with the following select and update statements:
SelectCommand="SELECT * FROM sims s INNER JOIN TransactionLog AS tl ON s.id = tl.SimsId"
UpdateCommand="UPDATE SET s.Notes=@Notes FROM sims s INNER JOIN TransactionLog AS tl ON s.id = tl.SimsId WHERE s.id=@id and tl.Id=@Id1"
Right now I only have the Notes column not set to readonly, but would like to add the others in later as soon as I can get the update statement to work for the notes column first.
When I try to update the notes column the error I’m getting is the following:
Incorrect syntax near the keyword ‘SET’.]
Mmm, hope my question is stated clearly enough.
This is how you write and SQL
UPDATEstatement with theFROMclause.This means that your statement should look like this:
I do however doubt the
WHEREclause. Maybe there’s no need to use both IDs there, but only you know that.Try you queries in SQL Management Studio before applying them in you application for a better debugging experience.
Here is the MSDN docs on the
UPDATEstatement: http://msdn.microsoft.com/en-us/library/ms177523.aspx