473,466 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with stored procedure

I am trying to query two tables with a stored procedure but I get the
following error:

"Procedure Details has no parameters and arguments were supplied."

Here is my stored procedure as created by Visual Studio:

ALTER PROCEDURE dbo.Details
AS
SET NOCOUNT ON;
SELECT Events.KeyID, Events.StartDate, Events.StartTime, Events.EventName,
Events.StartLocation, Events.EndLocation, Events.AvailableSeats,
Events.Description, Events.RateAdult, Events.RateChild, Events.RateSenior,
Reservations.KeyID AS Expr1, Reservations.EventID, Reservations.AccountID,
Reservations.qntyChild, Reservations.qntyAdult, Reservations.qntySenior,
Reservations.GroupID, Reservations.Status FROM Events INNER JOIN Reservations
ON Events.KeyID = Reservations.EventID

Here is the code being used to query the Stored Procedure in the page_load
event:

int EventID = Convert.ToInt32(Request.QueryString["ID"]);

this.sqlSelectCommand1.CommandText = "Details";
this.sqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure;
this.sqlSelectCommand1.Connection = this.sqlConnection2;
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@EventID", System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)),
((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));

this.sqlSelectCommand1.Parameters.Add("@EventID",
System.Data.SqlDbType.NVarChar).Value = EventID;

sqlConnection2.Open();
myReader = sqlSelectCommand1.ExecuteReader();

if (myReader.Read())
{
txtEventName.Text = myReader["EventName"].ToString();
}
sqlConnection2.Close();

Any ideas on why this isn't working?

This is my first time using a stored procedure in a project so any help
would be great.

Thanks, Justin.
Nov 18 '05 #1
1 2641
You're stored procedure doesn't have a parameter and in your code you specify
a parameter. The stored procedure must begin like:

ALTER PROCEDURE dbo.Details
@EventID int
as begin
.......

and in the where clause:
where Reservations.EventID = @EventID

The code looks something like:
SqlParameter sqlPar = new SqlParameter("@EventID", SqlDbType.Int);
sqlPar.Value = EventID;
this.SelectCommand1.Parameters.Add(sqlPar);
"Justin" wrote:
I am trying to query two tables with a stored procedure but I get the
following error:

"Procedure Details has no parameters and arguments were supplied."

Here is my stored procedure as created by Visual Studio:

ALTER PROCEDURE dbo.Details
AS
SET NOCOUNT ON;
SELECT Events.KeyID, Events.StartDate, Events.StartTime, Events.EventName,
Events.StartLocation, Events.EndLocation, Events.AvailableSeats,
Events.Description, Events.RateAdult, Events.RateChild, Events.RateSenior,
Reservations.KeyID AS Expr1, Reservations.EventID, Reservations.AccountID,
Reservations.qntyChild, Reservations.qntyAdult, Reservations.qntySenior,
Reservations.GroupID, Reservations.Status FROM Events INNER JOIN Reservations
ON Events.KeyID = Reservations.EventID

Here is the code being used to query the Stored Procedure in the page_load
event:

int EventID = Convert.ToInt32(Request.QueryString["ID"]);

this.sqlSelectCommand1.CommandText = "Details";
this.sqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure;
this.sqlSelectCommand1.Connection = this.sqlConnection2;
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@EventID", System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)),
((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));

this.sqlSelectCommand1.Parameters.Add("@EventID",
System.Data.SqlDbType.NVarChar).Value = EventID;

sqlConnection2.Open();
myReader = sqlSelectCommand1.ExecuteReader();

if (myReader.Read())
{
txtEventName.Text = myReader["EventName"].ToString();
}
sqlConnection2.Close();

Any ideas on why this isn't working?

This is my first time using a stored procedure in a project so any help
would be great.

Thanks, Justin.

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jeff Wang | last post by:
Hi all, Can someone help me out? I've been struggling with this for almost a week and still have no clue what's wrong. Basically I want to write a DB2 stored procedure for OS/390 in REXX. In...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
5
by: Timppa | last post by:
Hi, Could anyone help me with my problem ? Environment: Access 2000 and Sql Server 2000. I have a stored procedure as follows: DROP table1 SELECT alias1.field1,alias2.field2,table2.field6...
6
by: Wojciech Wendrychowicz | last post by:
Hello to All, I'm trying to retrieve records from AS/400 in an VBA application. So, I've made an RPG program, then a stored procedure wchich calls that RPG program, and finally some VBA code to...
1
by: BigD | last post by:
This all centers around an Access Data Project I have a stored procedure that aggregates events stored in a table based on intervals I specify. I have a form that supplies parameters for the...
2
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have...
1
by: tedqn | last post by:
Problem: - Stored procedure input parameters data type specific (SqlDbType.Int, SqlDbType.VarChar,etc). - Form submitted value in TextBox, DropDownList, etc are all string type (I guess). Some...
9
by: fniles | last post by:
I am using VB.NET 2003 and SQL2000 database. I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1 parameter (varchar(10)) and returns the identity column value from that table....
1
by: amgupta8 | last post by:
Note: This problem occurred when I updated the JDK from 1.3.1 to 1.4.1 or 1.4.2. Nothing else was changed in the code, other than updating the JDK on the database server (dbm cfg parm jdk_path) and...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.