Hello All,
Objective:
To fill in 'DataGrid' by running SQL 'Stored Procedure' where parameters are passed by textbox and listboxes.
Error:
Procedure or function Test_Proc1 has too many arguments specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Procedure or function Test_HUK1 has too many arguments specified.
Stored Procedure:
CREATE PROCEDURE Test_Proc1
(
@************ char(1),
@HBN varchar(14),
@Breed varchar(14),
@SR_Code char(2),
@ID_type varchar(1)
)
As
/*Check if data exists in HUK or not
if Exists
(*/
Select Animal_Name, ************, HBN, SR_Code, DateOfBirth
From tmp_pedigree_HUK_Females_lookup a
Where HBN = @HBN
and Breed = @Breed
and SR_Code = @SR_Code
and ID_type = @ID_type
and MasterRecord='Y'
and HBN is not null
and OrigSource=(Select min(OrigSource)
From tmp_pedigree_HUK_Females_lookup b
where a.HBN=b.HBN
and a.Breed=b.breed
and a.id_type=b.id_type
and a.SR_Code=b.SR_Code
and b.MasterRecord='Y' )
/*Return Animal_Name, ************, HBN, SR_Code, DateOfBirth*/
GO
ASP.Net.
VB Code:
'm_************, m_Breed_Code, m_SR_Code, m_ID_Type are listboxes which pass the values
'm_HBN is textbox
dbTest = New System.Data.SqlClient.SqlConnection
SQLCommand1= New System.Data.SqlClient.SqlCommand
SQLCommand1.CommandText = "[dbo].[Test_Proc1]"
SQLCommand1.CommandType = StoredProcedure
SQLCommand1.Connection = dbTest
SQLCommand1.Parameters.Add(New SqlParameter("@************", VarChar, 1)).Value = m_************.SelectedValue
SQLCommand1.Parameters.Add(New SqlParameter("@HBN", VarChar, 14)).Value = m_HBN.Text
SQLCommand1.Parameters.Add(New SqlParameter("@Breed", VarChar, 14)).Value = m_Breed_Code.SelectedValue
SQLCommand1.Parameters.Add(New SqlParameter("@SR_Code", VarChar, 2)).Value = m_SR_Code.SelectedValue
SQLCommand1.Parameters.Add(New SqlParameter("@ID_type", VarChar, 1)).Value = m_ID_Type.SelectedValue
SQLCommand1.CommandType = CommandType.StoredProcedure
'To Search for animal called onClick of the Search Button
Public Sub Search_Herd(ByVal sender As Object, ByVal e As System.EventArgs)
Dim datareader1 As SqlDataReader
If m_************.SelectedValue = 1 Then
datareader1 = SQLCommand1.ExecuteReader()
Herd_List.DataSource = datareader1
Herd_List.DataBind()
datareader1.Close()
End If
dbTest.Close()
End Sub
My Point of View:
I have tried using DataSet instead of DataReader but it doesn't help. I am stuck in this error :( , someone kind enough would give me expert advice on this issue?
regards,
Umer