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(加微信註明事由)
asp參數化查詢讀取寫入修改刪除完整版