Using C++ SQLDriverConnect Connection Handle in C# as SqlConnection

101 Views Asked by At

Below code is used for SQL Connection in C++:

SQLDriverConnect(hdbc,    /* Connection handle */
    0,                     /* Window handle */
    connectString,         /* Connection string */
    SQL_NTS,               /* This is a null-terminated string */
    (SQLWCHAR*)NULL,       /* Output (result) connection string */
    SQL_NTS,               /* This is a null-terminated string */
    0,                     /* Length of output connect string */
    SQL_DRIVER_NOPROMPT); /* Don’t display a prompt window */

And the class below is used in C# as Data Class for SQL Connection:

SqlConnection sqlCon;

Is there any way (conversion method) to use hdbc as sqlCon in C# Code? I know we can use DllImport for these kind of conversions to use C++ methods in C#, but do not know is it possible also for an SQLConnection class.

0

There are 0 best solutions below