A collection of methods for connecting various databases with ASP

Source: Internet
Author: User
Tags dbase connect odbc mssql server mysql access database access
Data | database

  ASP Object Access database method

In ASP, the object that accesses a database is called ADO (Active Data Objects), contains three kinds of objects mainly: Connection, Recordset, Command
Connection: Responsible for opening or connecting data
Recordset: Responsible for accessing data tables
Command: Responsible for performing action query commands on the database

  Two, the connection each database driver

You can use a driver or a data source to connect to each database, but I recommend that you use a driver because it's easy and easy to use, and it's cumbersome to use a data source.

ODBC links

Ways to link database types
Access "Driver={microsoft access Driver (*.mdb)};d bq=*.mdb;uid=admin;pwd=pass;"
DBase "Driver={microsoft dBase Driver (*.dbf)};d riverid=277;dbq=------------;"
Oracle "Driver={microsoft ODBC for Oracle};server=oraclesever.world;uid=admin;pwd=pass;"
MSSQL server "Driver={sql server};server=servername;database=dbname;uid=sa;pwd=pass;"
MS text "Driver={microsoft text Driver (*.txt; *.csv)};d bq=-----; extensions=asc,csv,tab,txt; Persist Securityinfo=false; "
Visual Foxpro "Driver={microsoft visual Foxpro Driver};sourcetype=dbc;sourcedb=*.dbc; Exclusive=no; "
MySQL "Driver={mysql};d atabase=yourdatabase;uid=username;pwd=yourpassword;option=16386;"


OLE DB Links

The appropriate way to link database types
Access "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=your_database_path;user id=admin;password=pass;"
Oracle "Provider=oraoledb.oracle;data source=dbname;user id=admin;password=pass;"
MS SQL Server "Provider=sqloledb;data source=machinename;initial catalog=dbname;userid=sa;password=pass;"
MS text "Provider=microsof.jet.oledb.4.0;data Source=your_path; Extended Properties′text; fmt=delimited′ "


And we generally use Access database more, here I recommend that you connect to an Access database using the following methods:

Dim conn
Set conn = Server.CreateObject ("Adodb.connection")
Conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0" & "Data Source =" & Server.MapPath (". /db/bbs.mdb ")

Which.. /db/bbs.mdb is the relative path of your database store! If your database and ASP files are in the same directory, you can just write this:

Dim conn
Set conn = Server.CreateObject ("Adodb.connection")
Conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0" & "Data Source =" & Server.MapPath ("Bbs.mdb")

There are many beginners who have problems when they encounter a database connection, but using the driver above will not be a problem as long as your database path is selected.



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.