0

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.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
SoftWar
  • 63
  • 1
  • 7
  • Not that I'm aware of. `SQLDriverConnect` uses ODBC drivers, but `SqlConenction` is an entirely different driver. Why would you want to do this anyway? – Charlieface Jul 13 '22 at 09:24
  • @charlieface it is a part of work, moving code from C# to C++ to have a dll that can not be decompiled, thanks... – SoftWar Jul 13 '22 at 09:45
  • 1
    knowing now that "C++ to have a DLL that can not be decompiled" was an idea which is mistake... – SoftWar Aug 18 '23 at 09:14
  • 1
    No idea what you're trying to do, but trying to avoid decompilation is an exercise in futility – Charlieface Aug 18 '23 at 11:39

0 Answers0