ASP 参数化查询如何实现SQL语句 带 IN(变量1,变量2,变量3,.......)查询

fdc_28 fdc_28 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
fdc_28
ASP 28,401 成员 356,940 内容