Solved

Creating a COM object that speaks  to the database

Posted on 2000-05-08
2
168 Views
Last Modified: 2013-11-25
I need to create a COM object in VC++ which will talk to the database,insert records,update and delete them.
My DB is SQl-Server.
0
Comment
Question by:Debasmitha
2 Comments
 

Expert Comment

by:woolmer
ID: 2795727
Use ADO if you can. If you make use of Smart Pointers your code looks very similar ( at least as straightforward to read ) as VB code. Plus there is loads more help for VB to SQL Server around than VC++.

If you have access to MSDN read
"Microsoft ADO Programmers Reference"

It has a Visual C++ Tutorial based on the PUBS database.

At the server end, try and make as many of your required queries Stored Procedures. This helps by making your business logic more visible and easily modified without recompilation, plus SQL Server can optimise the query each time it is used.

If you hand craft your queries inside your RecordSet objects, your SQL code is "buried" plus it cannot be optimised in the same way as each call is treated as a first time by SQL Server.

Don't forget to put try/catch handling around everything.

On the exported COM intrerface side,  define your object as a Full Control if you want to allow callback event notification into a window message pump. This makes it a new control in your Visual Studio palette that can be drawn on forms. If you do not need the notifications with this setup,  you can still invoke the object standalone. So it has more uses to other programmers.

Otherwise keep it a simple control and add the interfaces as and when you need them.

regards
Colin
0
 
LVL 1

Accepted Solution

by:
kdkd earned 100 total points
ID: 2848928
Just use OLE-DB-Consumer Template provided with the ATL-Object Wizard in VC6. There you can access DBs like SQL-Server and set your Sql-Statements or Queries and youll get a fully workable fast com-wrapper for your task!!!
Really cool! Never been so easy! ADO is better for VB - Programmers
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question