Solved

Procedure has no parameters and arguments were supplied

Posted on 2006-11-29
1
1,884 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
.NET Error 7 42
Expando 4 34
Change data in datatable 8 16
POWERSHELL: do / until, should continue even when there is an error 4 14
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now