asp参数化查询读取写入修改删除完整版

asp参数化查询读取写入修改删除完整版

Function SqlHelper(sqlstr,para)
Dim cmd
Set cmd = Server.CreateObject( "ADODB.Command" )
queryType = 0
If Not IsArray(para) Then
If para<>"" Then
para = Array(para)
End If
End If
If Instr(Lcase(Left(sqlstr, 7)),"select ")>0 Then queryType = 1
With cmd
.ActiveConnection = Conn
.CommandType = adCmdText
.CommandText = sqlstr
.Prepared = True
If queryType = 1 Then
conn.CursorLocation = 3 '游标服务位置为client时才能返回正确的RecordCount
End If
If IsArray(para) Then
nnn = Ubound(para)
For iii = 0 To nnn
.Parameters(iii).value = Para(iii)
Next
End If
If queryType = 1 Then
Set SqlHelper = .Execute
Else
.Execute affectedRows, , 129
SqlHelper = affectedRows
End If
.ActiveConnection = Nothing
End With
Set Cmd = Nothing
End Function

=============================================

互相学习电话微信:18611436777(加微信注明事由)

posted @ 2018-10-10 12:04  和硕宝亲王  阅读(774)  评论(0)    收藏  举报