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
Solved

Creating a COM object that speaks  to the database

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
isEverywhere  challenge 19 82
Changing the installation path of this MSI 5 107
WPF issue with Trigger 2 114
Recommendation vb6 to vb.net or others 14 175
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…

856 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