<%
'定义全局变量
Dim conn,rs,dbfile'错误处理
'on error resume next'打开数据库连接
Function opendb(querystr,rsmode)
dbfile = "guahao.mdb"
dbfolder = "database/"
dbpath = server.MapPath(dbfolder & dbfile)
set fso = server.createObject("scripting.filesystemobject")
if not fso.fileExists(dbpath) then dbpath = server.mappath("../") & "\" & dbfolder & dbfile
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath
set fso = nothing
set conn = Server.CreateObject("ADODB.CONNECTION")
conn.open connstr
If not querystr = "" then
set rs = Server.CreateObject("ADODB.Recordset")
Select case rsmode
case "1" rs.open querystr,conn,1,1
case "2" rs.open querystr,conn,2,2
case "3" rs.open querystr,conn,1,3
case else rs.open querystr,conn,1,1
End Select
End If
End Function'关闭数据库连接
Function closedb()
if vartype(rs)=0 then
rs.close
set rs=nothing
end if
conn.close
set conn=nothing
End Function'消息控制函数
sub mymsgbox(msgstring)
msgstring=cstr(msgstring)
response.write "<script language=""JavaScript"">alert ('"&msgstring&"');</script>"
end subsub mybackmsgbox(msgstring)
msgstring=cstr(msgstring)
response.write "<script language=""JavaScript"">alert ('"&msgstring&"');history.back();</script>"
end subsub mygoto(urlstring)
urlstring=cstr(urlstring)
response.write "<script language=""JavaScript"">window.location = '"&urlstring&"';</script>"
end sub
%>
改了好多个,都不能连接sql正常,立刻加分!!!
'定义全局变量
Dim conn,rs,dbfile'错误处理
'on error resume next'打开数据库连接
Function opendb(querystr,rsmode)
dbfile = "guahao.mdb"
dbfolder = "database/"
dbpath = server.MapPath(dbfolder & dbfile)
set fso = server.createObject("scripting.filesystemobject")
if not fso.fileExists(dbpath) then dbpath = server.mappath("../") & "\" & dbfolder & dbfile
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath
set fso = nothing
set conn = Server.CreateObject("ADODB.CONNECTION")
conn.open connstr
If not querystr = "" then
set rs = Server.CreateObject("ADODB.Recordset")
Select case rsmode
case "1" rs.open querystr,conn,1,1
case "2" rs.open querystr,conn,2,2
case "3" rs.open querystr,conn,1,3
case else rs.open querystr,conn,1,1
End Select
End If
End Function'关闭数据库连接
Function closedb()
if vartype(rs)=0 then
rs.close
set rs=nothing
end if
conn.close
set conn=nothing
End Function'消息控制函数
sub mymsgbox(msgstring)
msgstring=cstr(msgstring)
response.write "<script language=""JavaScript"">alert ('"&msgstring&"');</script>"
end subsub mybackmsgbox(msgstring)
msgstring=cstr(msgstring)
response.write "<script language=""JavaScript"">alert ('"&msgstring&"');history.back();</script>"
end subsub mygoto(urlstring)
urlstring=cstr(urlstring)
response.write "<script language=""JavaScript"">window.location = '"&urlstring&"';</script>"
end sub
%>
改了好多个,都不能连接sql正常,立刻加分!!!
'定义全局变量
Dim conn,rs,dbfile'错误处理
'on error resume next'打开数据库连接
Function opendb(querystr,rsmode)strSQLServerName = "服务器名或ip" 'server
strSQLDBUserName = "sql登陆的用户名" 'username
strSQLDBPassword = "密码" 'password
strSQLDBName = "数据库名" 'Database name connstr = "Provider=SQLOLEDB.1;Persist Security Info=False;Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
set conn = Server.CreateObject("ADODB.CONNECTION")
conn.open connstr
If not querystr = "" then
set rs = Server.CreateObject("ADODB.Recordset")
Select case rsmode
case "1" rs.open querystr,conn,1,1
case "2" rs.open querystr,conn,2,2
case "3" rs.open querystr,conn,1,3
case else rs.open querystr,conn,1,1
End Select
End If
End Function'关闭数据库连接
Function closedb()
if vartype(rs)=0 then
rs.close
set rs=nothing
end if
conn.close
set conn=nothing
End Function'消息控制函数
sub mymsgbox(msgstring)
msgstring=cstr(msgstring)
response.write "<script language=""JavaScript"">alert ('"&msgstring&"');</script>"
end subsub mybackmsgbox(msgstring)
msgstring=cstr(msgstring)
response.write "<script language=""JavaScript"">alert ('"&msgstring&"');history.back();</script>"
end subsub mygoto(urlstring)
urlstring=cstr(urlstring)
response.write "<script language=""JavaScript"">window.location = '"&urlstring&"';</script>"
end sub
%>