Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2008, 07:27 AM
Authorized User
 
Join Date: Feb 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to supply parameter to a storedproc

DEAR ALL,

How to supply parameter to a storedproc from codebehind..


AMR
 
Old March 31st, 2008, 09:02 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It all depends on how you will call the sproc:

1) Using a command object: add a parameter to the parameters collection with the details of that param.

2) Plain SQL query: construct the query with the parameter value inline.

You'll need to provide a bit more explanation about how you are building your page if you need more specific advice.

-Peter
peterlanoie.blog
 
Old March 31st, 2008, 10:21 PM
Authorized User
 
Join Date: Feb 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dear planoie,

I am actually using an sqldatasource like sqldatasource="mystoredproc" Commandtype="Storedprocedure".In the sqlServer 2005 i created a storedproc which takes a datetime value.I can exec like exec mystoredproc '04/01/2008'
its working but where to give the parameter value to the stored proc in the code behind....

thank you,
AMR.
 
Old March 31st, 2008, 10:30 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

There is a filterparameters node of this control. Review the documentation, it should help you.

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.filterpara meters(VS.80).aspx

-Peter
peterlanoie.blog
 
Old April 10th, 2008, 07:47 AM
Authorized User
 
Join Date: Dec 2004
Posts: 69
Thanks: 0
Thanked 5 Times in 5 Posts
Send a message via Yahoo to whiterainbow
Default

SqlCommand c = new SqlCommand();
            c.CommandType = CommandType.StoredProcedure;
            c.CommandText = "YourStoredProcedureName";

            SqlParameter[] p;
            p[0] = new SqlParameter("@yourdatabaseparametername", DateTime.Now.ToShortDateString());
            c.Parameters.Add(p);

            c.ExecuteReader();

Thanks and Regards,

Senthil Kumar M.





Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically Parameters.Add for storedProc havey C# 2 November 27th, 2007 02:41 PM
Procedure or function STOREDPROC has too man rit01 ASP.NET 2.0 Basics 4 January 25th, 2006 09:51 AM
Dumping StoredProc output to text File ao7711 SQL Server DTS 8 January 12th, 2006 04:41 PM
retrieve varbinary using StoredProc with OUTPUT ag19702004 ADO.NET 0 November 30th, 2005 01:37 PM
"ClassFactory cannot supply requested class" charan1976 Classic ASP Components 1 May 20th, 2004 06:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.