nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   Software Development (http://www.nvnews.net/vbulletin/forumdisplay.php?f=53)
-   -   Learning MySQL using ASP (http://www.nvnews.net/vbulletin/showthread.php?t=103567)

technoid 12-03-07 06:00 AM

Learning MySQL using ASP
 
I'm trying to learn MySQL using ASP and I'm getting a syntax error when I try to add a row to an empty table I created, does anyone know what's wrong with the last line of the code I'm using? Or anything else for that matter. It seems to connect to MySQL but I get the error message below. The name of the table in MySQL is 'order' so that part should be okay, I think, at least I looked and it shows the name 'order'. The 'id' element is auto incrementing and I've tried leaving it out of the update list too. Thanks for any help.

CODE
Quote:

connectstr = "Driver={MySQL ODBC 3.51 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr

Set oRS = oConn.Execute ( "INSERT INTO order (id, type, pn, cc) VALUES (NULL, 'SDP3430', '910', '5486')" )
ERROR
Quote:

[MySQL][ODBC 3.51 Driver][mysqld-4.1.22-max-log]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 'order (id, type, pn, cc) VALUES (NULL, 'SDP3430', '910', '5486')' at line 1

LinuxManMike 12-03-07 11:13 AM

Re: Learning MySQL using ASP
 
order is an SQL keyword. If you are going to use it as a table name try surrounding it with these goofy quote marks (not sure what its called, on same key as tilde ~) like this:
Code:

INSERT INTO `order` (id, type, pn, cc) VALUES (NULL, 'SDP3430', '910', '5486')

technoid 12-03-07 11:45 AM

Re: Learning MySQL using ASP
 
Quote:

Originally Posted by LinuxManMike
order is an SQL keyword. If you are going to use it as a table name try surrounding it with these goofy quote marks (not sure what its called, on same key as tilde ~) like this:
Code:

INSERT INTO `order` (id, type, pn, cc) VALUES (NULL, 'SDP3430', '910', '5486')

Give this man a cookie :) I fought with this all day yesterday.

I deleted the table and created a new one using sdp_orders as the name and now I can add rows from the on-line manager. I'll go modify my asp code and see if that works too. I'll let you know after I do that, thanks again.

EDIT:
I modified my asp code and it works now too, many thanks. I came so close to using sdp_orders for the table name but I had already created it and didn't know how to change the name so I left it alone. Man, what a mistake :) Thanks again for your help.

LinuxManMike 12-03-07 12:42 PM

Re: Learning MySQL using ASP
 
Glad to help. So... when can I expect that cookie? :)

technoid 12-03-07 02:56 PM

Re: Learning MySQL using ASP
 
Quote:

Originally Posted by LinuxManMike
Glad to help. So... when can I expect that cookie? :)

It's in your browser cache :D

LinuxManMike 12-03-07 03:18 PM

Re: Learning MySQL using ASP
 
I must be a geek because I find that hilarious! :rofl

technoid 12-04-07 05:31 AM

Re: Learning MySQL using ASP
 
Quote:

Originally Posted by LinuxManMike
I must be a geek because I find that hilarious! :rofl

hehehe... I know, it sounds like we're both geeks :)

I created a demo for my boss and he already has plans for it. So you helped me get another job at work :D

LinuxManMike 12-04-07 09:39 AM

Re: Learning MySQL using ASP
 
Oh, cool, you got a job...

...in that case...

...where's my money??? (pimp)

technoid 12-04-07 06:47 PM

Re: Learning MySQL using ASP
 
Quote:

Originally Posted by LinuxManMike
Oh, cool, you got a job...

...in that case...

...where's my money??? (pimp)

Oh man... I'm dying here :) I swear, the checks in the mail :D


All times are GMT -5. The time now is 06:07 AM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.