Solved

Procedure has no parameters and arguments were supplied

Posted on 2006-11-29
1
1,893 Views
Last Modified: 2012-06-22
Hi,

I wrote the following stored procedure :

ALTER PROCEDURE GetOrdersCount
/* Returns the number of orders records at the OrdersMain table */
            

AS
      SELECT Count(OrderDetNum)
      FROM OrdersDet
      RETURN

I called to this stored procedure as follows :

  public int GetOrdersCount()
 {
  int ordersCount = 0;
   try
   {
   command.CommandText = "GetOrdersCount";
   command.CommandType = CommandType.StoredProcedure;

  // activate the stored procedure to add lines to the database.
   conn.Open();
   ordersCount = (int)command.ExecuteScalar();
  }
  finally
  {
     conn.Close();
  }
  return ordersCount;
}

The problem that after some calls to that procedure I get an exception that says :
"Procedure GetOrdersCount has no parameters and arguments were supplied".

Please tell me why is that happen and how to fix it.

Thanks
Michael
0
Comment
Question by:MichaelMarom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
YZlat earned 50 total points
ID: 18040113
try this:

public int GetOrdersCount()
 {
  int ordersCount = 0;
   try
   {
// activate the stored procedure to add lines to the database.
   conn.Open();
   command=new SqlCommand("GetOrdersCount",conn);
   command.CommandType = CommandType.StoredProcedure;

 
   ordersCount = (int)command.ExecuteScalar();
  }
  finally
  {
     conn.Close();
  }
  return ordersCount;
}
0

Featured Post

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question