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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Insert into statement error

Author  Topic 

funkyspirit
Starting Member

9 Posts

Posted - 2011-12-29 : 06:00:49
Hi there,

I have an issue with an insert into statement, it's something stupid I'm sure. The statement is below.

When I execute it, I get an "incorrect syntax near the keyword Where" error. MerchantNo is a variable to which a value is assigned via a request.form statement.

I have tried to write it like this ('"&MerchantNo&"') and like that ('&MerchantNo&') but I get the same error everytime.

The page is written in VBScript.

If someone could tell me how to write it, it would be much appreciated. Thanks.

dim rsmerchantId

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

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

rsmerchantId.Open merchant_query,OLSLive,1,3

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-12-29 : 07:19:03
You may be missing couple of double-quotes. See the changes in red
merchant_query = "INSERT INTO Cases (MerchantId) values ('"& MerchantNo & "') WHERE UserId = '" & iduser & "'"
Go to Top of Page
   

- Advertisement -