asp

DSN-Less Connection to MySQL in ASP

Posted on

To access a MySQL database in ASP you can use the following script:

Function getDBConn()

Set conDB=Server.CreateObject("ADODB.Connection")
 conDB.Open "Driver={MySQL ODBC 3.51 Driver};" & _
      "Server=mysql.myserver.net;" & _
      "Port=3306;" & _
      "Option=131072;" & _
      "Stmt=;" & _
      "Database=mydatabase;" & _
      "Uid=myname;" & _
      "Pwd=mypassword"
End Function

Remember to change the Server address to the address of your MySQL database; also you will need to change the Database, Uid and Pwd parameters as appropriate.

This entry was posted in Web Development. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>