sql query error -Incorrect syntax near WHERE

Class library usage, coding and language questions.
omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

sql query error -Incorrect syntax near WHERE

Post by omayer » Fri May 11, 2012 7:00 am

what am i missing here -trying to insert data in existing row

cmdScnDesc = new SqlCommand("INSERT INTO PlacementRunResults(ScenarioDescr) VALUES (@_scenarioDescr) WHERE scenarioid LIKE @_scenarioid",dbConnection._conn);
Thank you in Advance
Beginner
Tipu

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: sql query error -Incorrect syntax near WHERE

Post by artur_gadomski » Fri May 11, 2012 8:31 am

You need update statement. I think it should look like that, but you may want to google it to make sure the correct syntax.

Code: Select all

UPDATE TABLE PlacementRunResults
SET ScenarioDescr = @_scenarioDescr
WHERE scenarioid LIKE @_scenarioid

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: sql query error -Incorrect syntax near WHERE

Post by omayer » Fri May 11, 2012 4:40 pm

It works, Thank you so much for your help :D
Tipu