
Right click M圜onnection in the Solution Explorer and select Build from the menu. Note: If you are developing for 64-bit Office then make sure you change the Platform Target on the Build menu to 圆4! This is mandatory for 64-bit Office COM libraries to avoid any ActiveX related errors. Right click M圜onnection in the Solution Explorer and select Properties.Ĭlick the Application tab on the left side, then Assembly Info and tick Make Assembly COM-VisibleĬlick the *Build* from the menu on the left and tick Register For COM Interop Replace the GUIDs with your own and remove the curly braces so they are in the same format as the ones you see now from the copied code Note: if you are unsure about the connection string you should use see ALL CONNECTION STRINGSĬlick on TOOLs in Visual Studio and CREATE GUID
#UNISAW PARTS UPDATE#
Locate the cnStr variable in the code and UPDATE your connection string details. Private string cnStr = "Provider=SQLOLEDB Data Source=SERVER\DB Initial Catalog=default_catalog User ID=username Password=password Application Name=MyNetConnection" Public class ServerConnection : INetConnection, IDisposable [InterfaceType(ComInterfaceType.InterfaceIsDual), Type activeX in the search box and tick the Microsoft ActiveX Data Objects 6.1 LibraryĬopy and paste the below code into the ServerConnection.cs completely replacing whatever is in the file. Right click your M圜onnection project in the Solution Explorer and select Add Reference In the Solution Explorer, rename Class1.cs to ServerConnection.cs Select Visual C# then Class Library and rename it to M圜onnection Open it as Administrator and create a New Project.
#UNISAW PARTS INSTALL#
Dim cn as ADODB.Connectionĭownload and install Visual Studio Express for Windows ( FREE) Set cn = new ADODB.Connection you will use a GetConection() method exposed by your own library.

You will be connecting to the database using a VBA ADODB.Connection object but with a substituted object reference. Your own COM library would return an ADODB.Connection object with a predefined connection string which seem to work in. The only way I can think of solving this at the moment it's to return an ADODB.Connection object from a COM C# library. It simply isn't being recognized when used within VBA. Ahh I see VBA connection string doesn't support the Application Name attribute.
