Hints, tips and tricks for newbies
Moderators: JRL, Dorian (MJT support)
-
jtsy
- Newbie
- Posts: 7
- Joined: Tue Jul 17, 2007 9:09 am
Post
by jtsy » Tue Jul 17, 2007 9:15 am
Hi i'm trying to connect to MySQL Database using ODBC Connection Driver. There was no error message when i executed it, but my database doesn't seem to be updated. Any form of help will be greatly appreciated! Below is my code
Dim MyDB : MyDB=Server.CreateObject("ADODB.Connection")
MyDB.open "Driver={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=mydatabase; USER=root; PASSWORD=*****; OPTION=3;"
MyDB.Execute("INSERT INTO carriertest VALUES('3', 'temp');")
Thank you very much

-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Tue Jul 17, 2007 9:26 am
The value returned by the Execute function should give you some clues.
-
jtsy
- Newbie
- Posts: 7
- Joined: Tue Jul 17, 2007 9:09 am
Post
by jtsy » Tue Jul 17, 2007 9:49 am
Erm how do you check what value is actually taken in? How do we print out the value? Sorry I'm a total newbie
After changing the final line to
Set rs = MyDB.Execute("INSERT INTO carriertest VALUES('3', 'temp');")
I now get an error message
Specified Window "rs = MyDB.Execute("INSERT INTO carriertest VALUES('3', 'temp');")" Not Present, Any subsequent key sends in script may cause exceptions.
Thanks for your help
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Tue Jul 17, 2007 9:52 am
The code you provided is VBScript. So it should appear in a VBScript block. Something like:
VBSTART
Dim MyDB
Dim rs
Set MyDB = Server.CreateObject("ADODB.Connection")
MyDB.open "Driver={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=mydatabase; USER=root; PASSWORD=*****; OPTION=3;"
Set rs = MyDB.Execute("INSERT INTO carriertest VALUES('3', 'temp');")
VBEND
-
jtsy
- Newbie
- Posts: 7
- Joined: Tue Jul 17, 2007 9:09 am
Post
by jtsy » Tue Jul 17, 2007 10:21 am
It worked! Thanks!!
