Summary of ASP connecting various database methods

Source: Internet
Author: User
Data | database

Methods for connecting DBF, DBC, MDB, Excel, SQL Server databases with asp:

ASP Object Access database method

In ASP, the object that accesses the database is called ADO (Activedataobjects), 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 to connect to each database, or you can use a data source, and we recommend that you use a driver.

ODBC links

Suitable for database type/link mode

"Driver={microsoftaccessdriver (*.mdb)};d bq=*.mdb;uid=admin;pwd=pass;"

"Driver={microsoftdbasedriver (*.dbf)};d riverid=277;dbq=------------;"

"Driver={microsoftodbcfororacle};server=oraclesever.world;uid=admin;pwd=pass;"

"Driver={sqlserver};server=servername;database=dbname;uid=sa;pwd=pass;"

"Driver={microsofttextdriver (*.txt;*.csv)};d bq=-----; extensions=asc,csv,tab,txt; Persistsecurityinfo=false; "

"DRIVER={MICROSOFTVISUALFOXPRODRIVER};SOURCETYPE=DBC;SOURCEDB=*.DBC; Exclusive=no; "

"Driver={mysql};d atabase=yourdatabase;uid=username;pwd=yourpassword;option=16386;"

OLE DB links

Suitable for database type/link mode

"Provider=microsoft.jet.oledb.4.0;datasource=your_database_path;userid=admin;password=pass;"

"Provider=oraoledb.oracle;datasource=dbname;userid=admin;password=pass;"

"Provider=sqloledb;datasource=machinename;initialcatalog=dbname;userid=sa;password=pass;"

"Provider=microsof.jet.oledb.4.0;datasource=your_path; ExtendedProperties ' text; Fmt=delimited ' "


The following is an example of a database that connects to access
Dimconn
Setconn=server.createobject ("Adodb.connection")
Conn.open= "Provider=Microsoft.Jet.OLEDB.4.0;" & "Datasource=" &server.mappath ("... /db/bbs.mdb ")

Which.. /db/bbs.mdb the relative path for the database! If the database and ASP files are in the same directory, this is all you need to write:
Dimconn
Setconn=server.createobject ("Adodb.connection")
Conn.open= "Provider=Microsoft.Jet.OLEDB.4.0;" & "Datasource=" &server.mappath ("Bbs.mdb")

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



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.