Home All Groups Group Topic Archive Search About

Cant get Stored Procedure connection string right??

Author
28 Jan 2005 7:15 PM
hemant
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
--
Hemant Singh
Software Programmer
Author
28 Jan 2005 7:23 PM
Marina
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.

Show quoteHide quote
"hemant" <hem***@discussions.microsoft.com> wrote in message
news:46BCBE1F-82DA-4971-A17A-52098EC8B13C@microsoft.com...
> 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
> --
> Hemant Singh
> Software Programmer
>
Are all your drivers up to date? click for free checkup

Author
28 Jan 2005 7:41 PM
hemant
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



Show quoteHide quote
"Marina" wrote:

> 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.
>
> "hemant" <hem***@discussions.microsoft.com> wrote in message
> news:46BCBE1F-82DA-4971-A17A-52098EC8B13C@microsoft.com...
> > 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
> > --
> > Hemant Singh
> > Software Programmer
> >
>
>
>

Bookmark and Share