我遇到了嘗試執行存儲過程的錯誤。使用存儲過程搜索數據
我有一個SQL Server數據庫,存儲過程是這樣的:
在VB我有數據層和代碼如下所示:
Friend Function Search_Licenses_By_Number(ByRef cmd As SqlCommand, ByRef dr As SqlDataReader, ByVal LicenseNumber As Integer)
Dim retval As Integer
cmd = New SqlCommand("Search_Licenses_By_Number")
cmd.Parameters.Add("@LicenseNumber", LicenseNumber, SqlDbType.Int)
cmd.Parameters.Add("@CentralRegistryNumber", SqlDbType.Int)
cmd.Parameters.Add("@LicenseNameArabic", SqlDbType.NVarChar)
cmd.Parameters.Add("@LicenseNameEnglish", SqlDbType.NVarChar)
cmd.Parameters.Add("@LegalForm", SqlDbType.NVarChar)
cmd.Parameters.Add("@ExpiryDate", SqlDbType.Date)
cmd.Parameters.Add("@LicenseOwner", SqlDbType.NVarChar)
cmd.Parameters.Add("@LicenseOwnerNationality", SqlDbType.NVarChar)
cmd.Parameters.Add("@LicenseType", SqlDbType.NVarChar)
cmd.Parameters.Add("@LicenseActivities", SqlDbType.NVarChar)
cmd.Parameters.Add("@LicenseAddress", SqlDbType.NVarChar)
cmd.Parameters.Add("@Phone", SqlDbType.NVarChar)
cmd.Parameters.Add("@Fax", SqlDbType.NVarChar)
cmd.Parameters.Add("@Email", SqlDbType.NVarChar)
cmd.Parameters.Add("@LicenseStatus", SqlDbType.NVarChar)
retval = dm.executeReader(cmd, dr)
Return retval
End Function
而且我也有一個商業層和代碼如下所示:
Public Function Search_Licenses_By_Number(ByVal LicenseNumber As Integer) As Integer
p.Search_Licenses_By_Number(cmd, dr, LicenseNumber)
Return p.Search_Licenses_By_Number(cmd, dr, LicenseNumber)
End Function
我有一個包含14個文本框和1個日期時間選擇器的形式d 1按鈕
我想什麼是當按下搜索按鈕,它顯示在TextBox1中進入
按鈕的代碼,像這樣的文本框取決於LicenseNumber記錄:
Dim retval As Integer = p.Search_Licenses_By_Number(txtLicensesNumber.Text)
txtLicensesNumber.Text = p.Search_Licenses_By_Number("LicenseNumber")
CentralRegistryNumber.Text = p.Search_Licenses_By_Number("CentralRegistryNumber")
txtLicensesNameArabic.Text = p.Search_Licenses_By_Number("LicenseNameArabic")
txtLicensesNameEnglish.Text = p.Search_Licenses_By_Number("LicenseNameEnglish")
LegalForm.Text = p.Search_Licenses_By_Number("LegalForm")
ExpiryDate.Value = p.Search_Licenses_By_Number("ExpiryDate").ToString
LicenseOwner.Text = p.Search_Licenses_By_Number("LicenseOwner")
LicenseOwnerNationality.Text = p.Search_Licenses_By_Number("LicenseOwnerNationality")
txtLicensesType.Text = p.Search_Licenses_By_Number("LicenseType")
LicenseActivities.Text = p.Search_Licenses_By_Number("LicenseActivities")
txtLicensesAddress.Text = p.Search_Licenses_By_Number("LicenseAddress")
LicensePhone.Text = p.Search_Licenses_By_Number("Phone")
LicenseFax.Text = p.Search_Licenses_By_Number("Fax")
LicenseEmail.Text = p.Search_Licenses_By_Number("Email")
LicStatus.Text = p.Search_Licenses_By_Number("LicenseStatus")
我的錯誤得到的是
過程Search_Licenses_By_Number沒有參數並提供參數。
親切的問候 塞勒姆
謝謝你,但我得到了另一個錯誤過程或函數「Search_Licenses_By_Number」需要參數「@CentralRegistryNumber」,但未提供。我想把文本框中的LicenseNumber,它返回給我所有我想要的數據CentralRegistryNumber,LicenseNameArabic,'LicenseNameEnglish,LegalForm,ExpiryDate,LicenseOwner,LicenseOwnerNationality,LicenseType,LicenseActivities,LicenseAddress,Phone,Fax,Em'ail,LicenseStatus – Salem
分號是第一個和第二個參數之間缺失。檢查更新代碼 –
謝謝阿里,但仍然相同 – Salem