"Procedure or function expects parameter '@UserId', which was not supplied.

  • Thread starter Thread starter GoneToTheDogs
  • Start date Start date
G

GoneToTheDogs

Guest
I'm getting the following error:

"Procedure or function 'uspLogin_UpdateUserOver96Dpi' expects parameter '@UserId', which was not supplied."

As you can see from the image below, the @UserId is supplied.

I've tried SELECT calls against the same SQL table and they work. So, I'm questioning the error message. Does anyone see anything that might throw this error? Could it be that I don't have update access via Stored Proc to the database? This is the first time I performed an update to this SQL Server and database. (we are converting from an ancient DB called, "Unidata" to MS SQL)



Calling Routine Code:

Dim SqlConnString As String = "<connection string info here>"
Dim SqlProcName As String = "[Hu].[uspLogin_UpdateUserOver96Dpi]"
Dim sqlParams As New Microsoft.VisualBasic.Collection
Dim SqlUpdater As New HubertClassLibraryIO.SQLClass(SqlConnString)

Dim UsernameParam As New SqlParameter("@UserId", SqlDbType.NVarChar)
Dim ComputernameParam As New SqlParameter("@Computername", SqlDbType.NVarChar)
Dim IssueKeyParam As New SqlParameter("@IssueKey", SqlDbType.Int)
Dim DisableWarningParam As New SqlParameter("@DisableWarnings", SqlDbType.Bit)

UsernameParam.Value = Environment.UserName
ComputernameParam.Value = Environment.MachineName
IssueKeyParam.Value = 1
DisableWarningParam.Value = 0

sqlParams.Add(UsernameParam)
sqlParams.Add(ComputernameParam)
sqlParams.Add(IssueKeyParam)
sqlParams.Add(DisableWarningParam)

If Not SqlUpdater.NonQuery(SqlProcName, sqlParams) Then
MsgBox("Update failed")
End If

Public Function NonQuery(ByVal sql As String, Optional ByVal params As Collection = Nothing) As Boolean
Dim sqlCommand As New SqlCommand(sql, Me.conn)
If Me.tran IsNot Nothing Then
sqlCommand.Transaction = Me.tran
End If

If params IsNot Nothing Then
For Each par As SqlParameter In params
sqlCommand.Parameters.Add(par)
Next
End If

Try
Me.sqlError = ""
sqlCommand.ExecuteNonQuery()
Catch ex As Exception
Me.sqlError = ex.Message
Return False
End Try
Return True
End Function

Stored Procedure

PROCEDURE [Hu].[uspLogin_UpdateUserOver96Dpi]

@UserId Varchar(50),
@Computername Varchar(60),
@IssueKey Int,
@DisableWarnings Bit

AS
BEGIN

MERGE Hu.UserIssue WITH (SERIALIZABLE) AS T
USING (VALUES(@UserId, @Computername, @IssueKey, @DisableWarnings)) AS UI (UserId, Computername, IssueId, DisableWarnings)
ON UI.UserId = T.UserId
WHEN MATCHED THEN
UPDATE SET UserId = @UserId,
Computername = @Computername,
IssueId = @issueKey,
Timestamp = GETDATE(),
DisableWarnings = @DisableWarnings
WHEN NOT MATCHED THEN
INSERT (UserId, Computername, IssueId, DisableWarnings)
VALUES (@UserId, @Computername, @IssueKey, @DisableWarnings);





1415226.png


~GoneToTheDogs

Continue reading...
 
Back
Top