A
A
Alexey Gorshkov2014-02-17 17:02:58
C++ / C#
Alexey Gorshkov, 2014-02-17 17:02:58

How can I check the connection to the MS SQL database in C++ code?

DB: Microsoft SQL of any version.
Preferably the easiest way (in terms of, without connecting third-party libraries).
You just need to check the connectivity.
You can't use the .Net Framework in the job, and MFC is highly discouraged.
Project in Visual Studio 2008 Professional
Found one way:

CDatabase * db = new CDatabase ();
if (!db->OpenEx (args [2], CDatabase::noOdbcDialog))
{
  printf ("Не удалось соединиться с БД\n");
  ExitProcess (1);
}
db->Close();

it doesn't quite fit as it requires Redistributable to be installed.
Preferably WinAPI.
Thank you for your attention.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DancingOnWater, 2014-02-19
@DancingOnWater

As the name clearly implies, WinAPI is an API to Windows functions and nothing more. Operation from a DB is operation from a DB and does not concern Windows in any way. If you don't want to use MFC, then look at Qt, if you don't want to, then choose from the list: rsdn.ru/poll/1822 or search in Google

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question