ASP database connection method

Source: Internet
Author: User

Use ASP for development and sort out the methods for connecting ASP to access, sqlserve, and Oracle databases:

1 access (versions earlier than office2003)

Dim DB
DB = "XX. mdb"
Dim connstr, Conn
Connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath (db)
Conn. Open connstr

Accdb (Office 2007)

Connstr = "provider = Microsoft. Ace. oledb.12.0; Data Source =" + httpcontext. Current. server. mappath ("XXX. accdb ");

2 sqlserver

Dim datasrt, scadb, dataadd, dataname, datapwd, sqldatabasename

Dataadd = "localhost" 'SQL database address
Dataname = "sa" 'SQL database username
Datapwd = "" 'SQL Database Password
Sqldatabasename = "pubs" 'Database Name

Conndata = "driver = {SQL Server}; server =" & dataadd & "; uid =" & dataname & "; Pwd =" & datapwd &"; database = "& sqldatabasename &";"
Conttstr = "SQL"

3 Oracle

ODBC
Create a data source in "Control Panel"> "Data Source"> "system DSN ".
Userid = "XXX" username
Passd = "XXX" Password
Dsname = "XXX" Data Source Name
Connection string
Connstring = "DSN =" & dsname & "; uid =" & userid & "; Pwd =" & passd &";"

Oledb
You need to install the Oracle client and the Oracle oledb connection driver.
Datasource = "250"
Userid = "XXX"
Passd = "XXX"

Connstring = "provider = oraoledb. Oracle; Data Source =" & datasource & "; user id =" & userid & "; Password =" & passd &";"

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.