Hello! Hello! Is anybody there! I really could use some help on 2 line so code? How about it.

B

Burton Wilkins

Dear Associaties:

I asked this question last Friday, and here it is Wednesday and NOBODY has replied. Come on. Help a little. All that I am looking for is 2 lines of code. One of you must know how to do this. Please respond.

I'm trying to get the DataLink to work under C++, and I need help. I'm able to make it work under VB and C#, but not C++. Under C# (with references to "adodb", and "MSDASC") , I would accomplish this by the following code:

ADODB._Connection cn; //Define ADO Connection.

MSDASC.DataLinks dataLink = new MSDASC.DataLinks():
cn = (ADODB._Connection) dataLink.PromptNew();

Under C++, I would expect some like this:

#using <adodb.dll> //Both using had to be "Resolve #using References" under the Property Pages C/C++.
#using <Interop.MSDASC.dll> //... because MSDASC alone fails, even though I resolved under the Property Pages.

ADODB::Connection* cn; //This line compiles OK, so long as the resolves have been done.

MSDASC::DataLinks* dataLink = new MSDASC::DataLinks(); //FAILS:Error C2061:Syntax error: identifier DataLinks
cn = (ADODB::Connection) dataLink->PromptNew() //Can't get this far because the previous line fails. I'm just guessing at this point.

I go to MSDN, and there is no definition for Error C2061, so I am faces with a mystery. I realize that this is Unmanage code, but certain there must be a way to call up the DataLink from .Net C++. Would someone please advise how I can get around this problem.

Sincerely,

Burton G. Wilkins, Programmer.

P.S: The libraries I am using are these:
MSDASC = c:\Program Files\Word\Samples\C++\AccessMaintenance\Debug\Interop.MSDASC.dll Microsoft OLE DB Service Component 1.0 Type Library
ADODB = C:\Program Files\Microsoft.NET\Primary Interop Assemblies\adodb.dll
 
B

Brandon Bray [MSFT]

Burton said:
I'm trying to get the DataLink to work under C++, and I need help. I'm
able to make it work under VB and C#, but not C++. Under C# (with
references to "adodb", and "MSDASC") , I would accomplish this by the
following code:

[SNIP]

Hi Burton, I was able to get the following code to compile:

#using <mscorlib.dll>
#using <adodb.dll>
#using <MSDASC.dll>

int main() {
ADODB::Connection* cn;

MSDASC::DataLinks* dataLink = new MSDASC::DataLinksClass();
cn = __try_cast<ADODB::Connection*>(dataLink->PromptNew());
}

The problem was likely with "DataLinks" vs. "DataLinksClass". The assembly
tlbimp generates creates the interfaces with the natural name and the
classes with the name and "Class" as a suffix. I often find the ildasm tool
//FAILS:Error C2061:Syntax error: identifier DataLinks
I go to MSDN, and there is no definition for Error C2061, so I am faces with
a mystery.

I'm not sure why you didn't find C2061 on MSDN. Basically, the compiler
didn't understand the identifier DataLinks. I was not able to get the same
error message -- I tried two different versions of the C++ compiler. The
VC7.1 compiler gave a helpful diagnostic that should have led to the
solution I described above.
I realize that this is Unmanage code, but certain there must be a way to
call up the DataLink from .Net C++. Would someone please advise how I can
get around this problem.

Hopefully, this will help you get past where you're stuck. Good luck.

Cheerio!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top