473,320 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

access varchar error

In my application,I use SQLBindCol to retrive the information, however
I found that in one table there is a varchar(10) column,
if the buffer size specified in the SQLBindCol is also ten,and the
buffer is ten length, then the result will be turned into 9.If the
buffer size specified as 11, then the result will be ok.
Does anyone explane for this?

Nov 12 '05 #1
5 1172
ja**********@yahoo.com.cn wrote:
In my application,I use SQLBindCol to retrive the information, however
I found that in one table there is a varchar(10) column,
if the buffer size specified in the SQLBindCol is also ten,and the
buffer is ten length, then the result will be turned into 9.If the
buffer size specified as 11, then the result will be ok.
Does anyone explane for this?


The issue lies in the handling of strings in the C programming language. A
string is terminated by a trailing '\0' (= 0x00) byte to denote the end.
If you provide a buffer of 10 bytes, then only 9 bytes are available for
the actual data and the last byte is needed for the termination character.
That's a standard C/C++ thing, which needs to be solved by using buffers
that have (at least) one more byte than is needed for the real data.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #2

Knut Stolze wrote:
The issue lies in the handling of strings in the C programming language. A
string is terminated by a trailing '\0' (= 0x00) byte to denote the end.
If you provide a buffer of 10 bytes, then only 9 bytes are available for
the actual data and the last byte is needed for the termination character.
That's a standard C/C++ thing, which needs to be solved by using buffers
that have (at least) one more byte than is needed for the real data.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany


sorry,I don't think so.In fact I have considered that.In my
application,I allocate 11 bypes but I specify the length as 10 in the
function then the problem happen. And for the oracle, almost the same
function works well.
Does this mean I have to specify the parameter one more than the length
in the database?

Nov 12 '05 #3
jacky shi wrote:

Knut Stolze wrote:
The issue lies in the handling of strings in the C programming language.
A string is terminated by a trailing '\0' (= 0x00) byte to denote the
end. If you provide a buffer of 10 bytes, then only 9 bytes are available
for the actual data and the last byte is needed for the termination
character. That's a standard C/C++ thing, which needs to be solved by
using buffers that have (at least) one more byte than is needed for the
real data.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
sorry,I don't think so.In fact I have considered that.In my
application,I allocate 11 bypes but I specify the length as 10 in the
function then the problem happen.


How should DB2 know how much space you allocated unless you tell it so? You
say that there are 10 bytes, so DB2 has 9 bytes for data and 1 byte for the
termination character.
And for the oracle, almost the same
function works well.
Does this mean I have to specify the parameter one more than the length
in the database?


Yes, the documentation for SQLBindCol() says so:

Note that for character data, the driver _counts_ the NULL termination
character and so space must be allocated for it.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #4
Thank you very much. I have read the document of the api, however,
there isn't any thing refering that. Would you please tell me which
documentation you refered?

Nov 12 '05 #5
jacky shi wrote:
Thank you very much. I have read the document of the api, however,
there isn't any thing refering that. Would you please tell me which
documentation you refered?


Did you try searchable online documentation available at:

http://publib.boulder.ibm.com/infoce...help/index.jsp

Specifically, for SQLBindCol() call you will find:

"Note that for character data, the driver counts the NULL termination character
and so space must be allocated for it."
Jan M. Nelken
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: photoelectric | last post by:
When trying to run the below script on an apache/1.3.26 with mysql and php I get the following error message: Warning: mysql_connect() : Access denied for user: 'nobody@software-ece.rutgers.edu'...
0
by: ImraneA | last post by:
Hi there I had pleasure of upsizing Access v97 db to Access v2K/SQL 2K. Wish to provide some knowledge gained back to community - hopefully help others. 1.Question how do you test stored...
1
by: 2BaCook | last post by:
Hi, I have an Access database that I am creating a java front end to. I am trying to insert a record into a table and get a problem whenever I try to insert into my "Number" column. Here is my...
1
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this...
1
by: bonnie.tangyn | last post by:
Hello all I get Too few parameters expected 2 error and "The MS Jet Database engine cannot find the input table or query "myTempTablename". Make sure it exists and that its name is spelled...
22
by: TC | last post by:
I have an Access database application with a lot of custom row functions written in VBA. In other words, a lot of queries contain calculated fields which use functions defined in the modules. I...
3
by: Hutty | last post by:
I'm trying create a calendar control that updates an access database with events. I have some code I managed to piece together. First error I'm running into is the Mycommand.ExecuteNonQuery(). I...
8
by: Yitzak | last post by:
Hi is there a way to run a SQL Script to Update an Access Schema. Without using VBA code. E.g. in mssql server I can run script like if not exists (select * from syscolumns where name =...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
1
by: sahashra | last post by:
I am trying to insert values into the table using the values from the form I following is the code I am using protected void Button_Click(object sender, EventArgs e) { SqlConnection conn...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.