Full introduction to ASP using MySQL database

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

Do you think this website is worth 2 million RMB? There are 1000 bullet cells on it. One bullet cell only sells for 50 yuan, but it can sell for 2 million yuan in total. Why? It's called yixiao bullet box, www.1ktag.com. Let's take a look!
The first day of yiyun.com
How can we sell 1000 bullet cells to 2 million?
Why is the Yiyi bullet show more valuable than millions of home pages?

MySQL database has become the first choice for many websites with its advantages of short, convenient, fast, and free.
Database, but it is generally used to develop a variety of dynamic pages with PHP + MySQL. In fact, ASP can also
I used MySQL database to develop dynamic pages. I just learned to do this, so I did not dare to share it with myself.
This articleArticleFor your reference.
My environment is Windows 98 + pws4.0 + mysql-3.23.32-win + PhP4
Necessary software: pws4.0 (haha, nonsense)
Mysql-3.23.32-win (this is the latest version)
Myodbc-2.50.36-dll (this is the most important, MySQL ODBC driverProgram, Can be downloaded at 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)
Create a new file with the extension Reg (Registry File) and 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"

Save the file and double-click the file.CodeRegister 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 lecture will be given below.
Open Control Panel/odbd data source, select system DSN, and then add a new DSN. The driver selects the mydbd driver, and a pair
Dialog box for entering MySQL
Related information.
Windows DSN name: name of the DSN to be created
MySQL host (name or IP): 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. Quantity
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.
Port (if not 3306): MySQL port on the server. If not specified, the default value 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. Execute (strquery)
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?

All the above Code has passed the test!

At this point, the full text is over, isn't it easy! Hope to help you!

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.