Nov
1
<%Dim StartTime,SQLQueryNums,opensql,errmsg
StartTime=Timer()
SQLQueryNums=0
opensql=1
errmsg="<head><meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" /><title>数据库连接出错,请检查连接字串</title></head><body><div align=""center"" style=""width:400px;height:100px;padding: 8px;font-size:9pt;border: 1px solid ThreeDShadow;POSITION:absolute;top:expression((document.body.offsetHeight-100)/2);left:expression((document.body.offsetWidth-400)/2);"" valign=""top""><table width=""100%"" height=""100%"" style=""font-size:12px;font-family:Tahoma;"" valign=""top""><tr><td align=""center"" valign=""top""><strong>数据库连接出错,请检查连接字串</strong></td></tr></table></div></body>"
'定义数据库链接文件,根据自己的情况修改
Const AccessPath="1212"
Const AccessFile="#1212.mdb"
'定义数据库连接
if opensql=0 then
Dim Conn
On Error Resume Next
Set Conn= Server.CreateObject("ADODB.Connection")
Conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(AccessPath&"/"&AccessFile)
Conn.Open
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write(""&errmsg&"")
Response.End
End If
else'sql数据库连接参数
Dim SqlDatabaseName,SqlPassword,SqlUsername,SqlSource,Driver
SqlDatabaseName = "21321" '数据库名
SqlUsername = "sa" '用户名
SqlPassword = "admfin" '用户密码
SqlSource = "(local)" '数据地址(本地用local,远程用IP)
Driver = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlSource & ";"
On Error Resume Next
set Conn = server.CreateObject("ADODB.Connection")
Conn.open Driver
If Err Then
err.Clear
Set Conn = Nothing
Response.Write(""&errmsg&"")
Response.End
End If
end if%>
StartTime=Timer()
SQLQueryNums=0
opensql=1
errmsg="<head><meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" /><title>数据库连接出错,请检查连接字串</title></head><body><div align=""center"" style=""width:400px;height:100px;padding: 8px;font-size:9pt;border: 1px solid ThreeDShadow;POSITION:absolute;top:expression((document.body.offsetHeight-100)/2);left:expression((document.body.offsetWidth-400)/2);"" valign=""top""><table width=""100%"" height=""100%"" style=""font-size:12px;font-family:Tahoma;"" valign=""top""><tr><td align=""center"" valign=""top""><strong>数据库连接出错,请检查连接字串</strong></td></tr></table></div></body>"
'定义数据库链接文件,根据自己的情况修改
Const AccessPath="1212"
Const AccessFile="#1212.mdb"
'定义数据库连接
if opensql=0 then
Dim Conn
On Error Resume Next
Set Conn= Server.CreateObject("ADODB.Connection")
Conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(AccessPath&"/"&AccessFile)
Conn.Open
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write(""&errmsg&"")
Response.End
End If
else'sql数据库连接参数
Dim SqlDatabaseName,SqlPassword,SqlUsername,SqlSource,Driver
SqlDatabaseName = "21321" '数据库名
SqlUsername = "sa" '用户名
SqlPassword = "admfin" '用户密码
SqlSource = "(local)" '数据地址(本地用local,远程用IP)
Driver = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlSource & ";"
On Error Resume Next
set Conn = server.CreateObject("ADODB.Connection")
Conn.open Driver
If Err Then
err.Clear
Set Conn = Nothing
Response.Write(""&errmsg&"")
Response.End
End If
end if%>