Passing parameters through form with stored procs in ASP | Newbie | | Join Date: Jan 2008 Location: Kochi
Posts: 13
| |
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 ------------------------------------------ - 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 -------------------------------------- - 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
| | Newbie | | Join Date: Jan 2008 Location: Kochi
Posts: 13
| | | 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 --------------------- - 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 -------------- - 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
--------------------------------------------------------------------------------
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | 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
| | | 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 --------------------- - 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 -------------- - 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?
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | 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
| | | 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
| | | 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. - CREATE PROCEDURE [dbo].[SP_SMS]
-
(
-
CampaignName nvarchar(50)
-
)
-
AS
-
BEGIN
-
SET NOCOUNT ON;
-
-
Declare @DateCreated datetime
-
-
INSERT INTO SMSMain (Campaign_Name,DateCreated) VALUES(CampaignName,GETDATE())
-
Return
-
-
END
-
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 --------------------- - 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 -------------- - 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
-------------------------------------------------------------------------------- |  | Similar ASP / Active Server Pages bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,411 network members.
|