Note: The following is relevant to the French edition of Sage Line 100 software. It may be applicable to other version, but bear in mind that not all country have the same software on offer and that Sage heavily localise their software.

Sage offers an ODBC driver to connect to their proprietary databases. Here we talk about using the supplied ActiveX performing advanced functions in a .Net C# application.

A connection to the ODBC data source must be made prior to using the advanced functions provided by the ActiveX.

Using the ActiveX DLL in C#

An assembly of the ActiveX dll must be created before it can be used in a .Net program.

After installing the Sage Ligne 100 ODBC Kit and the .Net 1.1 SDK, use the library converter:

cd "C:\Program Files\Microsoft.NET\SDK\v1.1\Bin"
tlbimp %WINDIR%\system32\ASD100.dll /out:%WINDIR%\system32\ASD100lib.dll

Test the newly created assembly with:

Ildasm %WINDIR%\system32\ASD100Lib.dll

The library can then be added to the C# project as a normal assembly. See the links below for details.

Connecting to the database via ODBC

To use any of the complex routines from the ASD100.dll, you must be connected to the database.

Create a System DSN connecting to the Gescom files (not a User DSN as it is only visible when that particular user is logged on. A System DSN is always available).

As an example, here we connect to the ODBC database, then calculate the net turnover of a particular article referenced 1402.CV15:

private void button1_Click(object sender, System.EventArgs e)
        OdbcConnection myConnection = new OdbcConnection("DSN=hairdiff;UID=renaud;PWD=");
        try {
                ASD100Lib.CialClass gc = new ASD100Lib.CialClass();
                double result = gc.get_ArtCAHTNet("1402.CV15", "", "",
                DateTime.Parse("1/1/2000 0:0:1"),
                DateTime.Now, 0, 255);
                MessageBox.Show("Result : " + result.ToString());
        } catch(Exception ex) {
                MessageBox.Show("Unexpected COM exception: " + ex.Message);


Design by N.Design Studio, adapted by (version 1.0.0)
Powered by pmwiki-2.2.0-beta65