Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax error in execting sql statements with asp?

Status
Not open for further replies.

crymedry

MIS
Joined
Nov 19, 2003
Messages
54
hello again everyone,

i am trying to write this script that will update records that already exist in a database .... but i keep getting a syntax error. i have tried every way of typing this in that i can think of, and the only difference is the different syntax errors. here is the code as i have it right now:

StrGet="SELECT * FROM Issues WHERE [_id] = " & frm_misId & ""
StrInsert="UPDATE Issues (_detailSituation, _solution, _status"
StrValues="Values('" & frm_misDetail & "','" & frm_misSolution & "','" & frm_misStatus & "'"

'create a connection
Set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=miskb"
Set objCmd=Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection=objConn
objCmd.CommandText="" & StrGet & " " & strInsert & " " & strValues & ""


and here is the error that i get as of now:

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '[_id] = 31 UPDATE Issues (_detailSituation, _solution, _status Values('test','','New''.

i would appreciate any help that you may have.

thanks in advance,
CMD
 
A update statement is written in the following format

UPDATE tablename SET field1=something,field2=somethingelse....and so on...

An Insert statement is written as...

INSERT INTO tablename VALUES ( '"&value1&"','"&value1&"')

What do you want to do...dO u want to do a insert or update

-VJ
 
update, that is why i have the select statement at the beginning there, select only that one record, and then update the data that is in that record
 
yes but then you concantenate the "SELECT * FROM..." onto the UPDATE and there also looks to be a stray " at the end of the StrGet, a missing closing bracket on the end of the StrInsert.

The syntax of your UPDATE command is wrong as you are constructing it as an INSERT command

and to run an UPDATE does not require a SELECT first.



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top