Frog Frog Recommended: Database Connection Page in ASP

zhaozj2021-02-12  135

<%

DIM CONN, STRCONN, MMDB

'Change the database name

MMDB = "# Test.mdb"

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

StrConn = "provider = microsoft.jet.Oledb.4.0; data source =" & server.mappath ("& mmdb &")

'If your server uses an older version access driver, use the following connection method.

'strconn = "driver = {Microsoft Access Driver (* .mdb)}; dbq =" & Server.mappath ("& MMDB &")

'If it is a connection method with SQLServer

StrConn = "driver = {SQL Server}; server = 192.168.0.110; database = WAWA; UID = SA; PWD = SA;"

'Response.write (strconn)' test statement

'When debugging, I will comment on the Error Resume next, otherwise some errors you can't see it.

ON Error ResMe next

Conn.open straconn

IF Err THEN

Err.clear

Conn.close

Response.write "

This website is working everyday maintenance, please wait later! < / p> "

Response.end

'Else

'Response.write ("successful connection")

END IF

Function CloseData

Conn.close

Set conn = Nothing

END FUNCTION

%>

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

New Post(0)