I have an sql stored procedure that gives an error when executed in Management Studio

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmaxsides
    New Member
    • Sep 2010
    • 3

    #1

    I have an sql stored procedure that gives an error when executed in Management Studio

    @ContractStateC ode, @ContactZipCode @BillingStateCo de, @BillingZipCode show "not a parameter for procedure SelectDonorXiD" .
    The Results show the selected data but the parameters are all null.

    My C# ocde -
    Code:
     DataView dvSql = (DataView)sdsEditDonor.Select(DataSourceSelectArguments.Empty);
    gives - "String[1]: the Size property has an invalid size of 0."

    I understand that something is wrong with my stored procedure but for the life of me I cannot see what.

    Please help?
    Code:
    Table ------
    USE [char68003f]
    GO
    /****** Object:  Table [dbo].[GFA_Donors]    Script Date: 09/01/2010 19:44:37 ******/
    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GFA_Donors]') AND type in (N'U'))
    DROP TABLE [dbo].[GFA_Donors]
    GO
    USE [char68003f]
    GO
    
    /****** Object:  Table [dbo].[GFA_Donors]    Script Date: 09/01/2010 19:44:38 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[GFA_Donors](
    	[DonorID] [int] IDENTITY(1,1) NOT NULL,
    	[ContactTitle] [varchar](7) NULL,
    	[ContactFirstName] [varchar](40) NULL,
    	[ContactLastName] [varchar](40) NULL,
    	[ContactAddress1] [varchar](40) NULL,
    	[ContactAddress2] [varchar](40) NULL,
    	[ContactCity] [varchar](30) NULL,
    	[ContactStateCode] [varchar](2) NULL,
    	[ContactZipCode] [varchar](10) NULL,
    	[ContactPhone] [varchar](30) NULL,
    	[ContactEmail] [varchar](80) NULL,
    	[BillingTitle] [varchar](7) NULL,
    	[BillingFirstName] [varchar](40) NULL,
    	[BillingLastName] [varchar](40) NULL,
    	[BillingAddress1] [varchar](40) NULL,
    	[BillingAddress2] [varchar](40) NULL,
    	[BillingCity] [varchar](30) NULL,
    	[BillingStateCode] [varchar](2) NULL,
    	[BillingZipCode] [varchar](10) NULL,
    	[BillingPhone] [varchar](30) NULL,
    	[BillingEmail] [varchar](80) NULL,
    	[BillStartDate] [smalldatetime] NOT NULL,
    	[CCExpire] [varchar](7) NOT NULL,
    	[CreditCardNo] [varchar](16) NOT NULL,
    	[DonationAmount] [money] NULL,
    	[DonationPreference] [varchar](10) NULL,
    	[PrivacyPreference] [varchar](20) NULL,
    	[DesignationCause] [varchar](50) NULL,
    	[GiftOrDedication] [varchar](50) NULL,
    	[SubscriptionID] [int] NULL,
    	[Comment] [varchar](255) NULL,
    	[BlockMailings] [bit] NULL,
    	[NewsLetter] [bit] NULL,
    	[DateAdded] [datetime] default getdate(),
    	[DateUpdated] [datetime] default getdate()
    ,
    	[anonymous] [bit] NULL,
    	[Active] [bit] NULL,
     CONSTRAINT [PK__persons__09DE7BCC] PRIMARY KEY CLUSTERED 
    (
    	[DonorID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    ALTER TABLE [dbo].[GFA_Donors] ADD  CONSTRAINT [DF_GFA_Donors_BillingStartDate]  DEFAULT (((7)/(13))/(1944)) FOR [BillStartDate]
    GO
    ALTER TABLE [dbo].[GFA_Donors] ADD  CONSTRAINT [DF_GFA_Donors_CCExipre]  DEFAULT ((7)/(1944)) FOR [CCExpire]
    GO
    ALTER TABLE [dbo].[GFA_Donors] ADD  CONSTRAINT [DF_GFA_Donors_CreditCardNo]  DEFAULT ('xxxxxxxxxxxx5555') FOR [CreditCardNo]
    GO
    ALTER TABLE [dbo].[GFA_Donors] ADD  CONSTRAINT [DF_GFA_Donors_Active]  DEFAULT ((1)) FOR [Active]
    GO
    
    Stored PROC---------------
    USE [char68003f]
    GO
    /****** Object:  StoredProcedure [dbo].[SelectDonorXiD]    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[SelectDonorXiD]
    	(
    	@DonorID varchar(50) ,
    	@ContactTitle varchar(7)=null OUTPUT,
    	@ContactFirstName varchar(40)=null OUTPUT,
    	@ContactLastName varchar(40)=null OUTPUT,
    	@ContactAddress1 varchar(40)=null OUTPUT,
    	@ContactAddress2 varchar(40)=null OUTPUT,
    	@ContactCity varchar(30)=null OUTPUT,
    	@ContactStateCode varchar(2)=null OUTPUT,
    	@ContactZipCode varchar(10)=null OUTPUT,
    	@ContactPhone varchar(30)=null OUTPUT,
    	@ContactEmail varchar(80)=null OUTPUT,
    	@BillingTitle varchar(7)=null OUTPUT,
    	@BillingFirstName varchar(40)=null OUTPUT,
    	@BillingLastName varchar(40)=null OUTPUT,
    	@BillingAddress1 varchar(40)=null OUTPUT,
    	@BillingAddress2 varchar(40)=null OUTPUT,
    	@BillingCity varchar(30)=null OUTPUT,
    	@BillingStateCode varchar(2)=null OUTPUT,
    	@BillingZipCode varchar(10)=null OUTPUT,
    	@BillingPhone varchar(30)=null OUTPUT,
    	@BillingEmail varchar(80)=null OUTPUT
    	)
    AS
    	Select ContactTitle, ContactFirstName, ContactLastName, ContactAddress1, ContactAddress2, ContactCity, ContactStateCode, ContactEmail, ContactPhone, ContactZipCode,BillingTitle,BillingFirstName,BillingLastName, BillingAddress1, BillingAddress2,BillingCity,BillingStateCode, BillingEmail, BillingPhone, BillingZipCode
    		From GFA_Donors Where @DonorID = DonorID
    	RETURN
    Last edited by Frinavale; Sep 3 '10, 03:25 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • Jerry Winston
    Recognized Expert New Member
    • Jun 2008
    • 145

    #2
    When are you getting the error?

    Comment

    • jmaxsides
      New Member
      • Sep 2010
      • 3

      #3
      I have an sql stored procedure that gives an error when executed in Management Studio

      "String[1]: the Size property has an invalid size of 0."
      takes place on DataView dvSql = (DataView)sdsEd itDonor.Select( DataSourceSelec tArgu ments.Empty);

      I went to SQL Management Studio to see if the stored procedure would actually run. In Management Studio I execute the Stored Procedure and get - @ContractStateC ode, @ContactZipCode @BillingStateCo de, @BillingZipCode show "not a parameter for procedure SelectDonorXiD" .

      If I can get by the error in Management Studio I think the C# code will work.

      Thanks..

      Comment

      • Jerry Winston
        Recognized Expert New Member
        • Jun 2008
        • 145

        #4
        I don't know if this is a typo here or in your executing code, but I think you've mislabled a field somewhere in your code.

        Code:
        @Cont[B][U]r[/U][/B]actStateCode
        is not a valid parameter. however
        Code:
        @ContactStateCode
        is a parameter.

        Comment

        • jmaxsides
          New Member
          • Sep 2010
          • 3

          #5
          resolved

          Resolved but not full understood. I had to give the parameters for the SQLDataSource a lenght attribute? ie @contactstateco de(2)...

          Comment

          • mzmishra
            Recognized Expert Contributor
            • Aug 2007
            • 390

            #6
            I think the problem was with your output paramter. you may be setting different datatype to your input parameter in code and storedprocedure .

            Comment

            Working...