January 31, 2003 at 10:44 am
I have a table with one column which is varchar(2000).
I'm writing a C++ programm which selects data from this table. To know the size of needed buffer for character data I call dbcolinfo() function. This function returns MaxLength=255 in DBCOL structure for the column data not 2000!
In MS documentation it is said:
"DB-Library applications and applications using the SQL Server ODBC drivers from SQL Server version 6.5 or earlier support only a maximum of 255 bytes of character data. If these applications attempt to retrieve character parameters of SQL Server version 7.0 or later, or result set columns containing more than 255 bytes of data, the character data is truncated at 255 bytes."
I have set DB-Library client behaviour to version 6.0 with DBSETLVERSION() function (If I do not call this function then default is 4.3 version behaviour.)
In MS documentation is is said:
"Using the DBVER60 value means that Microsoft® SQL Server™ 2000 treats the connection as a DB-Library 6.0 client in every way."
Does this mean that there is no way to set library behaviour to 7.0 or later (I have client library 8.0 installed) and varchar data truncation to 255 symbols will allways occur?
January 31, 2003 at 11:54 am
Can you post the relavent C++ I just cannot picuture the code as I have not used these options before.
February 3, 2003 at 5:06 am
Hi, thanx for the reply!
Table is created with statement:
create table test_big_text (description varchar(2000))
My C++ code goes like this:
...
DBCOL dbcol;
char *description;
char *stmt = " select description from test_big_text; ";
DBPROCESS *dbproc;
LOGINREC *login;
login = dblogin();
DBSETLUSER (login, "login");
DBSETLPWD (login, "password");
DBSETLVERSION(login, DBVER60);
dbproc = dbopen (login, "server");
dbuse (dbproc, "database");
dbcmd(dbproc, stmt);
dbsqlexec(dbproc);
dbcol.SizeOfStruct = sizeof(DBCOL);
if (dbresults(dbproc) == SUCCEED && dbcolinfo(dbproc, CI_REGULAR, 1, 0, &dbcol) == SUCCEED) {
description = (char*) malloc(dbcol.MaxLength);
// dbcol.MaxLength is 255, should be 2000
dbbind (dbproc, 1, NTBSTRINGBIND, 0, description);
while (dbnextrow(dbproc) != NO_MORE_ROWS)
printf ("%s\n", description);
free(description);
}
dbexit();
...
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply