[freetds] C++ version of http://www.freetds.org/userguide/samplecode.htm

Eric Prud'hommeaux eric+ibiblio at w3.org
Sun Jun 22 08:40:30 EDT 2014


(resent of an attempt 12 March 2014)

I wanted a wrapper which manage concurrent connections and provide a
vanilla interface like:

    MSSQL::Result r = sql.executeQuery(argv[i], &qeh);
    for (MSSQL::Result::iterator row = r.begin(); row != r.end(); ++row) {
        for (MSSQL::Values::const_iterator col = row->begin(); col != row->end(); ++col)
            std::cout << std::setw(col->size()) << col->lexical() << ' ';
        std::cout << "\n";
    }

I didn't see one so I'm offering this to the community. main() (by
default) tests the concurrent access by executing all of the queries
on the command line at one and interleaving the results on the
console. This also fixes a small memory leak in samplecode.htm in that
it calls dbloginfree(login) after dbopen().

I preserved the (1)(2)... comments from samplecode.htm in case someone
with write access decides to make a parallel page for this version.
-- 
-ericP

office: +1.617.599.3509
mobile: +33.6.80.80.35.59

(eric at w3.org)
Feel free to forward this message to any list for any purpose other than
email address distribution.

There are subtle nuances encoded in font variation and clever layout
which can only be seen by printing this message on high-clay paper.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freetdsSample.cpp
Type: text/x-c++src
Size: 21409 bytes
Desc: not available
URL: <http://lists.ibiblio.org/pipermail/freetds/attachments/20140622/48d4c8da/attachment-0001.bin>


More information about the FreeTDS mailing list