Cant get Stored Procedure connection string right??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
SqlCommand cmd = new SqlCommand("my_storedprocedure",con);
cmd.CommandType = CommandType.StoredProcedure;

The error is : type or namespace name 'CommandType' could not be found(are
you missing a using directive or an assembly reference)

I have included the following namespaces
using System.Data.SqlClient;
and the method 'CommandType 'is defined in this class only, but still i
could not get it right.

Suggest some other work arounds, or get it right.

Please advise
 
You need to import System.Data, I believe that is where that enumeration is,
since it is not exclusive to SQL Server.

In general, you could always find what namespace a class is in, by looking
it up in the documentation.
 
Hi Marina,
Thanks for the reply. I got it working, I am using MS .NET 2003 and i
dont have to specify commandtype to change it to storedprocedure, I ommitted
the line and voila it worked. The compiler is smart enough to make
adjustments.

Do correct me if i'm wrong.

Thanks again

Hemant Singh



Marina said:
You need to import System.Data, I believe that is where that enumeration is,
since it is not exclusive to SQL Server.

In general, you could always find what namespace a class is in, by looking
it up in the documentation.
 
Back
Top