Reputation: 9074
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.
Upvotes: 4
Views: 1178
Reputation: 3125
I think you are missing the blow line
using System.Data;
You need to use this namesapce for "SqlDataSourceCommandType.StoredProcedure" .
Upvotes: 1
Reputation: 4892
First use this namespace
using System.Data;
Then you should be able to use:
CommandType.StoredProcedure
Upvotes: 3
Reputation: 8109
Try like this:
System.Data.CommandType.StoredProcedure
Source: http://msdn.microsoft.com/en-us/library/system.data.commandtype.aspx
Upvotes: 4
Reputation: 4963
Need to use like this
System.Data.CommandType.StoredProcedure
Also make it sure that Reference to System.Data is needed.
Upvotes: 2