【发布时间】:2017-11-29 17:25:54
【问题描述】:
我正在尝试从经典 ASP 应用程序调用存储过程,但出现 3709 错误。这是一个无法连接的...错误。
On Error Resume Next
set ConnectionStr = "driver=SQL Server;server=***;uid=***;pwd=***;database=***"
Set cmd = Server.CreateObject("ADODB.Command")
With cmd
Set .ActiveConnection = ConnectionStr
.CommandType = adCmdStoredProc
.CommandText = "storedprocedure"
'Input Parameters
.Parameters.Append .CreateParameter("@email", adVarchar, adParamInput, 50, Request.Form("email"))
.Parameters.Append .CreateParameter("@pass", adVarchar, adParamInput, 50, Request.Form("password"))
End With
set rs = Server.CreateObject("ADODB.RecordSet")
'rs.Open cmd.Execute
set rs = cmd.Execute 'Here is 3709 Error
If not rs.eof Then 'I get a 3704 Error here because of the 3709 error above
'Do Things with the RS
End If
Set cmd = Nothing
我的存储过程是:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[nameofprocedure]
@email nvarchar(50),
@pass nvarchar(50)
AS
BEGIN
SET NOCOUNT ON
SELECT is, fstname, lstname, [password]
FROM users
WHERE email = @email AND [password] = @pass;
RETURN
END
【问题讨论】:
-
您需要将
ConnectionStr设置为Connection 对象而不是字符串。 -
你的意思是当我设置活动连接时?
-
无论我是自己管理连接还是将字符串传递给 activeConnection,它都会引发相同的错误。 ADODB.Command 应该能够为我管理连接。我已经完成了:
set Conn = Server.CreateObject("ADODB.Connection")Conn.open ConnectionStr并将其传递给活动连接只是为了检查,同样的事情。
标签: stored-procedures vbscript asp-classic