Insert, Update, Delete of rows using OLE DB ATL Consumer Templates 
Author Message
 Insert, Update, Delete of rows using OLE DB ATL Consumer Templates

I'm trying to figure out the best way to design my
C++ classes when using the OLE DB ATL Consumer templates.
All sql queries are performed using stored procedures
where the majority of the stored procedures require
parameters.

A common scenario in my application(s) is to insert,
update and delete records in a table.

Given that I typically would call one stored procedure to
do the insert, another to update the row, and a third stored
procedure to delete the row, it seems that I would need to have one
class defined to perform the insert, another class defined to perform
the
update and yet another class to perform the delete.  Each
class would have in the header a BEGIN_PARAM_MAP END_PARAM_MAP
section defining the parameters for each stored procedure call.

Is it possible while still taking advantage of the parameter
accessor features to have all 3 (insert, update, delete) functions
defined within the same class?   I would prefer to stay away from
3rd party tools if possible.



Tue, 29 Mar 2005 05:21:03 GMT  
 Insert, Update, Delete of rows using OLE DB ATL Consumer Templates
Maybe a simpler way to phrase the question is: Are
multiple parameter accessors possible within the same class?
And if so would anyone have an example of how to do this?
Quote:

> I'm trying to figure out the best way to design my
> C++ classes when using the OLE DB ATL Consumer templates.
> All sql queries are performed using stored procedures
> where the majority of the stored procedures require
> parameters.

> A common scenario in my application(s) is to insert,
> update and delete records in a table.

> Given that I typically would call one stored procedure to
> do the insert, another to update the row, and a third stored
> procedure to delete the row, it seems that I would need to have one
> class defined to perform the insert, another class defined to perform
> the
> update and yet another class to perform the delete.  Each
> class would have in the header a BEGIN_PARAM_MAP END_PARAM_MAP
> section defining the parameters for each stored procedure call.

> Is it possible while still taking advantage of the parameter
> accessor features to have all 3 (insert, update, delete) functions
> defined within the same class?   I would prefer to stay away from
> 3rd party tools if possible.



Tue, 29 Mar 2005 11:11:25 GMT  
 Insert, Update, Delete of rows using OLE DB ATL Consumer Templates
Here's an example:

class CEmployeeData
{
public:
// Data Elements
 CHAR m_szFirstName[51];
 CHAR m_szLastName[51];
 ISequentialStream* m_pstWaveData;

// Output binding map
BEGIN_ACCESSOR_MAP(CEmployeeData, 2)
 BEGIN_ACCESSOR(0, true)
  COLUMN_ENTRY(1, m_szFirstName)
  COLUMN_ENTRY(2, m_szLastName)
 END_ACCESSOR()
 BEGIN_ACCESSOR(1, false)
  BLOB_ENTRY(3, IID_ISequentialStream, STGM_READ, m_pstWaveData)
 END_ACCESSOR()
END_ACCESSOR_MAP()

Quote:
};

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Quote:

> Maybe a simpler way to phrase the question is: Are
> multiple parameter accessors possible within the same class?
> And if so would anyone have an example of how to do this?


> > I'm trying to figure out the best way to design my
> > C++ classes when using the OLE DB ATL Consumer templates.
> > All sql queries are performed using stored procedures
> > where the majority of the stored procedures require
> > parameters.

> > A common scenario in my application(s) is to insert,
> > update and delete records in a table.

> > Given that I typically would call one stored procedure to
> > do the insert, another to update the row, and a third stored
> > procedure to delete the row, it seems that I would need to have one
> > class defined to perform the insert, another class defined to perform
> > the
> > update and yet another class to perform the delete.  Each
> > class would have in the header a BEGIN_PARAM_MAP END_PARAM_MAP
> > section defining the parameters for each stored procedure call.

> > Is it possible while still taking advantage of the parameter
> > accessor features to have all 3 (insert, update, delete) functions
> > defined within the same class?   I would prefer to stay away from
> > 3rd party tools if possible.



Wed, 30 Mar 2005 02:10:13 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. OLE DB consumer template - How to INSERT

2. ATL OLE DB Consumer Templates

3. Insert rows with OLE DB template?

4. Help with invoking stored proc using OLE DB consumer templates

5. How to manage Db access with OLE DB Consumer Templates in COM

6. ATL OLE DB consumer using attribute -- information?

7. insert tables in ATL OLE DB Provider Templates

8. ADO recordset in OLE DB consumer templates

9. OLE DB Consumer Templates

10. Variable number of parameters for OLE DB consumer template

11. OLE DB Consumer Template Accessors (Dynamic Vs. Manual)??

12. ExecuteSQL in OLE-DB template consumer

 

 
Powered by phpBB® Forum Software