Skip to Content.
Sympa Menu

freetds - [freetds] Removal of trailing spaces by FreeTDS

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Simon Talbot" <simont AT nse.co.uk>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Removal of trailing spaces by FreeTDS
  • Date: Fri, 14 Nov 2003 13:16:36 -0000

Hi All,

I have observed the following with both the stable and the dev version
of FreeTDS.

Communicating with a Win2000 SQL Server 2000 from FreeTDS on Linux
2.4.22, using code like:

DBCHAR P_TEXT[6000];

...

Connect and issue query etc.

...

dbresults(dbconn);

dbbind(dbconn, 4, NTBSTRINGBIND, 0, (BYTE *)&P_TEXT);

/* Loop thru the result set */
while (dbnextrow(dbconn) != NO_MORE_ROWS)
{
printf("Text:%s:\n",P_TEXT)
}

...

Close database connection etc.


The column that the dbbind is binding to is of type varchar(6000).

Data is returned correctly apart from the following:

If the last character of the VARCHAR data is a space (0x20) this last
character is not returned into P_TEXT. If the last character is anything
else there is not a problem.

For example if the field conatined (note ' marks are for illustration
only, they are not in the actual field data):

'!20 michigan mini cooper , volvo ' -- P_TEXT would incorrectly contain
'!20 michigan mini cooper , volvo'

Whereas if the field conatined:

'!20 michigan mini cooper , volvo :' -- P_TEXT would correctly contain
'!20 michigan mini cooper , volvo :'


Thoughts ?

Simon

Simon Talbot MEng, ACGI
(Chief Engineer)
Net Solutions Europe Limited





Archive powered by MHonArc 2.6.24.

Top of Page