Reputation: 21
I am writing a C++ app for Windows Server 2008, and I need a driver/library to connect to SQL Server 2008 to run select queries. The app resides on the same computer as SQL Server. Which driver should I use?
EDIT:
If I were to have the app run on a separate computer (say, on the same VLAN as the computer running SQL Server), which driver should I use?
Upvotes: 2
Views: 1438
Reputation: 393114
Well, I'm gonna chip in with my own answer.
I agree the point is mostly moot because the database performance is going to swamp any performance difference on the library side. Also, if you are running the database server over TCP/IP the network transmission speed/latency is going to dominate the charts.
Of course the further processing may benefit in the usual ways from being written in a high-performance capable language.
That said, ADO is going to be the most featurefull.
However if you are really going for raw speed, e.g. only streaming moderate-to-large blobs to/from a table you'll find the best performance in going directly to the TDS protocol.
The TDS++ library will be a good starting point.
More info:
Upvotes: 1
Reputation: 61378
If you're asking which SQL Server access method is fastest to implement in C++, I'd say - ADO via native COM. You go about it thus:
#import "libid:{EF53050B-882E-4776-B643-EDA472E8E3F2}" rename("EOF", "ADOEOF")
//...
ADODB::_ConnectionPtr MyConn;
MyConn.CreateInstance(__uuidof(ADODB::Connection));
//Connect to the database
MyConn->Open(L"Provider=SQLOLEDB;Server=myserver;Database=mydb;Trusted_Connection=Yes", 0, 0, 0);
//Run a query
ADODB::_RecordsetPtr MyRecset(MyConn->Execute(L"select * from t", &_variant_t(), adCmdText));
Upvotes: 1
Reputation: 103597
the largest performance impact will be the database and so much the application. If the database is starved for memory, disk IO, or cpu or the queries are poorly written or have a bad table design, it won't really matter which language your application is written in. I've seen terribly written applications, with loads of inefficiencies just zip when the database was written/performs well. As soon as the database has a hiccup, watch out! even a 3 second query seems like forever to an application's end user.
Upvotes: 1