473,395 Members | 1,977 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,395 software developers and data experts.

Only first digit returned to VC++

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
1 1825
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: D.M | last post by:
Hye, I have a form with 8 telephone number fields. I want to take only first two numbers and make a new field called network group. Please can you help me? Thanks
1
by: J Jungeblut | last post by:
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++...
8
by: Jared.Holsopple | last post by:
Hi all, I have a dynamically allocated array of doubles in VC++ .NET. When I view the array in the watch window with "arrayName, 10", it displays the correct value for arrayName, but arrayName...
2
by: BurtonBach | last post by:
I have tried to research this and I'm worried the answer is already in this forum and I just didn't search under the correct word. However, I'm wanting to sort a table of job numbers while...
3
by: gigs68 | last post by:
What script would I need to write (vb.net) to validate a credit card number's length and first digit input to a text box (i.e., Visa Length=16 digits, first digit starts with a 4)? Thanks Bryan
3
by: yikes123 | last post by:
I have a simple program Set Textbox5= myPage1.Controls("Textbox5") Set Textbox7= myPage1.Controls("Textbox7") if Textbox5.value > Textbox7.value then msgbox("cheater cheater cheater") elseif...
2
by: penguinbob31 | last post by:
I'm writing a program that is supposed to take the first digit of every number in a list of numbers and count how many times each first digit appears. I can't seem to get the program to work...
4
by: Dustin | last post by:
Hi Everyone! First post here! I am working with a test report, using Report Builder 2.0 in an SQL environment with server 2008 R2 with SSRS installed. I have a data source and dataset set up...
2
by: deshaipet | last post by:
Hi Folks, I would like to update only first 1000 rows of a table. Can anyone help me with the SQL ? Thanks, Panditt
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.