Stored Procedures in .net

  • I have written Stored Procedure TourCount which take tourID as input.

    I have written the following code

    ---------------------------------------------------

    Dim con As New SqlConnection("DataSource path")

    Dim cmd As New SqlCommand()

    Dim da As New SqlDataAdapter(cmd)

    Dim ds As New DataSet

    cmd.Connection = con

    cmd.CommandType = CommandType.StoredProcedure

    cmd.Parameters.AddWithValue("@TourID", 16)

    cmd.CommandText = "TourCount"

    da.Fill(ds, "Table")

    GridControl1.DataSource = ds.Tables(0)

    -----------------------------------------------------

    but giving an error

    Procedure or Function 'TourCount' expects parameter '@Tour', which was not supplied.

    How to solve this

  • It looks like you actually named the parameter in the stored procedure @tour instead of @TourID. Either change the stored procedure to use @TourID or change the .NET code to use @Tour.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply