无奈啊....
强大的数据库连接 conn.asp <% Option Explicit Response.Buffer = True dim startime dim isSQL dim conn dim connstr isSQL=0 '(1为SQL数据库,0为Access数据库)注意修改这里 dim mydbpath,db MyDbPath = "database/" '数据库路径 Startime = Timer() sub open_database if not isobject(conn) then Set conn = Server.CreateObject("ADODB.Connection") if issql=1 then '----------------------------使用SQL数据库------------------- 'sql数据库连接参数:数据库名(SqlDatabaseName)、用户密码(SqlPassword)、用户名(SqlUsername)、 '连接名(SqlLocalName)(本地用local,外地用IP) Const SqlDatabaseName = "数据库名" Const SqlPassword = "用户密码" Const SqlUsername = "用户名" Const SqlLocalName = "连接名" ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";" '----------------------------使用Access--------------------- else db="actdata.mdb" ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath & db) end if '------------------------------------------------------------ On Error Resume Next Set conn = Server.CreateObject("ADODB.Connection") conn.open ConnStr If Err Then err.Clear Set Conn = Nothing Response.Write "数据库连接出错,请检查连接字串。" Response.End End If else exit sub end if end sub
'关闭数据库 sub close_database conn.close set conn=nothing end sub
'显示执行时间 function webtimes() response.Write ("<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align=center><font onmouseover=this.color='red' onmouseout=this.color='#000000'>页面执行时间为:") response.Write((closetime-starttime)*1000) response.Write("ms</font></td><tr></table>") end function %>
加红色地方,是response.clear 还是err.clear啊?我在别的地方看到是前者的,能给出解释吗?