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.
Try like this:
System.Data.CommandType.StoredProcedure
Source: http://msdn.microsoft.com/en-us/library/system.data.commandtype.aspx
First use this namespace
using System.Data;
Then you should be able to use:
CommandType.StoredProcedure
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With