Forum Moderators: open

Message Too Old, No Replies

Errors with database coding

         

traeanthony

7:53 am on Jun 28, 2006 (gmt 0)

10+ Year Member



I'm new to databases am using ASP scripting to creat my first connection to a data base, so far, I've only been able to get this error:


Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[MySQL][ODBC 3.51 Driver][mysqld-5.0.19-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'From) VALUES('qweqw')' at line 1

(the qwewq was random text I entered to test the set up)

I do have the database created (in MySQL) along with all the columns. I have the DSN set up on the server too. I had to download a driver from the MySQL website. Any clues?

Here's the coding, most of which I found on the net and put together.


<%
Response.Buffer = true
dim cnn,rst
set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "DSN=Email; DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=email; UID=user; PASSWORD=password"
sqltext = "SELECT * FROM reg"
rst.Open sqltext,cnn,3,3


dim addr,ip,day
addr = Request("emailaddy")


if addr = "" then
error = "You have not entered an email address."
Response.Write error
Response.End
end if


rst.AddNew
rst("From") = addr
rst.update


response.write("it worked")
%>

This is getting the information to store in the data base from another page. The field is called "emailaddy"

FalseDawn

10:06 pm on Jun 28, 2006 (gmt 0)

10+ Year Member



I can't really see the connection between your error message and the code you posted, but if it were me, rather than this:


rst.AddNew
rst("From") = addr
rst.update

I'd use a "proper" INSERT SQL statement to do the task, and execute that against the connection (or database - been a while since I messed with ADO)