Solved

Procedure has no parameters and arguments were supplied

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…

713 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