Five ways to connect the database in ASP

xiaoxiao2021-03-06  52

Brief introduction of the five ways to connect the database in the ASP

This section describes how ASP connects SQL, connects Access, and other databases!

text

Five ways to connect the database in ASP

The first type - this method is used in access in Access

StrConn = "driver = microsoft access driver (* .mdb); dbq =" & server.mappath ("aspfree.mdb")

Set conn = server.createObject ("adoDb.connection")

Conn.open straconn

Second, this method is used in SQL Server

DIM CONN, ConNNTOL

Conntol = "driver = {SQL Server}; server = server name; UID = login account; PWD = login password; database = database name"

Set conn = server.createObject ("adoDb.connection")

Conn.open Concentol

Third

Strconn = "driver = {MicrosoftAccessDriver (*. mdb)};" & _

"DBQ = f: /inetpub/wwroot/somedir/db1.mdb; defaultdir = f: / inetpub / wwwroot / somedir;

& _ UID = Loginid; "& _

"PWD = password; driverid = 25; FIL = msaccess;" set conn = server.createObject ("adodb.connection")

Conn.open straconn

Fourth type of system data source

The Following Uses A Data Source Name:

Set conn = server.createObject ("adoDb.connection")

Conn.open "Example"

The fifth use ODBC data source, provided that you must set up data sources in the ODBC of the control panel

SET RS = Server.createObject ("AdoDb.Recordset")

Rs.Open "TBLNAME", "DSNName", 3, 3

Constant constant value indicates that AdopenForwardonly 0 launches only a word-only cursor, the default value AdoPenKeyset 1 Start the keyset type cursor AdoPENDYNAMIC 2 Start the Dynamic type cursor AdoPenStatic 3 Start the Static type cursor

The LockType parameter represents the LOCK type used.

Constant constant value Description AdlockReadOnly 1 Start in read-only mode, unable to run AddNew, Update, Delete, etc. When data is being updated, the system does not temporarily lock other users ADLockBatchOptimistic 4 When the data is being updated, other users must set the CURSORLOCATION property to adusebatch to operate the database.

The Options parameter represents the type of database request.

转载请注明原文地址:https://www.9cbs.com/read-115758.html

New Post(0)