By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,637 Members | 1,967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,637 IT Pros & Developers. It's quick & easy.

Only first digit returned to VC++

P: n/a
Hi!
I have an Access 97 Database which I have to read from with C++.
All the text-fields are returned to c++ completely, but when a field
contains a number greater than 9 the return value to c++ is just the
first digit of that number.
With an Access 95 Database, it seems to work correctly, but I can't
use one in this case.

This is the Code I use:

CDaoRecordset rs;
//I have left out some irrelevant initializations
rs.Open(AFX_DAO_USE_DEFAULT_TYPE, "select * from TSW", NULL);

COleVariant olevar;
CString strData;

while (!rs.IsEOF()) {
rs.GetFieldValue("Distance",olevar);
olevar.ChangeType(VT_BSTR, NULL);
strData = (LPCSTR)olevar.pbstrVal;
cout << (const TCHAR*)strData << endl;
rs.MoveNext();
}
Please help!!

Thank You very much!
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I don't know much about VC++, but it sounds like an ODBC driver issue or a
data type issue. In looking at your code, it looks like you are using
variant data types, but I am not sure. What is the data type of the field
in the access database?

"J Jungeblut" <ju******@familie-schindler.com> wrote in message
news:ea**************************@posting.google.c om...
Hi!
I have an Access 97 Database which I have to read from with C++.
All the text-fields are returned to c++ completely, but when a field
contains a number greater than 9 the return value to c++ is just the
first digit of that number.
With an Access 95 Database, it seems to work correctly, but I can't
use one in this case.

This is the Code I use:

CDaoRecordset rs;
//I have left out some irrelevant initializations
rs.Open(AFX_DAO_USE_DEFAULT_TYPE, "select * from TSW", NULL);

COleVariant olevar;
CString strData;

while (!rs.IsEOF()) {
rs.GetFieldValue("Distance",olevar);
olevar.ChangeType(VT_BSTR, NULL);
strData = (LPCSTR)olevar.pbstrVal;
cout << (const TCHAR*)strData << endl;
rs.MoveNext();
}
Please help!!

Thank You very much!

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.