I am trying to create a class that will interact with a SQL Server database
I have made up but having a few issues with it.
The basic code is:
Class DatabaseMethods
{
Public:
DatabaseOpen();
DatabaseCreate();
Private:
SqlConnection conn;
};
When compiling (VS C++ 2005) , it won't let me declare 'SqlConnection conn;'
Is there a way around this ?
Cheers
Pete
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
-->>>>>>http://www.NewsDemon.com<<<<<<--
Unlimited Access, Anonymous Accounts, Uncensored Broadband AccessShould you fully denote the namespace where SQLConnection resides -or add a
'Using System.Data.SQLClient' to the class? How else would this class know
where/how to locate the SQLConnection object?
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"MyMail" <peter.moscatt@.gmail.com> wrote in message
news:44960c8f$0$30230$b9f67a60@.news.newsdemon.com...
>I am trying to create a class that will interact with a SQL Server database
>I have made up but having a few issues with it.
>
> The basic code is:
>
> Class DatabaseMethods
> {
> Public:
> DatabaseOpen();
> DatabaseCreate();
> Private:
> SqlConnection conn;
> };
>
> When compiling (VS C++ 2005) , it won't let me declare 'SqlConnection
> conn;'
>
> Is there a way around this ?
>
> Cheers
> Pete
>
>
> --
> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
> -->>>>>>http://www.NewsDemon.com<<<<<<--
> Unlimited Access, Anonymous Accounts, Uncensored Broadband Access|||G'Day Arnie,
Thanks for the guide.
I did what you asked (see code below)
// ......... MyHeader.h .........
using namespace System;
using namespace System::Data;
using namespace System::Data::SqlClient;
class DaabaseMethods
{
using System::Data::SqlClient;
public:
void OpenDatabase();
void CreateDatabase();
};
I would have throught because I had already declared
'System::Data::SqlClient' at the top of the header the class should
have seen it.
But anyway, I compiled it and got the following:
error C2886: 'System::Data::SqlClient' : symbol cannot be used in a
member using-declaration
So, what ya reckon '
Pete
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:%23Vq0ky2kGHA.1324@.TK2MSFTNGP04.phx.gbl...
> Should you fully denote the namespace where SQLConnection
> resides -or add a 'Using System.Data.SQLClient' to the class? How
> else would this class know where/how to locate the SQLConnection
> object?
> --
> Arnie Rowland, YACE*
> "To be successful, your heart must accompany your knowledge."
> *Yet Another certification Exam
>
> "MyMail" <peter.moscatt@.gmail.com> wrote in message
> news:44960c8f$0$30230$b9f67a60@.news.newsdemon.com...
>
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
-->>>>>>http://www.NewsDemon.com<<<<<<--
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access|||The USING statement has to be outside (and before) the class definition
code -you are correct that the header is where it belongs.
I'm not a C++ person, you need to direct this question to a group that deals
with C++.
Regards,
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"MyMail" <peter.moscatt@.gmail.com> wrote in message
news:44971fa3$0$4190$b9f67a60@.news.newsdemon.com...
> G'Day Arnie,
> Thanks for the guide.
> I did what you asked (see code below)
> // ......... MyHeader.h .........
> using namespace System;
> using namespace System::Data;
> using namespace System::Data::SqlClient;
> class DaabaseMethods
> {
> using System::Data::SqlClient;
> public:
> void OpenDatabase();
> void CreateDatabase();
> };
> I would have throught because I had already declared
> 'System::Data::SqlClient' at the top of the header the class should have
> seen it.
> But anyway, I compiled it and got the following:
> error C2886: 'System::Data::SqlClient' : symbol cannot be used in a member
> using-declaration
>
> So, what ya reckon '
> Pete
>
> "Arnie Rowland" <arnie@.1568.com> wrote in message
> news:%23Vq0ky2kGHA.1324@.TK2MSFTNGP04.phx.gbl...
>
> --
> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
> -->>>>>>http://www.NewsDemon.com<<<<<<--
> Unlimited Access, Anonymous Accounts, Uncensored Broadband Access|||Xref: TK2MSFTNGP01.phx.gbl microsoft.public.sqlserver.programming:610013
No worries Arnie... thanks for the help anyway.
Pete
On Mon, 19 Jun 2006 16:37:01 -0700, "Arnie Rowland" <arnie@.1568.com>
wrote:
>The USING statement has to be outside (and before) the class definition
>code -you are correct that the header is where it belongs.
>I'm not a C++ person, you need to direct this question to a group that deal
s
>with C++.
>Regards,
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
-->>>>>>http://www.NewsDemon.com<<<<<<--
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access