ASP Common connection string notation (access2007) _asp Foundation

Source: Internet
Author: User
Access Connection string
strconnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydatabase.mdb;"

Access 2007 Connection string
StrConnect = "provider=microsoft.ace.oledb.12.0; Mode=share exclusive;data source=c:\mydatabase.accdb; "

MSSQL Server Connection string
strconnect = "Provider=sqloledb;data source=servername\instancename;initial catalog=databasename; User Id=username; Password=password; "

Excel Connection string
StrConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Extended properties= "" Excel 8.0; Hdr=yes "";D ATA Source=c:\myworkbook.xls;
Where the HDR default is yes to the first behavior field name, otherwise the first row will be the content

Excel 2007 Connection string
StrConnect = "provider=microsoft.ace.oledb.12.0; Extended properties=excel 12.0;data source=c:\myworkbook.xlsx; "

Text files (text files can also be used as databases)
StrConnect = "provider=microsoft.ace.oledb.12.0; Extended properties=text;data source=c:\files\; "
Well, parameter data source is the directory name that contains the file, not the file name. If the first line of a text file does not contain a field name, you must participate in Hdr=no (with Excel) in the parameter extended properties to avoid losing the first row of data.



Using Connection Strings
Copy Code code as follows:

Dim conn
Sub Dbopen ()
Dim Db:db=server.mappath ("Zzz.mdb")
Set conn=server.createobject ("Adodb.connection")
on Error Resume Next
Conn. Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & DB
If err.number<>0 then
Err.Clear
Resp Onse. Write (' Response.End ()
End-If
on ERROR GoTo 0
End Sub

Call dbopen ()
...
Conn. Close (): Set conn=nothing

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.