vimsh / db_conn Goto Github PK
View Code? Open in Web Editor NEWGeneric C++ database API wrapper of native drivers (Sybase CTlib, SQLite drivers implemented)
Home Page: http://vimsh.github.io/db_conn/
Generic C++ database API wrapper of native drivers (Sybase CTlib, SQLite drivers implemented)
Home Page: http://vimsh.github.io/db_conn/
This is a very good cpp api for sybase, it works well in single cpp file, but when i include "sybase_driver.hpp" into a header file 'a.h', and an other file include the file 'a.h'。When complie&link the project, a link error has occurred:
It seems to point to the end of the file sybase_driver.hpp:
dbi::istatement* connection::get_statement(dbi::iconnection& iconn)
{
return new statement(dynamic_cast<connection&>(iconn));
}
I separate this function from the file to a .cpp file, and then add all this files to project.
This can solve the link error.
When i fetch a little amount of data, the strings returned are correct. But when the volume of records increases, most of the data(datatype CS_CHAR_TYPE) behind is incorrect: correct string followed by garbled.
I'm not familiar with Sybase APIs, and made some changes in sybase_driver.hpp.
1, below the function 'ct_describe' about line 620, I add this:
if (columns[i].datatype == CS_CHAR_TYPE) { columns[i].format = CS_FMT_PADNULL; }
2, comments 2 lines at line 196:
//if (CS_ROW_FAIL == retcode)
// throw std::runtime_error(std::string(FUNCTION).append(": Error fetching row ").append(std::to_string(result)));
3, In function "void process_result(bool compute, bool bind)" about line 645, add 3 lines:
if (columns[i].datatype == CS_CHAR_TYPE)
columndata[i].allocate(columns[i].maxlength + 2);
else
columndata[i].allocate(columns[i].maxlength);
4, Commented on the associated exception about line 710
After 4 steps, it works in debug mode(crashed in release mode), but still throw exceptions in callback functions, so i comment cs_msg_callback, ct_msg_callback and srv_msg_callback in the constructor of driver.
While this can get the right results, I'm not sure it's the right approach, and are there other better ways to fix it?
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.