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