My stored procedure is very simple. It inserts a new record. At the end of it I have the following line:
我的存储过程非常简单。它会插入一条新记录。最后我有以下几行:
SELECT SCOPE_IDENTITY()
1) Am I using the right code to return the Primary Key value for the newly inserted record?
2) How do I retrieve this value using ASP Classic/VBScript with ADO Classic?
1)我是否使用正确的代码返回新插入记录的主键值? 2)如何使用带有ADO Classic的ASP Classic / VBScript检索此值?
Dim cmdUA
Set cmdUA = Server.CreateObject("ADODB.Command")
Set cmdUA.ActiveConnection = tcon
cmdUA.CommandText = "InsertUserAgent"
cmdUA.CommandType = adCmdStoredProc
cmdUA.Parameters.Append cmdUA.CreateParameter("useragent", adVarWChar, _
adParamInput, 1000)
cmdUA("useragent") = Request.ServerVariables("HTTP_USER_AGENT")
cmdUA.Exec
'Here I need to get the value returned from the stored procedure
Set cmdUA.ActiveConnection = Nothing
Set cmdUA = Nothing
1 个解决方案
#1
4
The Execute method (NOT Exec) returns a record set which contains the result from the stored procedure.
Execute方法(NOT Exec)返回包含存储过程结果的记录集。
Set rs = cmdUA.Execute
result = rs.Fields(0).Value
#1
4
The Execute method (NOT Exec) returns a record set which contains the result from the stored procedure.
Execute方法(NOT Exec)返回包含存储过程结果的记录集。
Set rs = cmdUA.Execute
result = rs.Fields(0).Value