STORED PROCEDURE USAGE IN ASP.NET

Tanuj Kumar

Total Post:134

Points:940
Posted by  Tanuj Kumar
 1177  View(s)
Ratings:
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.
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: stored Procedure usage in ASP.NET

    Hi Tanuj!


    Used StoredProcedure as following

    System.Data.CommandType.StoredProcedure

    I hope it helpful to you!

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!