Common Database Connection Methods (ODBC, ole db, udl)

Source: Internet
Author: User
Tags dsn ole

The connection method between the database and the development tool in B/S mode.

1. Use ODBC to connect to the database:

ODBC provides three kinds of DSN, the difference is very simple: User DSN can only be used for this user. The difference between the system DSN and the file DSN is that the storage location of the connection information is different: the system DSN is stored in
ODBC storage, while the file DSN is placed in a text file.

When using them in ASP, the statement is as follows:

1) SQL Server:

System DSN: connstr = "DSN = dsnname; uid = xx; Pwd = xxx; database = dbname"

File DSN: connstr = "filedsn = xx; uid = xx; Pwd = xxx; database = dbname"

You can also use a connection string (so that you do not need to createDSN ): 

Connstr = "driver = {SQL Server}; server = servername; uid = xx; Pwd = xxx"

2) access:

System DSN: connstr = "DSN = dsnname"

(Or: connstr = "DSN = dsnname; uid = xx; Pwd = xxx ")

File DSN: connstr = "filedsn = xx"

You can also use a connection string (so that you do not need to create a DSN ):

Connstr = "driver = {Microsoft Access driver}; DBQ = D: \ ABC. mdb"

2. Use oledb to connect to the database: 1). SQL Server:

Connstr = "provider = sqloledb; Data Source = servername (Data
Source = (local) or data source = "127.0.0.1", server name); uid = xx; Pwd = xxx; database = dbname"

2) access:

Connstr = "provicer = Microsoft. Jet. oledb.4.0;

Data Source = c: \ ABC. mdb"

3. Use the udl file:

A udl file is a text file used to store database connection information, which is a bit like a file DSN. However, udl is for oledb (direct and ODBC-oriented.

Udl creation method:

Right-click desktop or resource manager-> New-> Microsoft Data Connection

The setting should be clear.

Udl usage:

Connstr = "file name = E: \ ABC. udl"

Link: http://yiqianlingyiye0109.blog.163.com/blog/static/181221173201211994524570/

Author: Zhang Bo, ninth Information Technology Improvement Course of Langfang Normal University

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.