SqlCommand CommandType property

  • Thread starter Thread starter lakshmi
  • Start date Start date
L

lakshmi

I'm trying to set the CommandType property of a SqlCommand
to Stored procedure. My code looks like:

using System.Data.SqlClient;
SqlCommand cmd = new SqlCommand("MyStoredProcedureName");
cmd.Connection = myConn;
cmd.CommandType = CommandType.StoredProcedure;

I'm getting the following error:
The type or namespace name 'CommandType' could not be
found.

Should I hard code the enumerated number for CommandType?
or what namespace would support the above syntax?

Your help is appreciated.
Thanks.
 
I think I figured that out. I guess I should use the
System.Data namespace also. Thanks.
 
Hi,

The CommandType enumeration is present in the System.Data
namespace. So you need to include that in your code by
the following statement,

using System.Data

Regards,
Madhu

MCSD.NET | MVP
 
Back
Top