CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 SQL INSERT INTO with VARIABLES

Print topic Send  topic

Author Message
carlosespada


Posts: 5
Posted: 12/27/2006, 7:59 AM

I am trying to insert records from one table to another using SQL but am having a problem inserting some variables along with the records. Here is my code, probably just a syntax error:

putSQL = "INSERT INTO SurveyResponses (SurveyQuestionID, UserID )" & _
"VALUES (" & "SELECT SurveyQuestions.SurveyQuestionID FROM SurveyQuestions WHERE Active = 1 AND ClientID=" & ClientID & "," & CCDLookUp("max(UserID)","Users","", Connection) & ")"

The error im getting is: Incorrect Syntax near the keyword 'SELECT'

What am I doing wrong?
_________________
Skysoft Incorporated- A Professional Software Development Company
View profile  Send private message
matheus

Posts: 386
Posted: 12/27/2006, 8:26 AM

Take off
(
{parenthesis} after VALUES.


putSQL = "INSERT INTO SurveyResponses (SurveyQuestionID, UserID )" & _
"VALUES " & "SELECT SurveyQuestions.SurveyQuestionID FROM SurveyQuestions WHERE Active = 1 AND ClientID=" & ClientID & "," & CCDLookUp("max(UserID)","Users","", Connection) & ""


_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
carlosespada


Posts: 5
Posted: 12/27/2006, 9:30 AM

I tried removing the ( and the ) but still am getting the same error....:-|
_________________
Skysoft Incorporated- A Professional Software Development Company
View profile  Send private message
peterr


Posts: 5971
Posted: 12/27/2006, 12:45 PM

I would try replacing "putSQL =" with Response.Write (you can also add Response.End on the next line), then test your syntax directly in the database.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Edd


Posts: 547
Posted: 12/27/2006, 2:26 PM

Try

putSQL = "INSERT INTO SurveyResponses (SurveyQuestionID, UserID ) " & _
" SELECT SurveyQuestions.SurveyQuestionID, " & Connection.ToSQL(CCDLookUp("max(UserID)","Users","", Connection),ccsInteger) & " FROM SurveyQuestions WHERE Active = 1 AND ClientID=" & Connection.ToSQL(ClientID,ccsInteger)



Edd

_________________
Accepting and instigating change are life's challenges.

http://www.syntech.com.au
View profile  Send private message
carlosespada


Posts: 5
Posted: 12/27/2006, 5:50 PM

Edd is the MAN!!!! But he already knew this, works perfect! Thank you!:-)
_________________
Skysoft Incorporated- A Professional Software Development Company
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.