How to connect between ASP and MySql?

MohdAsalah
MohdAsalah used Ask the Experts™
on
Hi, I am new in mysql, I want to connect from ASP to Mysql, How can I do that.
I was build half of my project by considering MS SQL Server, I need now rebuild it by using MYSQL, so is it too hard, or there is the same relationship?
and where can I find a documentation about mysql.
Please help?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
this website might help

http://www.mysql.com/documentation/
Commented:
skyshadow,

Create a recordset in ASP as normal and in the ActiveConnection setting use your server with MySql on's Ip address along with the database name and usernames and passwords i.e

Set get_Index = Server.CreateObject("ADODB.Recordset")
get_Index.ActiveConnection = "Driver={MySQL};SERVER=216.222.176.64;DATABASE=MyDatabaseName;UID=duserid;PWD=password;"
get_Index.Source = "SELECT *  FROM mytable  WHERE ID = 1"
get_Index.CursorType = 0
get_Index.CursorLocation = 2
get_Index.LockType = 1
get_Index.Open()

Obviously just replace the Ip address with yours, the DATABASE with yours and the UID and PWD values with yours.

If you are using a Microsfot Server and you have installed MySQL on it you can create DSN's with the MySQL driver as you would with any other database

Migrating from Ms SQL to MySql can mean quite a few code changes dependig on how you wrote the MS Sql database. i.e. MySql does not use stored procedures etc and there is a totally different way of grabbing auto increment values after inserting a record (see LAST_INSERT_ID() under the mysql documentation)

MySQL also doesn't support Sub Selects so you may have to manually code things in ASP to get around this.

On Saying that the MySQL documentation is not bad and you always have the mailing lists and this site to get help with specific problems.

Hope this helps,

Harry

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial