Solved

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

Posted on 2004-10-15
3
193 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

771 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

12 Experts available now in Live!

Get 1:1 Help Now