Skip to Content.
Sympa Menu

freetds - RE: [freetds] ODBC prepared statements to sybase 12.5 not working

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Alex Hornby <alex AT anvil.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] ODBC prepared statements to sybase 12.5 not working
  • Date: Thu, 07 Aug 2003 10:33:34 -0000

Heres the source inline... I couldn't see the attachment on the list for
some reason.

#include <string>
#include <memory>
#include <iostream>

#include <odbc++/drivermanager.h>
#include <odbc++/databasemetadata.h>
#include <odbc++/connection.h>
#include <odbc++/preparedstatement.h>
#include <odbc++/resultset.h>

using namespace std;

// test database prepares

int
main(int argc, char** argv)
{
if ( argc < 4 ) {
cerr << "Not enough arguments" << endl;
return 1;
}

try {

// Connect to DB
odbc::Connection* conn =
odbc::DriverManager::getConnection(argv[1], argv[2], argv[3]);

odbc::DatabaseMetaData* md = conn->getMetaData();
assert(md);
cerr << "Connected to "
<< md->getDatabaseProductName() << " "
<< md->getDatabaseProductVersion()
<< " using " << md->getDriverName() << " "
<< md->getDriverVersion() << " (ODBC Version "
<< md->getDriverMajorVersion() << "."
<< md->getDriverMinorVersion() << ")" << endl;

conn->setAutoCommit(0);

cerr << "creating statement" << endl;
auto_ptr<odbc::PreparedStatement> stmt(
conn->prepareStatement("select name from sysusers "
"where name like ?"));
cerr << "statement created" << endl;

for (int i = 1; i< 20; ++i) {
stmt->setString(1, "%role");

cerr << "getting result set" << endl;
auto_ptr<odbc::ResultSet> rs(stmt->executeQuery());
cerr << "got result set" << endl;
int count = 0;
while(rs->next()) {
std::string name = rs->getString(1);
count++;
}
cerr << "execute " << i << " got " << count << " rows" << endl;
}
} catch(const odbc::SQLException& ex) {
cerr << ex.getMessage() << endl;
return -1;
}

return 0;
}




On Thu, 2003-08-07 at 11:22, Alex Hornby wrote:
> >
> > Hi Alex.
> > This is very strange...
> > Could you send a code snip for reproducing the problem ?
> >
> > freddy77
>
> Heres a libodbc++ program that shows the problem - its looks like its
> statement option related.
>
> Its only requirement is libodbc++ 0.2.3 which you can pick up from:
>
> http://sourceforge.net/project/showfiles.php?group_id=19075
>
> To run it give DSN, user and password on the command line.
>
> Cheers,
> Alex.






Archive powered by MHonArc 2.6.24.

Top of Page