ASP implementation using MySQL database

Source: Internet
Author: User
Tags mysql host mysql odbc driver

MySQL databaseWith its advantages of being short, convenient, fast, and free, it has become the preferred database for many websites. However, it is generally used in combination with PHP + MYSQL to develop various dynamic pages. In factASPYou can also use the MYSQL database development dynamic page. The following describes the implementation of ASP using MySQL database in detail, hoping to help you.

My environment is Windows 98 + PWS4.0 + mysql-3.23.32-win + PHP4

Necessary software: PWS4.0, nonsense)

Mysql-3.23.32-win this is the latest version)

Myodbc-2.50.36-dll this is the most important, mysql odbc driver, can download to www.mysql.com)

Step 1: Install the mysql odbd driver, copy the downloaded myodbd-2.50.46-dll file to the windows \ system directory windows2000

Is winnt/system32) and then create a new file with the extension reg as the registry file), copy the following content to the file.

REGEDIT4

[HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST. INI \ myodbc driver]

"UsageCount" = dword: 00000002

"Driver" = "C: \ WINDOWS \ System \ myodbc. dll"

"Setup" = "C: \ WINDOWS \ System \ myodbc. dll"

"SQLLevel" = "1"

"FileUsage" = "0"

"DriverODBCVer" = "02.50"

"ConnectFunctions" = "YYY"

"APILevel" = "1"

"CpTimeout" = "120"

[HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST. INI \ ODBC Drivers]

"Myodbc driver" = "installed"

Double-click the file and register the above Code to the WINDOWS registry.

If it is installed in windows2000, the value of the Driver and Setup primary key must be changed accordingly. I don't want to say much here. If it succeeds, you will see the myodbd driver in the driver of the control panel/ODBD data source!

Step 2: Create an ASP file link database.

There are two methods, one is to create a system DSN In the ODBC data source. Later, I found that MYSQL can be used in ASP even if it is not created. The method is described below.

Open Control Panel/ODBD data source, select system DSN, and add a new DSN. Select mydbd driver as the driver. A dialog box is displayed for you to enter mysql information.

Windows DSN name: name of the DSN to be created

Mysql Host name or ip address): The name or ip address of the Mysql server.

Mysql database name: the name of the database to be used. The database is created in the Mysql management program. Here is an example. Database Name: hc188

There is a data table: the user data table has two fields: username and password. Just insert a few data.

User: the user name used to connect to the database. I entered the root Super user.

Password: password used to connect to the database. If not, leave it empty.

Portif not 3306): Mysql port on the server. If this parameter is left blank, the default port is 3306.

SQL command on connect: use SQL commands to connect to the database. This parameter is optional.

After entering the information, select OK to save.

The ASP code of the database is linked below!

<%

StrConnection = "dsn = hc188; driver = {mydbd driver}; server = localhost; uid = root; pwd =; database = hc188"

Set adoDataConn = Server. CreateObject "ADODB. Connection ")

AdoDataConn. Open strConnection

StrQuery = "SELECT * FROM user"

Set rs = adoDataConn. ExecutestrQuery)

If Not rs. BOF Then

%>

<TABLE>

<TR>

<TD <B> username </B> </TD>

<TD> <B> password </B> </TD>

</TR>

<%

Do While Not rs. EOF

%>

<TR>

<TD> <% = rs "username") %> </TD>

<TD> <% = rs "password") %> </TD>

</TR>

<%

Rs. MoveNext

Loop

%>

</TABLE>

<%

Else

Response. Write "Sorry, no data found .")

End If

Rs. Close

AdoDataConn. Close

Set adoDataConn = Nothing

Set rsEmailData = Nothing

%>

Method 2: I thought about using the MYSQL database if the system DSN is not set up? The result is acceptable.

The method is very simple. Change the second line of the above ASP code:

Strconnection = "DefaultDir =; Driver = {myodbc driver}; database = hc188"

I was surprised to find that this method can be used without the user name or password. Is it a mysql bug?

I have explained in detail the implementation steps of ASP using MySQL database. I believe that you will understand the implementation methods of ASP using MySQL database through the above learning, I hope everyone will be able to get some gains from the content mentioned above and solve similar problems in the future.

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.