|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with my code - Syntax Error
I keep getting a syntax error with the following insert statement but I can not figure out why. Can anyone please help. The only value that is not going into a text field is zip. Thanks in advance.
Code:
<%
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConString
sql = "insert into clients (companyName,domain,address,address2,city,state,zi p,comments,phone)"
sql = sql & " values( " & companyName & " , " & domain & " , " & address1 & " , " & address2 & " , " & city & " , " & state & " , '" & zip & "' , " & comments & " , " & phone & ")"
Conn.Execute(sql)
%>
|
|
#2
|
||||
|
||||
|
Welcome to the forums
![]() this part of you sql statement is wrong: it should be: Code:
sql = sql & " values( '" & companyName & "' , '" & domain & "' , '" & address1 & "' , '" & address2 & "' , '" & city & "' , '" & state & "' , " & zip & " , '" & comments & "' , '" & phone & "')" As you mentioned, if zip is the only numeric field then in your sql it should be between " & zip & " .... character fields should be between '" & yourcharfield & "' and so on. Almost correct, you just had it backwards ![]()
__________________
................... ASCII and ye shall receive .................. Knowledge is the only resource on earth that multiplies when shared Support the Shemzilla Project Powered by C# |
|
#3
|
|||
|
|||
|
wow I guess I was just not paying attention there, thanks. But for some reason still a syntax error in the same SQL statement. Any ideas. Thanks again.
|
|
#4
|
|||
|
|||
|
Ok. I have it narrowed down a little. It has something to do with the domain field. I took all the objects out and put them back one by one and did not get a syntax error until the domain was inserted. I took domain out and added everything else back in and it works fine. I tried to rename the variable, in case domain was a reserved name, and it still does not work.
Domain is a text field in my database and I am trying to insert text. I am using the value ' " & domainURL & " '. Does anyone have any idea what is going on. |
|
#5
|
||||
|
||||
|
Right before this line:
Conn.Execute(sql) do a Response.Write sql Response.End() and check if the sql statement looks correct. It's always helpful to see what your sql statement looks like, especially if it's giving you problems ![]() Post the result |
|
#6
|
|||
|
|||
|
what is the error msg , that u get
|
![]() |
| Viewing: ASP Free Forums > Other > Programming Help > Help with my code - Syntax Error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|