By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,369 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,369 IT Pros & Developers. It's quick & easy.

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

P: n/a
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\Int erop.MSDASC.dll Microsoft OLE DB Service Component 1.0 Type Library
ADODB = C:\Program Files\Microsoft.NET\Primary Interop Assemblies\adodb.dll
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Burton Wilkins wrote:
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
invaluable in these cases. Just type "ildasm <assemblyname>" to get a look
at the internals of the 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!

--
Brandon Bray Visual C++ Compiler
This posting is provided AS IS with no warranties, and confers no rights.
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.