Knowledgebase: ASP
How
do I connect to my mySQL database using ASP?
Making the Data Connection to your mySQL Database is done fairly easily
through ASP. The required coding is:
<%@ LANGUAGE="VBSCRIPT" %><% strConnection ="driver={MySQL};
server=localhost;uid=YOUR_USERNAME; pwd=YOUR_PASSWORD;
database=YOUR_DATABASE_NAME;option=NUM"Set adoDataConn =
Server.CreateObject("ADODB.Connection") adoDataConn.Open strConnection
%>
You should replace the fields with YOUR USERNAME, PASSWORD, and DATABASE_NAME
with the appropriate information on your account. Once the connection
is established you can then issue SQL statements to perform your queries
or record additions. Burningbulb does not program or debug any of the
ASP pages that you place on our servers. You should be an experienced
developer before working with the ASP language on our system.
How
do I connect my Microsoft Access database using ASP?
You cannot put your MS Access database on our servers. Burningbulb has
Linux servers that are not compatible with the Microsoft Acess database
product. However, you can export your MS Access database into a mySQL
database environment and then utilize your mySQL database on our servers
through your ASP pages. To export an Access Database into MySQL do the
following:
1 - First, you must successfully install mySQL on your Virtual Server.
Be aware that you will need to consult the mySQL users manual for information
on using mySQL.
2 - Add a user with password privileges to your mySQL database. Instructions
on this are contained in the Adding New User Privileges section of the
mySQL users manual.
3 - Download and install the necessary ODBC mySQL driver on your computer.
There are currently drivers available for both Window95 and Windows NT.
Select the appropriate driver for your computer. Please visit the following
URL to download ODBC driver for your computer : http://www.mysql.com/downloads/api-myodbc.html
4 - Unzip the appropriate driver on your computer, likely in a temp directory
or other location of your choosing.
5 - Run the setup program for the driver. To do this simply double-click
on the setup.exe in the directory you unzipped the driver in.
6 - Following the setup of the mySQL driver on your computer, you will
need to configure it for use. To do this go to your Control Panel (start
-> setttings -> control panel) and double click on ODBC icon. You
will then need to select whether you want to configure the ODBC driver
for use by a single user or for use by every user on the computer. The
first tab, "User DSN" is for only a specific user and can only
be used on your specific computer. The second tab, "System DSN"
is used to configure the ODBC driver for all users on your computer. Depending
on which you choose to use, you will then click the add button on the
right side. By clicking the add button you will be given a choice of drivers
you can set up for a data source. You should find mySQL in the list. Select
mySQL and click finish.
7 - The TcX mysql driver default configuration screen will then appear.
You will want to fill out the fields with the appropriate information.
a. Windows DNS Name: type a name for this particular driver that you will
be using for MySQL. The name is something of your choosing.
b. Server: This is the name of the Virtual Server you will be publishing
your database to. (example: myserver.net)
c. mySQL Database Name: This needs to be the mySQL user you created in
step #2 in this list. (example: mysql)
d. Password: Simply the password, if applicable for the mySQL user in
the field above.
e. Port (if not 3306): If you are behind a Firewall you will need to open
up port 3306 or another port you specify or it will not work correctly.
8 - Now you are ready for using Access. Open up Access and create or select
the database you want to move to your Virtual Server in the Tables section.
Once you have selected the appropriate table, select Save As/Export under
the File menu. This will allow you to select the "To an External
File or Database" option. Click OK.
9 - The Save Table screen will appear. You will want to select the field
and then change the "Save as type" to ODBC Databases and click
Export.
10 - The Export screen appears. The "Export Addresses to:" should
simply be the name you want to call this specific database table on the
Virtual Server.
11 - The "Select Data Source" screen should then appear. Select
the "Machine Data Source" tab and then select the Data Source
Name you should have set up previously in step 7a.
12 - The table should then be moved to the Virtual Server under the user
you specified for mySQL. To verify this, use SSH to connect to your Virtual
Server and find the table.
©
2003 Burningbulb.net |