MySQL database with its short, convenient, fast, free and so on the advantages of becoming a lot of web site at present preferred database, but generally are combined with php+mysql to develop a variety of dynamic pages, in fact, ASP can also use the MySQL database development dynamic page, small series I have just learned, do not dare to enjoy, So close-up of this article for everyone's reference.
My environment is WINDOWS98+PWS4.0+MYSQL-3.23.32-WIN+PHP4.
the necessary software: PWS4.0
Mysql-3.23.32-win
Myodbc-2.50.36-dll
First step: Install MySQL
ODBD driver, copy the downloaded Myodbd-2.50.46-dll file to the Windows\System directory (Windows2000 is winnt/system32) and create a new file with the extension reg (that is, 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 "=" a "
[hkey_local_machine\software\odbc\ Odbcinst. INI\ODBC Drivers]
"MYODBC Driver" = "Installed"
After saving, double-click the file to register the above code in the Windows registry.
If installed in Windows2000, then the value of the driver and the Setup primary key will be changed accordingly, and I don't want to say more. If successful, you will see the MYODBD driver in the driver for the/ODBD data source in the Control Panel!
Step two: Set up ASP file link database
Here are two ways to create a System DSN in an ODBC data source. Later I found that it was possible to use MySQL in ASP, and the method would be preached below.
Open the Control Panel/odbd the data source, select the System DSN, then add a new DSN, the driver chooses MYODBD driver, and a dialog box appears to enter MySQL-related information.
Windows DSN Name: The name of the DSN to be established
MySQL Host (name or IP): the name of the MySQL server or IP address, usually filled localhost
MySQL database name: You need to use the names of the databases, which are established in the MySQL management program. Here we use an example. Database name: hc188
There are data tables: The User Data table has two fields: username and password, inserting a few data randomly.
User: The username of the linked database, I am the root superuser
Password: Link database user password, if not, can not fill
Port (if not 3306): MySQL on server ports, if not filled defaults to 3306
SQL command on Connect: Using SQL commands to link to a database that does not fill in
Select OK to save after completing the completion.
The following links the ASP code of the database!
<%
strconnection = "dsn=hc188;driver={myodbd driver};server=localhost;uid=root;pwd=;d atabase=hc188"
Set Adodataconn = Server.CreateObject ("ADODB"). Connection ")
adodataconn.open strconnection
strquery =" SELECT * from User "
Set rs = Adodataconn.execute ( strquery)
If not Rs. BOF Then%>
username |
password |
<% Do but not Rs. EOF%>
<%=rs ("username")%> |
<%=rs ("password")%> |
<% Rs. MoveNext Loop%>
<% Else Response.Write ("Sorry, no data found.") End If
Rs. Close
adodataconn.close
Set adodataconn = no
set rsemaildata = Nothing
%>
The second approach: I thought about using the MySQL database if I didn't create a system DSN? The result is OK.
The method is simple, the second line of code for the above ASP code should read:
strconnection= "defaultdir=;D river={myodbc Driver};d atabase=hc188"
I am surprised to find that this method can be used even if the username and password are not needed. Is it a bug in MySQL?
All the above code passed the test!
I hope that through this article on MySQL and ASP using the database method introduction, can bring you help.