它再次成爲我們的老朋友..... 我收到這個錯誤,我不知道爲什麼。我已經檢查過要傳遞的參數的數量以及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")})
哪條線發生錯誤?此外,刪除所有不必要的代碼,只發布相關的代碼(但如果可能使其完成)。 – 2012-02-09 13:55:46
@Konrad Rudolph Me.SqlDataAdapter1.Fill(DataSet11,「design_sp_search_drawing」) – 2012-02-09 13:58:36
它很有趣,當我右鍵單擊數據適配器並預覽數據結果正在返回。 – 2012-02-09 14:01:31