ASP Classic database connection file support Access,mssql server
Dim conn,connstring
Sub openconn ()
if db_type = "Access" Then
connstring = "Provider = Microsoft.jet.oledb.4.0;data Source =" & Server.MapPath (Accpath)
els EIf Db_type = "SQL" Then
connstring = "Provider = SQLOLEDB; User ID = "& Sqlusername &"; Password = "& SQLPassword &"; Initial Catalog = "& Sqldatabasename &"; Data Source = "& Sqlsource &";
else
response.write The system database type is incorrect, check that the database type in the inc/const.asp is set correctly. "
response.end
end If
' on Error Resume Next
set Conn = Server.CreateObject ( connobj)
conn.open connstring
if Err Then
err.clear
conn.close: Set Conn = Nothing
response.write system database connection error, please check that the database connection section in Inc/const.asp is set correctly. '
response.end
end If
End Sub
Sub closeconn ()
on Error Resume Next
if isobject (Conn) Then
conn.close:set Conn = Nothing
end If
End Sub