4

I am using StoredProcedure in sqlserver 2005.

Stored Procedure:

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.

By researching for code i came to know i should use

 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 is my mistake?

What command should i use for implementing stored procedure?

Please Help Me.

2
  • 1
    What error you are getting ?? Commented May 13, 2013 at 7:33
  • 1
    CommandType does not exists in current context Commented May 13, 2013 at 7:34

5 Answers 5

4

Try like this:

System.Data.CommandType.StoredProcedure

Source: http://msdn.microsoft.com/en-us/library/system.data.commandtype.aspx

Sign up to request clarification or add additional context in comments.

Comments

3

First use this namespace

using System.Data;

Then you should be able to use:

CommandType.StoredProcedure

Comments

2

Need to use like this

System.Data.CommandType.StoredProcedure

Also make it sure that Reference to System.Data is needed.

Comments

2

try using the namespace using System.Data;

Comments

1

I think you are missing the blow line

using System.Data;

You need to use this namesapce for "SqlDataSourceCommandType.StoredProcedure" .

1 Comment

Yeah it's my mistake. Thanks for your response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.