我有一段调用SQL Server存储过程的代码,但是我保留了错误#34;指定的参数太多"。
这是我的SQL Server存储过程:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[usp_update_consequenceweighting]
@ITID int
AS
BEGIN
DECLARE @CW AS INT
SELECT
@CW = Impact_Type_Weighting
FROM
tbl_ImpactType
WHERE
ImpactTypeID = @ITID
UPDATE
Tbl_Consequences
SET
Consequence_Weighting = @CW
WHERE
Impact_TypeID = @ITID
END
这是MS Access中调用存储过程的代码:
Private Sub Combo13_LostFocus()
Dim P1 As Integer
P1 = Forms![Frm_Ws10a]![Frm_WS10b]![Combo13].Column(0)
Dim rs As ADODB.Recordset
Dim CN As ADODB.Connection
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Dim adstring As Variant
Set CN = New ADODB.Connection
CN.ConnectionString = "Driver=SQL
Server;Server=LDXFBHD013492\SQLEXPRESS;Database=xxxx;Trusted_Connection=YES;"
CN.Open
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = CN
.CommandText = "dbo.usp_update_consequenceweighting"
.CommandType = adCmdStoredProc
.Parameters.Refresh
Set prm = .CreateParameter("@ITID", adVarChar, adParamInput, 50)
.Parameters.Append prm
prm.Value = P1
End With
Set rs = cmd.Execute
Me.Recalc
Me.Refresh
Set prm = Nothing
Set cmd = Nothing
End Sub
请帮忙。这用于与DAO一起工作,但后来我遇到了32位和64位驱动程序之间的冲突。