Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 insert query

Author  Topic 

funkyspirit
Starting Member

9 Posts

Posted - 2011-12-22 : 08:23:42
Hello,

I need to insert an id number, assigned to the variable MerchantId,into the table Cases. To do so, I wrote the query below. However, when I execute it I get a "Syntax error near where" error message. Any idea why? Thanks a lot.

dim rsmerchantId

set rsmerchantId = Server.CreateObject("adodb.recordset")

merchant_query = "INSERT INTO Cases (MerchantId) values('"&MerchantId&"') WHERE UserId = '" & iduser & "'"

rsmerchantId.Open merchant_query,OLSLive,1,3

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2011-12-22 : 08:33:55
You are doing an insert and not an update. Where would userid be equal to iduser when a record doesn't already exist?

If this is supposed to be an update to that field in a table where records already exist, write an update:

"UPDATE Cases SET MerchantId = '"&MerchantId&"' WHERE UserId = '" & iduser & "'"


otherwise just remove your WHERE condition.
Go to Top of Page
   

- Advertisement -