?
Solved

Creating a COM object that speaks  to the database

Posted on 2000-05-08
2
Medium Priority
?
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…

741 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