Connecting Tech Pros Worldwide Forums | Help | Site Map

Passing parameters through form with stored procs in ASP

Newbie
 
Join Date: Jan 2008
Location: Kochi
Posts: 13
#1: Aug 17 '08
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.CommandType = adCmdStoredProc

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

Expand|Select|Wrap|Line Numbers
  1. Dim Camp_Name
  2. Dim CmdUpdate
  3.  
  4. Camp_Name = Request.Form("x_CampaignName1")
  5.  
  6. Set CmdUpdate = Server.CreateObject("ADODB.Command") 
  7. CmdUpdate.ActiveConnection = conn
  8. CmdUpdate.CommandText = "SP_SMS"
  9. CmdUpdate.CommandType = adCmdStoredProc
  10.  
  11. CmdUpdate.Parameters.Append CmdUpdate.CreateParameter("@Campaign_Name", adnvarchar, adParamInput,50,Camp_Name)
  12. CmdUpdate.Execute , , adExecuteNoRecords
  13.  
  14. Set CmdUpdate = Nothing
--------------------------------- Here is my Stored Procedure --------------------------------------

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE [dbo].[SP_SMS]
  2.  
  3. AS
  4. BEGIN
  5.     SET NOCOUNT ON;
  6.  
  7. Declare @Campaign_Name nvarchar(50) 
  8. Declare @DateCreated datetime
  9.  
  10.     INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES(@Campaign_Name,GETDATE())
  11.  
  12. END

Can you please help me
Thnx in Advance
Newbie
 
Join Date: Jan 2008
Location: Kochi
Posts: 13
#2: Aug 17 '08

re: 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 ---------------------

Expand|Select|Wrap|Line Numbers
  1. Dim Camp_Name
  2. Dim CmdUpdate
  3.  
  4. Camp_Name = Request.Form("x_CampaignName1")
  5.  
  6. Set CmdUpdate = Server.CreateObject("ADODB.Command") 
  7. CmdUpdate.ActiveConnection = conn
  8. CmdUpdate.CommandText = "SP_SMS"
  9. CmdUpdate.CommandType = adCmdStoredProc
  10.  
  11. CmdUpdate.Parameters.Append CmdUpdate.CreateParameter("@Campaign_Name", adnvarchar, adParamInput,50,Camp_Name)
  12. CmdUpdate.Execute , , adExecuteNoRecords
  13.  
  14. Set CmdUpdate = Nothing
----------------- Here is my Stored Procedure --------------

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE [dbo].[SP_SMS]
  2.  
  3. AS
  4. BEGIN
  5. SET NOCOUNT ON;
  6.  
  7. Declare @Campaign_Name nvarchar(50) 
  8. Declare @DateCreated datetime
  9.  
  10. INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES(@Campaign_Name,GETDATE())
  11.  
  12. END

Can you please help me
Thnx in Advance

--------------------------------------------------------------------------------
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#3: Aug 18 '08

re: Passing parameters through form with stored procs in ASP


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
Newbie
 
Join Date: Jan 2008
Location: Kochi
Posts: 13
#4: Aug 19 '08

re: Passing parameters through form with stored procs in ASP


Quote:

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 ---------------------

Expand|Select|Wrap|Line Numbers
  1. Dim Camp_Name
  2. Dim CmdUpdate
  3.  
  4. Camp_Name = Request.Form("x_CampaignName1")
  5.  
  6. Set CmdUpdate = Server.CreateObject("ADODB.Command") 
  7. CmdUpdate.ActiveConnection = conn
  8. CmdUpdate.CommandText = "SP_SMS"
  9. CmdUpdate.CommandType = adCmdStoredProc
  10.  
  11. CmdUpdate.Parameters.Append CmdUpdate.CreateParameter("@Campaign_Name", adnvarchar, adParamInput,50,Camp_Name)
  12. CmdUpdate.Execute , , adExecuteNoRecords
  13.  
  14. Set CmdUpdate = Nothing
----------------- Here is my Stored Procedure --------------

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE [dbo].[SP_SMS]
  2.  
  3. AS
  4. BEGIN
  5. SET NOCOUNT ON;
  6.  
  7. Declare @Campaign_Name nvarchar(50) 
  8. Declare @DateCreated datetime
  9.  
  10. INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES(@Campaign_Name,GETDATE())
  11.  
  12. END

Can you please help me
Thnx in Advance

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

Can you tell me where to use the "#" button?
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#5: Aug 19 '08

re: Passing parameters through form with stored procs in ASP


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
Newbie
 
Join Date: Jan 2008
Location: Kochi
Posts: 13
#6: Aug 19 '08

re: Passing parameters through form with stored procs in ASP


Quote:

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(@Campaign_Name,GETDATE())

END
Newbie
 
Join Date: Aug 2008
Posts: 1
#7: Aug 23 '08

re: Passing parameters through form with stored procs in ASP


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.


Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE [dbo].[SP_SMS]
  2. (
  3.     CampaignName nvarchar(50)
  4. )
  5. AS
  6. BEGIN
  7. SET NOCOUNT ON;
  8.  
  9. Declare @DateCreated datetime
  10.  
  11. INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES(CampaignName,GETDATE())
  12. Return
  13.  
  14. END
  15. Go
Quote:

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 ---------------------

Expand|Select|Wrap|Line Numbers
  1. Dim Camp_Name
  2. Dim CmdUpdate
  3.  
  4. Camp_Name = Request.Form("x_CampaignName1")
  5.  
  6. Set CmdUpdate = Server.CreateObject("ADODB.Command") 
  7. CmdUpdate.ActiveConnection = conn
  8. CmdUpdate.CommandText = "SP_SMS"
  9. CmdUpdate.CommandType = adCmdStoredProc
  10.  
  11. CmdUpdate.Parameters.Append CmdUpdate.CreateParameter("@Campaign_Name", adnvarchar, adParamInput,50,Camp_Name)
  12. CmdUpdate.Execute , , adExecuteNoRecords
  13.  
  14. Set CmdUpdate = Nothing
----------------- Here is my Stored Procedure --------------

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE [dbo].[SP_SMS]
  2.  
  3. AS
  4. BEGIN
  5. SET NOCOUNT ON;
  6.  
  7. Declare @Campaign_Name nvarchar(50) 
  8. Declare @DateCreated datetime
  9.  
  10. INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES(@Campaign_Name,GETDATE())
  11.  
  12. END

Can you please help me
Thnx in Advance

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

Reply