Passing parameters through form with stored procs in ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neenaprasad
    New Member
    • Jan 2008
    • 13

    Passing parameters through form with stored procs in ASP

    I am trying to pass parameters through form ............... .....

    Getting the following error.......... .

    ADODB.Command (0x800A0BB9)
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

    -------------------------------------------------------------------------------------------------------------

    The error is in line.......... CmdUpdate.Comma ndType = adCmdStoredProc

    ---------------------------------------- Here is my code ------------------------------------------

    Code:
    Dim Camp_Name
    Dim CmdUpdate
    
    Camp_Name = Request.Form("x_CampaignName1")
    
    Set CmdUpdate = Server.CreateObject("ADODB.Command") 
    CmdUpdate.ActiveConnection = conn
    CmdUpdate.CommandText = "SP_SMS"
    CmdUpdate.CommandType = adCmdStoredProc
    
    CmdUpdate.Parameters.Append CmdUpdate.CreateParameter("@Campaign_Name", adnvarchar, adParamInput,50,Camp_Name)
    CmdUpdate.Execute , , adExecuteNoRecords
    
    Set CmdUpdate = Nothing
    --------------------------------- Here is my Stored Procedure --------------------------------------

    Code:
    CREATE PROCEDURE [dbo].[SP_SMS]
    	
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    Declare @Campaign_Name nvarchar(50) 
    Declare @DateCreated datetime
     
    	INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES(@Campaign_Name,GETDATE())
    
    END

    Can you please help me
    Thnx in Advance
    Last edited by DrBunchman; Aug 19 '08, 06:44 AM. Reason: Added [Code] Tags - Please use the '#' button
  • neenaprasad
    New Member
    • Jan 2008
    • 13

    #2
    Passing parameters through form with stored procs in ASP

    I am trying to pass parameters through form ............... .....

    Getting the following error.......... .

    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure SP_SMS has no parameters and arguments were supplied.

    ---------------------- Here is my code ---------------------

    Code:
    Dim Camp_Name
    Dim CmdUpdate
    
    Camp_Name = Request.Form("x_CampaignName1")
    
    Set CmdUpdate = Server.CreateObject("ADODB.Command") 
    CmdUpdate.ActiveConnection = conn
    CmdUpdate.CommandText = "SP_SMS"
    CmdUpdate.CommandType = adCmdStoredProc
    
    CmdUpdate.Parameters.Append CmdUpdate.CreateParameter("@Campaign_Name", adnvarchar, adParamInput,50,Camp_Name)
    CmdUpdate.Execute , , adExecuteNoRecords
    
    Set CmdUpdate = Nothing
    ----------------- Here is my Stored Procedure --------------

    Code:
    CREATE PROCEDURE [dbo].[SP_SMS]
    
    AS
    BEGIN
    SET NOCOUNT ON;
    
    Declare @Campaign_Name nvarchar(50) 
    Declare @DateCreated datetime
    
    INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES(@Campaign_Name,GETDATE())
    
    END

    Can you please help me
    Thnx in Advance

    --------------------------------------------------------------------------------
    Last edited by DrBunchman; Aug 19 '08, 06:43 AM. Reason: Added [Code] Tags - Please use the '#' button

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      The error says that it recognizes the stored procedure, but it is not supposed to have any parameters. Are you sure you are supposed to add parameters?

      Jared

      Comment

      • neenaprasad
        New Member
        • Jan 2008
        • 13

        #4
        Originally posted by neenaprasad
        I am trying to pass parameters through form ............... .....

        Getting the following error.......... .

        Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
        [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure SP_SMS has no parameters and arguments were supplied.

        ---------------------- Here is my code ---------------------

        Code:
        Dim Camp_Name
        Dim CmdUpdate
        
        Camp_Name = Request.Form("x_CampaignName1")
        
        Set CmdUpdate = Server.CreateObject("ADODB.Command") 
        CmdUpdate.ActiveConnection = conn
        CmdUpdate.CommandText = "SP_SMS"
        CmdUpdate.CommandType = adCmdStoredProc
        
        CmdUpdate.Parameters.Append CmdUpdate.CreateParameter("@Campaign_Name", adnvarchar, adParamInput,50,Camp_Name)
        CmdUpdate.Execute , , adExecuteNoRecords
        
        Set CmdUpdate = Nothing
        ----------------- Here is my Stored Procedure --------------

        Code:
        CREATE PROCEDURE [dbo].[SP_SMS]
        
        AS
        BEGIN
        SET NOCOUNT ON;
        
        Declare @Campaign_Name nvarchar(50) 
        Declare @DateCreated datetime
        
        INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES(@Campaign_Name,GETDATE())
        
        END

        Can you please help me
        Thnx in Advance

        --------------------------------------------------------------------------------
        Can you tell me where to use the "#" button?

        Comment

        • jhardman
          Recognized Expert Specialist
          • Jan 2007
          • 3405

          #5
          Select all of your code and then click the '#' button directly above the text area where you are typing. This will format all of your code as you see above. Alternatively you may type '[' and then the word 'code' and then ']' to begin the code section, and end with '[/code]'. this is covered in the posting guidelines under "How to ask your question".

          Jared

          Comment

          • neenaprasad
            New Member
            • Jan 2008
            • 13

            #6
            Originally posted by jhardman
            The error says that it recognizes the stored procedure, but it is not supposed to have any parameters. Are you sure you are supposed to add parameters?

            Jared
            I am not sure about it............. .I am passing the parameter with SP for the first time........... ........But if we give SELECT @Campaign_Name = 'hello' before the insert stmt, when we call the SP that value will be updated in the database....... ..

            But I dont know how to pass values from ASP form..........

            CREATE PROCEDURE [dbo].[SP_SMS]

            AS
            BEGIN
            SET NOCOUNT ON;

            Declare @Campaign_Name nvarchar(50)
            Declare @DateCreated datetime

            SELECT @Campaign_Name = 'Hello'

            INSERT INTO SMSMain (Campaign_Name, DateCreated) VALUES(@Campaig n_Name,GETDATE( ))

            END

            Comment

            • krayman
              New Member
              • Aug 2008
              • 1

              #7
              The statement Declare @Campaign_Name nvarchar(50)
              declares a local variable...not a parameter.

              In MS SQL the parameters are placed between parenthesis after the CREATE or ALTER stored procedure name. Take the @ out of your parmeter -- this is used for local variables.

              Create the procedure with your parameters and change your parameter name in the VB Code to match. Also, you do not need the local variable for date since you are using the GetDate() function to populate the column.


              Code:
              CREATE PROCEDURE [dbo].[SP_SMS]
              (
                  CampaignName nvarchar(50)
              )
              AS
              BEGIN
              SET NOCOUNT ON;
              
              Declare @DateCreated datetime
              
              INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES([B]CampaignName[/B],GETDATE())
              Return
              
              END
              Go
              Originally posted by neenaprasad
              I am trying to pass parameters through form ............... .....

              Getting the following error.......... .

              Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
              [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure SP_SMS has no parameters and arguments were supplied.

              ---------------------- Here is my code ---------------------

              Code:
              Dim Camp_Name
              Dim CmdUpdate
              
              Camp_Name = Request.Form("x_CampaignName1")
              
              Set CmdUpdate = Server.CreateObject("ADODB.Command") 
              CmdUpdate.ActiveConnection = conn
              CmdUpdate.CommandText = "SP_SMS"
              CmdUpdate.CommandType = adCmdStoredProc
              
              CmdUpdate.Parameters.Append CmdUpdate.CreateParameter("@Campaign_Name", adnvarchar, adParamInput,50,Camp_Name)
              CmdUpdate.Execute , , adExecuteNoRecords
              
              Set CmdUpdate = Nothing
              ----------------- Here is my Stored Procedure --------------

              Code:
              CREATE PROCEDURE [dbo].[SP_SMS]
              
              AS
              BEGIN
              SET NOCOUNT ON;
              
              Declare @Campaign_Name nvarchar(50) 
              Declare @DateCreated datetime
              
              INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES(@Campaign_Name,GETDATE())
              
              END

              Can you please help me
              Thnx in Advance

              --------------------------------------------------------------------------------

              Comment

              Working...