在经典的asp

时间:2015-04-28 05:48:34

标签: vbscript asp-classic

为了使其参数化,我使用了命令对象,以便在进行参数化后保护不被注入,它无法连接到DB。 我不确定它出了什么问题。

错误:关闭对象时不允许操作。

有人可以帮我解决这个问题吗?

Set dbConn = Server.CreateObject("ADODB.Connection")
set RS = server.CreateObject("ADODB.recordset")
dbConn.Open Application("SOP_DB_ConnectionString"), _
Application("SOP_DB_RuntimeUserName"), _
Application("SOP_DB_RuntimePassword")


Set cmdSQL= server.CreateObject("ADODB.command")



sqlStmt = "select * from Parameters where Parameter like ?"

cmdSQL.Activeconnection = dbConn
cmdSQL.CommandText = sqlStmt
cmdSQL.CommandType = adCmdText
cmdSQL.Prepared = True ' only needed if u plan to reuse this command often
cmdSQL.Parameters.Refresh 

strSearch = "%conn%"
Set prmSQL = cmdSQL.CreateParameter("strVal" , adVarChar, adParamInput,     255,strSearch)
cmdSQL.Parameters.Append prmSQL



RS.CursorType = 3' adOpenStatic 


RS.Open cmdSQL,dbConn


 if RS.BOF and RS.EOF then ' if no connection found -->GETTING ERROR HERE
 session("ErrorTitle")="the initializing process"   
 session("ErrorText")="Connection failed- Couldn't read SOP parameters from database"
   Response.Redirect "Error.asp"
   else ' found record  
   RS.MoveFirst
   Do while not RS.EOF
   session(trim(RS.Fields("Parameter").value)) =       Trim(RS.Fields("Val").value)
   RS.MoveNext
  Loop  
  end if 
   Rs.close

0 个答案:

没有答案