Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > urgent asp.net Help:

Reply
Thread Tools

urgent asp.net Help:

 
 
=?Utf-8?B?YW1qYWQ=?=
Guest
Posts: n/a
 
      06-08-2006
i am posting below code i am not sure how to call parametrized store
procedure and fill the grid.
....
I have store procedure which pull the info from sql server 2005 using
asp.net 1.1... that proc accept two parameters .
any body has any idea how to do that thing using dataset ....
thanks
public DataSet GetCustByDate(int MonthNo,string YearNo)
{
strSQL="dbo.sp_GetCust " + MonthNo.ToString() + " , " + YearNo;

SqlConnection conn = this.GetConnection();
conn.Open();
SqlDataAdapter myCommand = new SqlDataAdapter(strSQL, conn);
DataSet ds = new DataSet();
myCommand.Fill(ds, strSQL);
conn.Close();

return ds;

}
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      06-08-2006
Amjad,
This is the WRONG way to use ADO.NET to make a stored procedure call!
You are using the Language path through SQL Server, and you want to use the
RPC path instead.

1) Create a SqlCommand object, set it's CommandText property to the name of
the stored proc, and it's CommandType property to StoredProcedure.
2) Create a SqlParameter object for each named parameter, assign it the
actual parameter value, and add the Parameter to the SqlCommand's Parameters
collection.

3) Assign the Command to the SelectCommand property of the DataAdapter and
continue as you did before.

--Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"amjad" wrote:

> i am posting below code i am not sure how to call parametrized store
> procedure and fill the grid.
> ...
> I have store procedure which pull the info from sql server 2005 using
> asp.net 1.1... that proc accept two parameters .
> any body has any idea how to do that thing using dataset ....
> thanks
> public DataSet GetCustByDate(int MonthNo,string YearNo)
> {
> strSQL="dbo.sp_GetCust " + MonthNo.ToString() + " , " + YearNo;
>
> SqlConnection conn = this.GetConnection();
> conn.Open();
> SqlDataAdapter myCommand = new SqlDataAdapter(strSQL, conn);
> DataSet ds = new DataSet();
> myCommand.Fill(ds, strSQL);
> conn.Close();
>
> return ds;
>
> }

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT RichA <rander3127@gmail.com> For rec.photo.digital MVP of all time. Vote now!! URGENT. Griffin Digital Photography 0 08-27-2010 08:18 AM
urgent help....need urgent help on say string task.. pooja Software 0 03-03-2009 06:16 AM
!!URGENT!! Tor Vulnerability Discovered !!URGENT!! Security Advisory Computer Security 1 08-11-2007 09:04 PM
URGENT !! QUEUE STL PROBLEM URGENT!! Sachin Jagtap C++ 4 04-29-2005 12:08 PM
Urgent problem, repeat, Urgent problem. Rob Javascript 3 05-18-2004 12:05 AM



Advertisments