Solved

Procedure has no parameters and arguments were supplied

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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

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.   …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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