Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Creating a COM object that speaks  to the database

Posted on 2000-05-08
2
Medium Priority
?
179 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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…

610 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