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

Syntax error in INSERT INTO statement

Status
Not open for further replies.

AGNEW2PRG

Technical User
Aug 5, 2003
98
AE
Hi All,

I have been trying to find the error on this statement for quite a while now, and cant spot it. please could anyone point out the obvious.

Regards


<%

set con = Server.CreateObject("ADODB.connection")
accessdb = "./database.mdb"
con.open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCe="&server.mappath(accessdb)



strID=Request.Form("id")
strcompany=Request.Form("company")
strcontact=Request.Form("contact")
strjobfunction=Request.Form("jobfunction")
straddress=Request.Form("address")
strmobile=Request.Form("mobile")
strtel=Request.Form("tel")
strext=Request.Form("ext")
strfax=Request.Form("fax")
stremail=Request.Form("email")
strweb=Request.Form("web")


mysql = "INSERT INTO tblcontacts"
mysql = mysql & "VALUES'"& "ID='" & strID & "',"
mysql = mysql & "Company='" & strcompany & "',"
mysql = mysql & "Contact='" & strcontact & "',"
mysql = mysql & "JobFunction='" & strjobfunction & "',"
mysql = mysql & "Address='" & straddress & "',"
mysql = mysql & "Mobile='" & strmobile & "',"
mysql = mysql & "Tel='" & strtel & "',"
mysql = mysql & "Fax='" & strfax & "',"
mysql = mysql & "Email='" & stremail & "',"
mysql = mysql & "Web='" & strweb & "';"
con.execute mysql
%>

 
always do a response.write on your sql statement to see if the query is getting passed correctly...

an insert statement should look like this:

insert into mytable(field1, field2) VALUES ( field1val, field2val)

in your string...i see no space between tblcontacts and Values..

i would suggest you to structure your query string correctly and do a response.write

-DNG
 
I always find Response.Write helpful to debug this type of error... Something like this:[tt]
[...]
mysql = mysql & "Web='" & strweb & "';"
Response.Write "<br><br>" & mysql & "<br><br>"
Response.End

con.execute mysql
[/tt]
 
DNG/Sheco,

Thanks for the help, got it working..

on a seperate topic, what's the best way to get a client side command (onclick) to run a sub within the page on the server?

eg:

<%

sub runstserver
Code .....
end sub

%>

<html>
<script>
Sub confirm_OnClick
code...(calls sub runstserver)
End Sub
</script>
<input align='center' type='button' value='Okay' name="confirm">
</html>

is this possible??
 
aganthony,

You might want to check out the FAQ's section for how to post in these fora.

One thing to remember is that you should post 1 question in 1 thread, that way future users will be able to find answers easier via the title.

Another is to post your question in the correct forum. ASP is a server side technology, so client side questions are not relevant here. You should try the VBScript forum for what you have above.

However, I would recommend using Javascript clientside instead of VBScript as VBScript is only supported by IE - not Firefox, Mozilla, Netscape, Opera, Konqueror etc etc.

You might find this link interesting:
and forum216

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top