parameter insert command throwing error RRS feed

  • Question




    VS 2005 & SQL 2005


    I am using a web service to update a sql server database. However, I keep getting the following error message on the da.update(dsChanges,Incidents) line. The error is:

    "Parameterized Query '(@status nvarchar(50))INSERT INTO Incident(Status) VALUES(@Statu' expects parameter @status, which was not supplied."


    As you can see from my code the status is supplied.


    In the database the status is a nvarchar(50) datatype. I have tried the very same code with other fields in the database, but out of all of them. Status is the only one it fails on.

    Can anyone tell me if there is something wrong with my code, as I have done everything possible in trying to fix this error.


    Many thanks in advance,



    Code Snippet

    'Update the central database and return the updated dataset
        Public Function SynchroniseChanges(ByVal dsChanges As DataSet) As String
            Dim da As New SqlDataAdapter()

                da.InsertCommand = New SqlCommand("INSERT INTO Incident(Status) VALUES(@Status)", cnn)
                da.InsertCommand.Parameters.Add("@status", SqlDbType.NVarChar, 50, "Status")
                da.Update(dsChanges, "Incidents")'Error happens

                Return dsChanges
            Catch ex As Exception
                Return ex.ToString()
            End Try
    End Function



    This is some alternative code I used for creating the parameter, but this failed with the same error message as well.

    Code Snippet
    Dim pStatus As New SqlParameter()
    pStatus.ParameterName = "@status"
    pStatus.SqlDbType = SqlDbType.NVarChar
    pStatus.Direction = ParameterDirection.Input
    pStatus.SourceColumn = "Status"



    Tuesday, September 18, 2007 3:17 AM


  • I didnt perfomed it. As per my guess
    1. u given parameter as @Status in add u mentiond as @status Plz check out
    2.dataset is there i think u have to create the instance of the dataset
     exds=new dataset

    Plz check out and post the message if u get any error. I will check out andi will try to solve the issue

    Thank u

    Please remember to click "Mark as Answer" on this post if it helped you.
    Tuesday, September 18, 2007 6:55 AM