How to connect the MySQL database in ASP

Source: Internet
Author: User
Tags dsn odbc odbc connection name database
Check a lot of information, ASP and MySQL connection currently has two ways: one is the use of components, more famous is MYSQLX, but a pity to 99 dollars. Two is to use MYODBC to connect, let's look at the second way.
Platform for testing:
MySQL 4.0 for Radhat Linux (you can also use for Windows)
Windows 2003 Standard Edition Windows XP 中文版
I. Installation of MYODBC
1. Visit the website www.mysql.com and download MYODBC, we are using the 3.51 version.
2. Install MYODBC to Windows
Run download back myodbc-3.51.06.exe (filename varies by version)
Ii. establishing an ODBC connection
Entering: Control Panel-ODBC data source

At this point, we can already see that there is already one item in the User DSN: Myodbc3-test, note that the Driver{mysql ODBC 3.51 driver on the right side of this argument will have to be in one word. As an ASP and database connection connection Word (conection String).
Add a "System DSN"
Select the System DSN column in the dialog box and press the Add button on the right. This will allow you to select a data source. Choose MySQL ODBC 3.51 Driver. Press "End".
A configuration dialog box pops up:

The data source name DataSource name: The identifier of the DSN used in the program, which can be arbitrarily named.
Host/server name (or IP) host/server name (or IP address), if this is the local to fill in the localhost
DB Name Database name: The name of the library you want to use in your program.
User User: Log in to MySQL using username, special note, root user due to security problems can log in, of course, users can modify the user table to remove this feature.
Password key: Password for login
Port ports: Use default values, preferably not, unless you are sure.
When all is set, press "test data source" to see that the screen shows a successful connection.

The configuration is all done! ^_^

Third, ASP and database connection

The following is my test, connection MySQL source code, the connection library name is mm, the table name is my, the table has two fields name and sex.

<title>mysql Connectivity Test </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<%
Strconnection= "Dsn=mysqltest;
Driver={mysql ODBC 3.51 driver};
Server= fill in the server address; uid= username; pwd= Secret
Code; DATABASE=MM "
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.