我们的老朋友了...... 我收到这个错误,我不知道为什么。我已经检查了传递的参数数量以及sp中所需参数的数量,重新生成数据集给了我一些看法。我一定错过了一些基本的东西。另一双眼睛会有所帮助。
提前谢谢
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
///设计师代码
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")})
答案 0 :(得分:2)
您是不是多次添加Option和SearchString参数?在底部显示的设计器代码中,通过调用AddRange添加参数@RETURN_VALUE,@ searchString和@Option,当您为每个参数调用AddWithValue时,您将在代码顶部再次添加它们。所以对我来说,看起来好像你已经添加了5个参数。我错过了什么吗? sproc需要什么?