stored Procedure usage in ASP.NET

Posted by  Tanuj Kumar
 1810  View(s)
Rate this:
Hi Expert!

I want to used stored procedure in my asp. net application. I'm using SQL Server 2005. My line of code as following.

create proc useGetASP @PartyCode nvarchar(50)
select * 
from partyRegister 
where PartyCode=@PartyCode

I was trying to execute it with visual studio 2010.

I'm try as following.

cmd.CommandType = CommandType.StoredProcedure
But unfortunatly CommandType.StoredProcedure is not there , its not working.

Hence i used:

cmd.CommandType = SqlDataSourceCommandType.StoredProcedure;

But this is also not working. It shows me red line below it [As comes when we type something invalid]. As a tooltip it shows me error as: CommandType does not exists in current context

My Full Code:

cmd = new SqlCommand("useGetASP",con);
//cmd.CommandType =CommandType./*Not Working*/
cmd.CommandType = SqlDataSourceCommandType.StoredProcedure;/*Also Not Working*/

what's I'm missing in my code?

What command should I use for implementing stored procedure?

Please Help Me.
Any help will be appreciated.
  1. Re: stored Procedure usage in ASP.NET

    Hi Tanuj!

    Used StoredProcedure as following


    I hope it helpful to you!