Its our old friend again…..
I am recieving this error and i cant think why. I have checked the number of parameters being passed as well as the number of required paramaters from the sp ,regenerating the data set has given me no look. I must have missed something basic. Another pair of eyes would be helpfull.
Thank you in advance
Public Sub GetRows(ByVal [Option] As String, ByVal searchString As String)
Me.DataSet11.Clear()
SqlSelectCommand1.CommandType = CommandType.StoredProcedure
SqlSelectCommand1.Parameters.AddWithValue("@Option", [Option])
SqlSelectCommand1.Parameters.AddWithValue("@searchString", searchString.ToUpper)
Try
SqlConnection1.Open()
'execute reader
'rdr = SqlSelectCommand1.ExecuteReader
Me.DataGridViewAvItems.DataSource = DataSet11.design_sp_search_drawings
Me.SqlDataAdapter1.Fill(DataSet11, "design_sp_search_drawing")
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
'close the conenction
SqlConnection1.Close()
End Try
End Sub
///DESIGNER CODE
Me.SqlSelectCommand1.CommandText = "dbo.design_sp_search_drawings"
Me.SqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
Me.SqlSelectCommand1.Parameters.AddRange(New System.Data.SqlClient.SqlParameter() {New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing), New System.Data.SqlClient.SqlParameter("@searchString", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, "TES0201"), New System.Data.SqlClient.SqlParameter("@Option", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, "site_code")})
Aren’t you adding the Option and SearchString parameters more than once? In the designer code you showed at the bottom, you add the parameters @RETURN_VALUE, @searchString, and @Option with the call to AddRange and you are adding them again at the top of the code when you call AddWithValue for each one of them. So to me it looks as if you have added 5 parameters. Am I missing something? What does the sproc require?