Solved

Creating a COM object that speaks  to the database

Posted on 2000-05-08
2
166 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now