Home > DeveloperSection > Forums > stored Procedure usage in ASP.NET
Tanuj Kumar

Total Post:134

Points:940
Posted on    May-13-2013 3:43 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 840  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)
as
select * 
from partyRegister 
where PartyCode=@PartyCode
Go

I was trying to execute it with asp.net 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:

con.Open();
cmd = new SqlCommand("useGetASP",con);
//cmd.CommandType =CommandType./*Not Working*/
cmd.CommandType = SqlDataSourceCommandType.StoredProcedure;/*Also Not Working*/
cmd.Parameters.AddWithValue("@PartyCode","0L036");

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.


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    May-13-2013 9:37 AM

Hi Tanuj!

Used StoredProcedure as following

System.Data.CommandType.StoredProcedure

I hope it helpful to you!

Don't want to miss updates? Please click the below button!

Follow MindStick