.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

call stored procedure

Posted By: rashmi     Posted Date: July 16, 2011    Points:5   Category :C#
hi i have created store procedure like this

ALTER PROCEDURE [dbo].[consumption](@fromdate datetime,@todate datetime)
-- Add the parameters for the stored procedure here

AS


BEGIN

select distinct S.date,S.itemname ,v.ingname,v.quantity,count(S.quantity) as salequantity, (v.quantity *count(S.quantity) ) as totqty from ingredientdetails v INNER JOIN bill S ON S.itemname= v.itemname where S.date between @fromdate and @todate group by v.itemname,v.ingname,v.quantity,S.itemname,S.date

END


and i call this stored procedure in project
like this

public static DataTable
getdataforconsmtnreportsbfromatodatewise(DateTime fromdate,DateTime todate)
{

DbCommand dbcom = BaseDB.CreateCommand();
dbcom.CommandText = "consumption";

DbParameter dbParam = dbcom.CreateParameter();
dbParam.ParameterName = "@fromdate";
dbParam.Value = fromdate;
dbParam.DbType = DbType.DateTime;
dbParam.Direction = ParameterDirection.Input;
dbcom.Parameters.Add(dbParam);


dbParam.ParameterName = "@todate";
dbParam.Value = todate;
dbParam.DbType = DbType.DateTime;
dbParam.Direction = ParameterDirection.Input;
// dbcom.Parameters.Add(dbParam);

DataTable dt;
try
{
dt = BaseDB.ExecuteSelect(dbcom);
}
catch (Exception ex)
{
throw ex;
}
return dt;
}


but at the time of execution error is occur:
Additional information: Procedure consumption has no parameters and arguments were supplied.

plz any one help me how i solve this problem


Responses
Author: Narayanan             
Posted Date: July 17, 2011     Points: 20   

Hi,
Add this line in your Code:
cmd.CommandType = CommandType.StoredProcedure;

and also Refer this Site:
http://msdn.microsoft.com/en-us/library/d7125bke%28v=vs.80%29.aspx#Y1710

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: Sasi Prabhu             
Posted Date: July 17, 2011     Points: 20   
Author: rashmi             
Posted Date: July 18, 2011     Points: 20   

thanks

now my proj is running well in my pc but when i make exe of that proj and run this exe to another pc at that time when i call this stored procedure to display crystal report that time database login dialogue will appear
how i show crystal report by calling stored procedure when exe is running


Author: Narayanan             
Posted Date: July 18, 2011     Points: 20   

Hi,
http://www.pdssoftware.com/newsletter/mar07/page6.htm
http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/e04bcb0f-3174-466d-a198-8865d9b9de57

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend