Re: templates question: can you parameterize the template passed?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Angus Comber (ac_at_NOiteloffice.com.PLEASENOSPAM)
Date: 09/09/04


Date: Thu, 9 Sep 2004 12:19:24 +0100

Would you mind posting a little code sample. I would be interested to see
the approach you take.

Angus

"Alexander Nickolov" <agnickolov@mvps.org> wrote in message
news:OALCw#PlEHA.1644@tk2msftngp13.phx.gbl...
> The action class does not need to derive from the accessor.
> In fact in all my ATL OLE DB code (and I've never used the
> wizard) I've used instances of the accessor classes on the
> stack and usually a single (sometimes multiple for different
> databases) class encompassing all the data access logic with
> a method per query.
>
> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD
> email: agnickolov@mvps.org
> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================
>
> "Angus Comber" <ac@NOiteloffice.com.PLEASENOSPAM> wrote in message
> news:OaC55E0kEHA.3988@tk2msftngp13.phx.gbl...
> > Hello
> >
> > I am using ATL OLE DB classes - ie atldbcli.h
> >
> > The wizard created the classes for me and I notice there are Accessor
> > classes - which are passed as parameters to the class used to access the
> > data. But in my header file I have three classes - two for SELECT type
> > access and one for action queries - eg INSERT INTO ...
> >
> > But I want to setup a global instance of my main database class - which
I
> > can access anywhere in my program - this is so I can access the
datasource
> > object. eg the connection to the database. Then from there do either
> > SELECT or action type queries using this global (or pointer to a class).
> >
> > So for example I have the following action accessor class:
> >
> > class CActionAccessor
> > {
> > public:
> > //Parameter variable.
> > CHAR m_InParam[2];
> > ULONG m_status;
> > // Parameter binding.
> > BEGIN_PARAM_MAP(CAppointsInsertAccessor)
> > SET_PARAM_TYPE(DBPARAMIO_INPUT)
> > COLUMN_ENTRY_STATUS(1,m_InParam,m_status)
> > END_PARAM_MAP()
> > };
> >
> > and here is one of the SELECT accessors - with lots of it removed for
> > clarity.
> >
> > VARIANT_BOOL m_Alarm;
> > VARIANT_BOOL m_AllDay;
> > LONG m_ApptID;
> > DATE m_StartDate;
> > DATE m_EndDate;
> > DATE m_AlarmDate;
> > TCHAR m_Location[101];
> > TCHAR m_Notes[255];
> > TCHAR m_Resource[101];
> > TCHAR m_Title[101];
> > TCHAR m_Type[101];
> > TCHAR m_User[101];
> > TCHAR m_Locked[101];
> > BEGIN_COLUMN_MAP(CAppointmentsAccessor)
> > COLUMN_ENTRY(1, m_ApptID)
> > COLUMN_ENTRY_TYPE(2, DBTYPE_DATE, m_StartDate)
> > COLUMN_ENTRY_TYPE(3, DBTYPE_DATE, m_EndDate)
> > COLUMN_ENTRY_TYPE(4, DBTYPE_DATE, m_AlarmDate)
> > COLUMN_ENTRY_TYPE(5, DBTYPE_BOOL, m_AllDay)
> > COLUMN_ENTRY_TYPE(6, DBTYPE_BOOL, m_Alarm)
> > COLUMN_ENTRY(7, m_Type)
> > COLUMN_ENTRY(8, m_Location)
> > COLUMN_ENTRY(9, m_Title)
> > COLUMN_ENTRY(10, m_Notes)
> > COLUMN_ENTRY(11, m_Resource)
> > COLUMN_ENTRY(12, m_User)
> > COLUMN_ENTRY(13, m_Locked)
> > END_COLUMN_MAP()
> >
> > But the wizard generates the classes to actually do the work like this:
> >
> > SELECT example:
> > class CAppointments : public CCommand<CAccessor<CAppointmentsAccessor> >
> > or action example:
> >
> > class CAppointsInsert : public
> > CCommand<CAccessor<CAppointsInsertAccessor>,
> > CNoRowset >
> > But I want a general database class, eg CDatabase. Can I do something
> > like
> > this?
> >
> > class CDatabase : public CCommand<CAccessor<CAppointmentsAccessor> >,
> > public
> > CCommand<CAccessor<CAppointsInsertAccessor>, CNoRowset >
> >
> > Should this work? Or is it better to create a separate CDatabase class
> > which then works out what is required and then uses the appropriate
class?
> > This I suppose is really a C++/design question. I am a bit of a
beginner
> > on
> > this so any help would be most appreciated?
> >
> > Angus Comber
> > angus@iteloffice.com
> >
> >
> >
> >
> >
>
>



Relevant Pages

  • Re: Continuously monitors Outlook and stores email data in database.
    ... automatically for an e-commerce web site. ... along with some HTML pages I created to allow customers to log in, ... information and put it into your database. ... any testing of any illustrative code sample for any particular use. ...
    (comp.databases.ms-access)
  • Re: connectionstring for VB.Net app which connects to MDB on website
    ... I am hoping that someone can provide a code sample using the following ... sample information below. ... is run on a local computer and connects to our database on our website. ... The alternative is to use a Web Service or binary Web Remoting. ...
    (microsoft.public.dotnet.general)
  • Re: upload file into database in asp
    ... Do you have a code sample of how you run the doc file download/edit/upload? ... so far I am doing some small testings and what I can do is upload the ... however, I cann't insert them into the database, Plus, what type ... without even the implied warranty of merchantability ...
    (microsoft.public.inetserver.asp.general)
  • Re: connectionstring for VB.Net app which connects to MDB on website
    ... > I am hoping that someone can provide a code sample using the following ... > sample information below. ... > is run on a local computer and connects to our database on our website. ...
    (microsoft.public.dotnet.general)
  • Re: Opening a database in a form view
    ... "Angus" wrote in message ... > update that database -- the dates I work for clients each ... > database program. ... > in datasheet view and open it into any of the forms ...
    (microsoft.public.access.tablesdbdesign)