快速示例:
set cmd = Server.CreateObject("ADODB.Command")
set rs = server.createObject("ADODB.RecordSet")
with cmd
.ActiveConnection = conn
.CommandText = "SELECT COUNT(*) as MyCount FROM corp_crcchallenge WHERE cc_email = @p1"
.createparameter("@p1",adVArChar,adParamInput,,email)
set rs = .Execute
end with
rtn = rs.fields("MyCount")
n = MyScalar("SELECT COUNT(*) FROM corp_crcchallenge WHERE cc_email = @p1","abc@def.com")
function MyScalar(sql, Param1)
set cmd = Server.CreateObject("ADODB.Command")
set rs = server.createObject("ADODB.RecordSet")
with cmd
.ActiveConnection = conn
.CommandText = sql
.createparameter("@p1",adVArChar,adParamInput,,Param1)
set rs = .Execute
end with
MyScalar = rs.fields(0)
end function