ASP 参数化查询如何实现SQL语句 带 IN(变量1,变量2,变量3,.......)查询
CorpNum 是变量,当变量为 1 是好办,如果变量为 1,2,3,4,....时如何处理
Sql = "Select top 2 CorpID,RptYear,RptMonth,RptDate,RptYM,GetDate() From RptDate Where CorpID IN (?,?,?,.....) and RptYM <= ?"
SET cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = oConn
cmd.CommandType = 1
cmd.Prepared = true
cmd.CommandText = Sql
'''这个地方怎么处理
cmd.Parameters.Append(cmd.CreateParameter("@CorpID", 20, 1, 20, CorpNum))
cmd.Parameters.Append(cmd.CreateParameter("@RptYM", 20, 1, 20, RptYM))
SET Rs = cmd.Execute()
RptEndDate = FormatDateTime(Rs(3),2)
Do While Not Rs.Eof
Rs.movenext
RptBeginDate = FormatDateTime(DateAdd("d", 1, rs(3)),2)
Loop
Rs.Close() : Set Rs = Nothing : cmd.Close() : Set cmd= Nothing