I have an ASP page for inserting a new record in a database. The original code functioned fine, but omitted the column list. I plan to add fields to the database, so I would like to add the column list to ensure the data goes to the right place after the table change. Unfortunately after I added the column list, though I checked the syntax a million times, I get:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. /info/revisedtrack/track_directory_insert.asp, line 187
The original SQL (ignore numfill, just a function to pad values):
SQL = "INSERT INTO Track_Table VALUES ('" &numfill(Trackname)& "','"
SQL = SQL & "" &numfill(Request.Form("Contactname"
)& "','" &numfill(Request.Form("Address"
)& "','"
SQL = SQL & "" &numfill(Request.Form("City"
)& "','" &numfill(Request.Form("comstate"
)& "','"
SQL = SQL & "" &numfill(Request.Form("Postalcode"
)& "','" &numfill(Request.Form("Phone"
)& "','"
SQL = SQL & "" &numfill(Request.Form("radio1"
)& "','" &numfill(Request.Form("radio2"
)& "','"
SQL = SQL & "" &numfill(Request.Form("radio3"
)& "','" &numfill(Request.Form("radio4"
)& "','"
SQL = SQL & "" &numfill(Request.Form("radio5"
)& "','" &numfill(Request.Form("radio6"
)& "','"
SQL = SQL & "" &numfill(Request.Form("radio7"
)& "','" &numfill(Request.Form("radio8"
)& "','"
SQL = SQL & "" &numfill(Request.Form("radio9"
)& "','" &numfill(Request.Form("radio10"
)& "','"
SQL = SQL & "" &numfill(Request.Form("radio11"
)& "','" &numfill(Request.Form("radio12"
)& "','"
SQL = SQL & "" &numfill(Request.Form("radio13"
)& "','"
SQL = SQL & "" &numfill(Request.Form("Website"
)& "','"
SQL = SQL & "" &numfill(Request.Form("emailAddr"
)& "','No','"
SQL = SQl & "" &numfill(Request.Form("comcount"
)& "', '" &date&"')"
My modified statement:
SQL = " INSERT INTO Track_Table "
SQL = SQL & "(Track_Name,Contact_Name,Address,City,State,Zip,Phone_Number,"
SQL = SQL & "T_Indoor,T_Outdoor,T_Off_Road,T_Oval,T_Banked,T_Dirt,T_Carpet,"
SQL = SQL & "T_Concrete,T_Asphalt,T_Hobby_Shop,T_AC_Power,T_Automatic_Lap,"
SQL = SQL & "T_Food,URL,Email,Country,Date) "
SQL = SQL & "VALUES ('" &numfill(Trackname)& "','"
etc. continuing as above.
Is there something specific to Access SQL that I need to know here? Or could it be that by adding the column list I exceeded some limits on the length of the statement? I could change the whole thing to recordset.addnew format I suppose, but I hate to leave it like this. Any helpful hints would appreciated. And by the way, what are pros and cons of INSERT vs. Addnew?
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. /info/revisedtrack/track_directory_insert.asp, line 187
The original SQL (ignore numfill, just a function to pad values):
SQL = "INSERT INTO Track_Table VALUES ('" &numfill(Trackname)& "','"
SQL = SQL & "" &numfill(Request.Form("Contactname"
SQL = SQL & "" &numfill(Request.Form("City"
SQL = SQL & "" &numfill(Request.Form("Postalcode"
SQL = SQL & "" &numfill(Request.Form("radio1"
SQL = SQL & "" &numfill(Request.Form("radio3"
SQL = SQL & "" &numfill(Request.Form("radio5"
SQL = SQL & "" &numfill(Request.Form("radio7"
SQL = SQL & "" &numfill(Request.Form("radio9"
SQL = SQL & "" &numfill(Request.Form("radio11"
SQL = SQL & "" &numfill(Request.Form("radio13"
SQL = SQL & "" &numfill(Request.Form("Website"
SQL = SQL & "" &numfill(Request.Form("emailAddr"
SQL = SQl & "" &numfill(Request.Form("comcount"
My modified statement:
SQL = " INSERT INTO Track_Table "
SQL = SQL & "(Track_Name,Contact_Name,Address,City,State,Zip,Phone_Number,"
SQL = SQL & "T_Indoor,T_Outdoor,T_Off_Road,T_Oval,T_Banked,T_Dirt,T_Carpet,"
SQL = SQL & "T_Concrete,T_Asphalt,T_Hobby_Shop,T_AC_Power,T_Automatic_Lap,"
SQL = SQL & "T_Food,URL,Email,Country,Date) "
SQL = SQL & "VALUES ('" &numfill(Trackname)& "','"
etc. continuing as above.
Is there something specific to Access SQL that I need to know here? Or could it be that by adding the column list I exceeded some limits on the length of the statement? I could change the whole thing to recordset.addnew format I suppose, but I hate to leave it like this. Any helpful hints would appreciated. And by the way, what are pros and cons of INSERT vs. Addnew?