April 14, 2004 at 6:41 pm
The following VBA code (in Access 2002) calls a stored procedure procPhoneInsert but gets stuck on the .Execute line with the error code saying that there are too many or not enough parameters (can't even generate the error message at the moment). Any clues?
Public Function InsertPhoneRecord() As Long
Dim cmdNew As ADODB.Command
Dim cnn As ADODB.Connection
Dim strCnn As String
strCnn = "Provider=sqloledb;Data Source=Knox-Server;" & _
"Initial catalog=BData;User Id=**;Password=**;"
Set cnn = New ADODB.Connection
cnn.Open strCnn
Set cmdNew = New ADODB.Command
With cmdNew
Set .ActiveConnection = cnn
.CommandText = "procPhoneInsert"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("@EmpCreated", adVarChar, adParamInput, 10)
.Parameters("@EmpCreated").Value = GetUserName()
.Parameters.Append .CreateParameter("@NewPhoneID", adInteger, adParamOutput)
.Execute
InsertPhoneRecord = .Parameters("@NewPhoneID").Value
End With
cnn.Close
Set cnn = Nothing
End Function
SP:
CREATE PROCEDURE dbo.procPhoneInsert
@EmpCreated varchar(10),
@NewPhoneID int OUTPUT
AS
INSERT INTO phone (EmpCreated, EmpUpdated) VALUES (@EmpCreated, @EmpCreated)
SET @NewPhoneID=SCOPE_IDENTITY()
GO
April 14, 2004 at 7:09 pm
Nevermind. I figured out the problem is elsewhere. The code is working okay now. Thanks,
SMK
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply