Solved

Calling Stored procedure from C++ or calling VB COM from C++

Posted on 2004-10-15
3
205 Views
Last Modified: 2010-05-18
Hi,

I am basically a VB programmer and I now have a task to write a C++ dll which will invoke a Stored procedure in MSQL server.

The SP takes username, ID, AFlag and Output message.

Assuming I am using the VC++ process for the first time can you provide me a code sample step by step.

I can easily write this in VB COM. Is it easy to call the COM compnent than writing this in VC++ (are there any disadvantages?)

Also all the input parameters Should be passed to the VC++ dll as a singel parameter with a ',' delimiter. I hope you will also tell how to parse.

500 points for a quick turn around with code samples

Thanks
0
Comment
Question by:praveen_ms
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 12321467
If you cann use MFC, you'll like the idea that there's even a class wizard for that task: http://www.codeproject.com/database/spcw.asp
0
 
LVL 2

Author Comment

by:praveen_ms
ID: 12321498
I need to create a win32 DLL

I have in stdAfx.h

struct XMLDataBuf
{
// enum XMLCharSet      charSet; //for Siebel v6.x/v7.0.x only (CR#12-E7SHOB)
   int                  nLength;
   void*                pData;
};

extern "C" int __declspec(dllexport) TestEAI(const XMLDataBuf* Value, XMLDataBuf* pReply);

and in my cpp
extern "C" int __declspec(dllexport) MyFunctionName( const XMLDataBuf* Value, XMLDataBuf* pReply)

So Now I need to parse const XMLDataBuf* Value that for ',' and call SP.

Thanks

0
 
LVL 2

Author Comment

by:praveen_ms
ID: 12321578
and in my cpp
extern "C" int __declspec(dllexport) MyFunctionName( const XMLDataBuf* Value, XMLDataBuf* pReply)

Should have been
and in my cpp
extern "C" int __declspec(dllexport) TestEAI( const XMLDataBuf* Value, XMLDataBuf* pReply)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

895 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

15 Experts available now in Live!

Get 1:1 Help Now