ASP中的select from后的表名可否换成变量

来源:百度知道 编辑:UC知道 时间:2024/06/06 19:36:10
请教各位大侠,如果在ASP中编写一个用变量名做表名的语句,
例如:
ABC = "表名"
Set rs = server.CreateObject("ADODB.Recordset")
rs.open "select * from ABC where id = ID ",conn,2,3
我用的是ACCESS数据库,应该怎么写法,望高手出招,帮帮小弟,先谢谢了.

rs.open "select * from " & ABC & " where id = ID ",conn,2,3

但id应该是数字型,所以,id=ID会有问题,一般来说,程序会传ID值进去,

这样的话就应该这样写:

rs.open "select * from "& ABC &" where id = " & cstr(ID),conn,2,3

太久没出现这个问题了
好像是把ABC写成
rs.open "select * from "&abc&" where id = ID ",conn,2,3