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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL INSERT INTO Problem

Status
Not open for further replies.

Manxman55

IS-IT--Management
Aug 16, 2005
5
GB
Here's the code:
<%
// Create Memory Variable
Dim m_strSQL
//
// Build the SQL statement
m_strSQL = "INSERT INTO <TableName>(fieldname2,fieldname3,fieldname4,fieldname5,fieldname6, Etc...)
VALUES (Session('Variable2),Session('Variable3'),Session('Variable4'),Session('Variable5),Session('Variable6')Etc.....)"
// Create the MySQL Connection.
set MySQLConn = server.createobject("adodb.connection")
// Open the Database
MySQLConn.open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=<IP Address>;DATABASE=<Database>;USER=<User>;PASSWORD=<Password>;OPTION=3;"
//
// Open recordset
Set objRS = MySQLConn.Execute(m_strSQL)
// Close the recordset
objRS.close
Set objRS = Nothing
// Close the database
MySQLConn.close
Set MySQLConn = Nothing
%>

The INSERT INTO statement gives me syntax errors immediately after the "VALUES" statement. How Come?

PS... I must use the global Session("variable1") variables and need to find out how to place them in the proper fields in the database.

I could change the global variables to local ones for this page by the Dim m_variable1,m_variable2,m_variable3
and then "m_variable1=Session("variable1") statements
and then try to insert VALUES (m_variable1,m_variable2)Etc..,

Would that work?

Thanks in anticipation.....

 
should look like this:

VALUES ('"&Session("Variable2")&"','"&Session('Variable3')&"',... and so on...

or

VALUES ('"&m_variable1&"','"&m_variable2&"'...and so on...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top