ASP data connection method

zhaozj2021-02-16  48

MS Access database connection

Connect with DSN and no username and password:

<% set conn = server.createObject ("adoDb.connection" conn.open "YourDsnname"%>

Connect with DSN and have usernames and passwords:

<% set conn = server.createObject ("AdoDb.Connection") Conn.open "YourDsnname", "UserName", "Password"%>

Use the actual database absolute path connection:

<% Set conn = server.createObject ("adoDb.connection") strconn = "driver = {microsoft access driver (* .mdb)};" strconn = strconn & "dbq = e: /yanhang/database.mdb" conn. Open strConn%>

Connect with the actual database:

<% Set conn = server.createObject ("adoDb.connection") strconn = "driver = {Microsoft Access Driver (* .mdb)};" strconn = strconn & "dbq =" & server.mAppath ("/ database / Yanhang .mdb ") Conn.open strconn%>

MS SQL Server Database Connection

Use DSN:

<% set conn = server.createObject ("adoDb.connection") conn.open "DSN = mydsn; uid = user; pwd = password; database = databasename"%>

No DSN connection:

<% Set conn = server.createObject ("adoDb.connection") DSNTemp = "driver = {SQL Server}; server = servername; uid = user; pwd = password; database = databasename" conn.open dsntemp%>

FoxPro database connection

<% Set Conn = Server.CreateObject ( "ADODB.connection") ConnStr = "Driver = Microsoft Visual Foxpro Driver; UID = userID; SourceType = DBC; SourceDB = C: /yanhang/database.dbc" Conn.Open ConnStr%>

Oracle Database Connection:

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

New Post(0)