Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2005, 06:53 AM
Registered User
 
Join Date: Apr 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to umertahir
Default ASP.Net: Stored Procedures and DataGrid

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



 
Old April 18th, 2005, 08:27 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Everything looks ok except that in the sproc you are declaring the first argument as a Char while the code adds it as a Varchar. I wouldn't think this should result in the error you are seeing, but it's worth looking into.

-Peter
 
Old April 18th, 2005, 08:42 AM
Registered User
 
Join Date: Apr 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to umertahir
Default

Peter i did try it that way before but no vain.i am still struggling to fix it....

 
Old April 19th, 2005, 03:28 AM
Registered User
 
Join Date: Apr 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to umertahir
Default

ok i figured out the problem.
Solution:
If the Command Parameters are shifted from 'Sub Page Init' to the function where button click will call them then there won't be any of this error.






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Stored Procedures kwilliams ASP.NET 2.0 Basics 1 March 16th, 2006 11:56 PM
asp and ms sql stored procedures solomon_13000 Classic ASP Basics 1 July 11th, 2005 12:04 AM
CR.Net and Stored Procedures eman2a Crystal Reports 1 September 2nd, 2004 11:32 PM
trigger stored procedures from asp Kornel Classic ASP Databases 7 July 15th, 2004 10:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.