📄 conn.asp
字号:
<%@ LANGUAGE = VBScript CodePage = 936%>
<%Server.ScriptTimeOut=5000%>
<%
'定义基本变量常量
Session.Timeout=120
Response.Buffer = True
Dim db,SqlNowString,Conn,Rs
Const IsSqlDataBase = 0 '定义数据库类别,1为SQL数据库,0为Access数据库
'数据库链接过程
Sub ConnectionDatabase
Dim ConnStr
If IsSqlDataBase = 1 Then
'sql数据库连接参数:数据库名、用户密码、用户名、连接名(本地用local,外地用IP)
Dim SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName
SqlDatabaseName = "IFS"
SqlPassword = ""
SqlUsername = "IFS"
SqlLocalName = "(local)"
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Else
'Access数排据库路径
Db = "../db/#data.asp"
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(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 "The Sever Is Busy,Please try again..."
Response.End
End If
End Sub
'建立数据源函数
Function GrateRs(SqlStr,wr)
dim Rs
Set Rs=Server.CreateObject("ADODB.Recordset")
Rs.Open SqlStr, Conn, 1, wr
set GrateRs=Rs
End Function
'防SQL注入函数
Function YeSqlStr(data,falgs)
select case falgs
case "1" '数值型
data= data
if not isNumeric (data) then data=0
case "2" '字符型
data = Replace (data, "'", "''" )
case else '字符串
data = Trim(Replace(data, "&", "&"))
data = replace(data, "<", "<")
data = replace(data, ">", ">")
data = replace(data, "'", """")
data = replace(data, "*", "")
data = replace(data, "?", "")
data = replace(data, "select", "")
data = replace(data, "insert", "")
data = replace(data, "delete", "")
data = replace(data, "update", "")
data = replace(data, "delete", "")
data = replace(data, "create", "")
data = replace(data, "drop", "")
data = replace(data, "declare", "")
data = replace(data, vbCrLf&vbCrlf, "</p><p>")
data = replace(data, vbCrLf, "<br>")
end select
YeSqlStr= data
End Function
'关闭数据源
Sub DBConnEnd()
On Error Resume Next
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
End Sub
response.write "<!--258sp商务平台 Design By IFStudio-->"
response.write "<!--http://www.258sp.com-->"
response.write "<!--http://www.258sp.com-->"
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -