Could I have some help wiht the DataLink: Brandon Bray

  • Thread starter Thread starter Burton Wilkins
  • Start date Start date
B

Burton Wilkins

Dear Brandon:

You sent me some advice before as to how get the DataLink working, but I haven't been able to get your solution to compile:

You sent me this:
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".
You then went on to advise the use of "Ildasm", but honestly I couldn't get that to work.

Here are my issues. First you suggest that I use "#using <MSDASC.dll>. When I use
this I get the error "Fatal error C1107: could not find assembly "MSDASC.dll"; please
specify the assembly search path using /AI or by setting the LIBPATH environment
variable.

The fact is, there appears to be no such DLL as MSDASC.dll. When I copy in your code
exactly as you sent it to me, then on the Solution Explorer I go to References, and add a
reference on the COM tab to the "Microsoft OLE DB Service Component 1.0 Type Library"
whose source is "C:\Program Files\Common Files\System\OLE DB\oledb32.dll", not
"MSDASC.DLL". The reference that appears then on the Solution Explorer Reference is in
fact MSDASC, but then when I look up the Properties Page for this reference I find that
the "Output Name" is $(OutDir)\Interop.MSDASC.dll.

So the only way I can use "MSDASC.dll" in a using statement is as:
#using <Interop.MSDASC.dll>, not <MSDASC.dll> as you suggested. Now, is this OK
or am I missing a MSDASC.dll on my computer to reference.

Having used "Interop.MSDASC.dll" in the using statement, as in the following code:

#include "stdafx.h"
#using <mscorlib.dll>
#using <C:\Program Files\Microsoft.Net\Primary Interop Assemblies\adodb.dll>
#using <Interop.MSDASC.dll> //C:\Program Files\Common Files\System\OLE DB\oledb32.dll

using namespace System;

int _tmain()

{
ADODB::Connection* cn;

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

}

When I then compile my code I get these errors:

Error C2061: Syntax error: Identifies "DataLinksClass".
Error C2065: "datalink": undeclared identifier.
Error C2065: "DataLiniks": Undeclared idnetifies
Error C2227: left of '->PromptNew/' must point to class/struct/union type is"unknown-type"
Error C2653: "MSDASC": is not a class or namespace name
Error C2653: "MSDASC": is not a class or namespace name.
Error C3861: "dataLink": Identifies not found, ven with argument-dependent lookup.

You say that this code compiles for you. Well it certainly isn't compiling for me. I'm using .Net C++,
version 1.1. Is that what you are using?

The only way I can use "MSDASC.dll" in a using statement is as:
#using <Interop.MSDASC.dll>, not <MSDASC.dll> as you suggested. Now, is this OK
or am I missing a MSDASC.dll on my computer to reference? The "Oledb32.dll" from MSDASC is a
part of is version 2.70.9001.0. Is this DLL the proper version?

Sincerely,


Burton G. Wilkins
 
Burton said:
You sent me some advice before as to how get the DataLink working,
but I haven't been able to get your solution to compile:

Hi Burton,
I'm sorry that I did not see this sooner. Hopefully, you haven't been
completely blocked waiting for some help. :-)
So the only way I can use "MSDASC.dll" in a using statement is as:
#using <Interop.MSDASC.dll>, not <MSDASC.dll> as you suggested.
Now, is this OK or am I missing a MSDASC.dll on my computer to
reference.

Using "Interop.MSDASC.dll" is just fine. You just went about creating the
assembly in a different way than I did. I used the tlbimp tool on the
command-line, and you used the IDE to create the assembly from the
oledb32.dll type library. This shouldn't have any significant impact on the
result, other than the types may be in different namespaces.
You say that this code compiles for you. Well it certainly isn't
compiling for me. I'm using .Net C++, version 1.1. Is that what
you are using?

Try using the type "Interop::MSDASC::DataLinksClass". I bet the assembly was
generated such that everything was put in the Interop namespace.

Just to be sure, I would try opening "Interop.MSDASC.dll" in ildasm. If you
open the "Visual Studio Command Prompt" (it's on the start menu where Visual
Studio is), choose Open from the File menu. There, search for the assembly
"Interop.MSDASC.dll" and open it. This will give you a look inside that
assembly to see how it is structured.

I hope that helps get you going. Cheerio!
 
Back
Top