Solved

Procedure has no parameters and arguments were supplied

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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