Avatar of rivkamak
rivkamak
Flag for United States of America asked on

Error in prepared statement

I have a very long prepared statement in ASP VB.
I am getting a 500 error on the execute line so I have no idea where to start on debugging anything.
This is my errror
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ','.
can anyone help me on where I can start looking?
ASPVB Script

Avatar of undefined
Last Comment
Shaun Kline

8/22/2022 - Mon
Shaun Kline

You code post the offending line here. Someone here can help. Another option is to print the line to your asp page and then end the processing just after the line, then run that output in a query tool (SSMS) to see where the error is occurring.
rivkamak

ASKER
How can I print the prepared statement with a response.write?
   Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = myConn
    MM_editCmd.CommandText = "INSERT INTO dbo.tKAOCD (KAOCD_First, KAOCD_Last, KAOCD_Address,KAOCD_City, KAOCD_State,  KAOCD_Zip,KAOCD_Country, KAOCD_Email, KAOCD_PhoneHome, KAOCD_PhoneCell, KAOCD_PickAddress, KAOCD_PickCity, KAOCD_PickState, KAOCD_PickZip, KAOCD_CarType, KAOCD_HasTrailer, KAOCD_Year, KAOCD_Make, KAOCD_Model, KAOCD_Make_BoatRV, KAOCD_Model_BoatRV, KAOCD_Length, KAOCD_Color, KAOCD_Mileage, KAOCD_LicensePlate, KAOCD_HaveTitle, KAOCD_Running,KAOCD_Vin, KAOCD_CarNotes, KAOCD_PickNotes, KAOCD_WebEnteredBy, KAOCD_Org, KAOCD_OrgPhone,KAOCD_Source	 , KAOCD_SawAdIn, , KAOCD_AutoRefer, KAOCD_Url,KAOCD_Url2, KAOCD_GaSource,KAOCD_GaMedium, KAOCD_GaCampaign, KAOCD_GaKeyword, KAOCD_GaContent,KAOCD_GaExactQuery, KAOCD_Matchtype, KAOCD_Device,  KAOCD_CID, ipaddress) VALUES (?, ?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?,?,?, ?, ?, ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" 

    MM_editCmd.Prepared = true

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, firstname) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, lastname) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 50, address) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, st) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 50,Request.Form("city")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 50, Request.Form("Zip")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 2, country) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 50, Request.Form("E_mail")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 50, Request.Form("Phone_Home")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 50, Request.Form("Phone_Cell")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 50,Pick_Adres) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 50, Request.Form("Pick_City")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 202, 1, 50, Request.Form("Pick_State")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 202, 1, 50, Pick_Zip) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 202, 1, 20, carType) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 5, 1, -1, MM_IIF(HasTrailer, HasTrailer, null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param16", 202, 1, 50, carYear) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param17", 202, 1, 50, carMake) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param18", 202, 1, 50, carModel) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param19", 202, 1, 50, Make_BoatRV) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param20", 202, 1, 50, Model_BoatRV) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param21", 202, 1, 50, Request.Form("Length")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param22", 202, 1, 50,carColor) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param23", 202, 1, 50, carMile) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param24", 202, 1, 20, Request.Form("LicensePlate")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param25", 202, 1, 50, carTitle) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param26", 202, 1, 50, carRunning) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param27", 202, 1, 50, Request.Form("VIN_Num")) ' adVarWChar
	    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param27", 202, 1, 250, carCondition) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param27", 202, 1, 250, comments) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param27", 202, 1, 50, Request.Form("Entered_By")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param27", 202, 1, 50, Request.Form("org")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param27", 202, 1, 50, Request.Form("orgPh")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param27", 202, 1, 50, request.Cookies("source1") ) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, sawAdIn) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 202, 1, 50, auto_refer) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 202, 1, 500,urlTry2) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 202, 1, 500, url2) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 50,Lcase(gasource)) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 50, Lcase(gamedium) ) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 500, Lcase(GaCampaign)) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 500, Lcase(GaKeyword)) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 500, Lcase(GaContent)) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 500,Lcase(GaExactQuery)) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 500,Lcase(matchtype)) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 500,Lcase(device)) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 30, left(request.form("cid"),30)) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 20, left(Request.ServerVariables("REMOTE_ADDR") ,20) ) ' adVarWChar
   
    MM_editCmd.Execute
%>
<!--#include virtual="/Connections/errorhandler.asp" -->
<%
'if it was entered into unfinished table and then they donated the firsttime around, just delete the unfinished row
if request.form("id") <> "" AND request.Cookies("utm")("source") <> "form-drop-list" then 

 Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = myConn
	'maybe do a select statemnet and if sentemail <> 1 then do a delete with id instead of update
	deletetext = "DELETE FROM [OnlineUnfinishedDonations] where id ='" & Request.Form("id")  & "'"
	session("errorInfo") =  "<br>" & updatetext & session("errorInfo") 
	MM_editCmd.CommandText = deletetext
  MM_editCmd.Execute
	end if 
'if they came back from the dropped email, then update unfinished with second date
if request.form("id") <> "" AND request.Cookies("utm")("source") = "form-drop-list" then 
 Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = myConn
	updatetext = "UPDATE [OnlineUnfinishedDonations] SET  donated = 1, dateSecondDonation = '" & date() & "' where id ='" & Request.Form("id")  & "'"
		session("errorInfo") = session("errorInfo") & "<br>" & updatetext

	MM_editCmd.CommandText = updatetext
  MM_editCmd.Execute

Open in new window

ASKER CERTIFIED SOLUTION
Shaun Kline

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23