Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Insert Syntax Error


Message #1 by "Ceri Thomas" <webmaster@p...> on Mon, 26 Feb 2001 20:08:06
Function WhiteSpace(StringToConvert, ReplaceChar, ConversionChar)

	TempString = StringToConvert

		LastFound = instr(TempString, ReplaceChar)

			do Until LastFound = 0

				TempString = left(TempString, LastFound -

1) & ConversionChar & right(TempString, Len(TempString) - LastFound)

				LastFound = instr(TempString, ReplaceChar)

			Loop

	WhiteSpace = TempString

End Function



'Request Form Variables and Declare SQL variables



Dim txtName, txtAddress, txtCity, strPostcode, intTelephone, intFax, 

txtEmail, strSQL



txtName = Request("Name")

txtAddress = Request("Address")

txtCity = Request("City")

strPostcode = Request("Postcode")

intTelephone = Request("Telephone")

intFax = Request("Fax")

txtEmail = Request("Email")



txtName = WhiteSpace(txtName ," ", "_")

txtAddress = WhiteSpace(txtAddress ," ", "_")

txtCity = WhiteSpace(txtCity ," ", "_")

strPostcode = WhiteSpace(strPostcode ," ", "_")

intTelephone = WhiteSpace(intTelephone ," ", "_")

intFax = WhiteSpace(intFax ," ", "_")

txtEmail = WhiteSpace(txtEmail ," ", "_")



'Build SQL Insert Statement



strSQL = "INSERT INTO Customer(Name , Address , City , Postcode ,"  

strSQL = strSQL & "Telephone , Fax , Email) "

strSQL = strSQL & "VALUES ('" & txtName & "' , '" & txtAddress & "' , '" & 

txtCity & "' , '" 

strSQL = strSQL & "" & strPostcode & "' , '" & intTelephone & "' , '" & 

intFax & "' , '" 

strSQL = strSQL & "" & txtEmail & "')"



***************************************************************************



The code listed above is taken from an application that I am building to 

insert the details of customers into a database.



The fields listed in the 'INSERT INTO Customer(' statement exist and the 

variables are all populated with data which can be viewed as follows when



Response.Write strSQL is placed in the body of the document



INSERT INTO Customer(Name , Address , City , Postcode ,Telephone , Fax , 

Email) 

VALUES 'Customer_Name' , 'Customer_Address' , 'City_of_Origin' , 'Post_or_Z

ip_Code' , '549_68752_5468' , '742541_5663_1554' , 'someone@s...')



Please forgive the wrapping of the text.



Any help would be greatly appreciated.



please email me any solutions at cerithomas@u...
Message #2 by John Pirkey <mailjohnny101@y...> on Mon, 26 Feb 2001 13:16:50 -0800 (PST)
Your sql statement is missing the opening ( for the values clause.  Your code shows

that character there, but the resulting SQL (at least that was posted) doesn't have

it.  Check on this to see if it was a mispost or if there is something wierd

happening.



hope this helps,



john


  Return to Index