Thursday, 8 March 2012

Connect / use SQL server in C/C++?

I would like to know what is the most basic (I don't mean easy) way to connect and use an SQL (and/or Oracle...) database using C/C++, can anyone point me in a direction please? I simply cannot find any sort of API on the internet!

Don't database providers other than mySQL want people programming apps that access them?

Thanks in advance!!

The three ways to talk to a database using C/C++ are ODBC, OLEDB and ADO (the last is much more commonly done from VB and ASP than from C++).

If you're comfortable with programming ATL, OLEDB is probably the way to go (less code to write than ODBC).

Microsoft ships two implementations of both OLEDB and ODBC. If you intend to write an app that talks to SQL Server only, you'll want to use the SQL Native Client implementations (there will contain additional features and bugfixes vs. MDAC). You can find details about programming SQL Native Client here:

http://msdn2.microsoft.com/en-us/library/ms130904(SQL.90).aspx

If you need the flexibility of communicating with data sources other than SQL server, the MDAC implementations will allow you to do that. You can find details about OLEDB here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/oledb/htm/dasdkoledboverview.asp

and ODBC here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/dasdkodbcoverview.asp

Hope this helps!

--John

No comments:

Post a Comment