Search code examples
c++sql-serverconsole-applicationborland-c++

How to connect from c++ console program to MS SQL SERVER


I made a simple c++ console program with Borland c 3.1, and I want to connect to sql server to manipulate data in the data base.


Solution

  • Old vanilla way is to create ODBC driver using the Windows control panel. After that you use ODBC library in your application. The idea of this approach is that you specify all information about your server in the control panel and in you app you specify just the name of the driver and nothing else.

    I used this approach and it worked as described in MSDN. The code is not short at all.

    There is a better way when you specify everything in your app. I had sample code that uses these undocumented features. It was long ago. I am not sure I can find this code now.