The string cui set connecting various databases through ADO (b) (end)

Source: Internet
Author: User
Tags ole first row access database
ado| Data | database | string (next)

22. Next, let's talk about using OLE DB to connect to a database.

1 OLE DB Provider for Active Directory Service

<%

Dim Oconn,strconn

Set oconn=server.createobject ("ADODB. Connection ")

Strconn= "Provider=adsdsoobject" & _

"User id=myusername;" & _

"Password=mypassword;"

oConn.Open strconn

%>

2 OLE DB Provider for DB2

<%

Dim Oconn,strconn

Set oconn=server.createobject ("ADODB. Connection ")

Strconn= "Provider=db2oledb;" &

"Network transport Library=tcpip;" &

"Network Address=myserver;" & _

"Package collection=mypackage;" &

"Host ccsid=1142"

"Initial catalog=mydb;" &

"User id=myusername;" & _

"Password=mypassword;"

oConn.Open strconn

%>

3 OLE DB Provider for Index Server

<%

Dim Oconn,strconn

Set oconn=server.createobject ("ADODB. Connection ")

Strconn= "Provider=msidxs" & _

"Data Source=mycatalog;"

oConn.Open strconn

%>

4 OLE DB Provider for Internet Publishing

<%

Dim Oconn,strconn

Set oconn=server.createobject ("ADODB. Connection ")

Strconn= "Provider=msdaipp. DSO; "& _

"Data Source=http://mywebsite/mydir;" & _

"User id=myusername;" & _

"Password=mypassword;"

oConn.Open strconn

%>

5 OLE DB Provider for Microsoft Jet

Standard is also the common way of access.

<%

Dim Oconn,strconn

Set oconn=server.createobject ("ADODB. Connection ")

Strconn= "Provider=Microsoft.Jet.OLEDB.4.0" & _

"Data Source=c:\somepath\mydb.mdb;" & _

"User id=admin;" & _

"Password=;"

oConn.Open strconn

%>

If it is a workgroup system database, then the connection string is as follows.

<%

Dim Oconn,strconn

Set oconn=server.createobject ("ADODB. Connection ")

Strconn= "Provider=Microsoft.Jet.OLEDB.4.0" & _

"Data Source=c:\somepath\mydb.mdb;" & _

"Jet Oledb:system database=mysystem.mdw;", _

"Admin", "" "

oConn.Open strconn

%>

Note: When using the 4.0 OLE DB Provider provider driver, remember to convert the MDB and MDW to the 4.0 database format.

If the MDB is setting a password, use the following connection string.

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0" & _

"Data Source=c:\somepath\mydb.mdb;" & _

"Jet oledb:database Password=mydbpassword;", _

"Admin", "" "

If the MDB is located on the network and is shared, use the following connection string.

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0" & _

"Data Source=\\myserver\myshare\mypath\mydb.mdb;

If you want to use a proprietary way to access the database, use the following connection string.

Oconn.mode = admodeshareexclusive

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0" & _

"Data Source=c:\somepath\mydb.mdb;" & _

"User id=admin; password=; "

6 use OLE DB Provider for Microsoft jet to access the Excel spreadsheet.

<%

Dim Oconn,strconn

Set oconn=server.createobject ("ADODB. Connection ")

Strconn= "Provider=Microsoft.Jet.OLEDB.4.0" & _

"Data Source=c:\somepath\myexcelspreadsheet.xls;" & _

"Extended properties=" "Excel 8.0; Hdr=yes; ""; "

oConn.Open strconn

%>

Description: Here the Hdr=yes means that the provider accesses the Excel spreadsheet without adding the first row of data to the dataset, and when Hdr=no means that the provider accesses the Excel spreadsheet when the action is exactly the opposite of what is described above.

7 OLE DB Provider for ODBC Databases

Accessing the MS Access database

<%

Dim Oconn,strconn

Set oconn=server.createobject ("ADODB. Connection ")



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.