Solved

Ado Big Problem

Posted on 2004-10-14
3
282 Views
Last Modified: 2013-12-03
Hello experts....

I have a problem.

The project is in C++ (#import "msado15.dll... etc)

Everything works rather well...
The connection to an Access database works fine.

I create a recordset by calling the Execute method of the connection object.
The command is valid ("select col1, colb from anytable where condition")
After that, I start to scan the recordset by
char *str = (char*)pRecordset->Fields->GetItem("Col1")->Value;
pRecordset->MoveNext ();

The problem is that in some minor cases, I get garbage in the variable str.

I tested reading twice the value and check if the method fails in some minor cases.
That was not the problem, no mather how many times i call.
str = (char*)pRecordset->Fields->GetItem("Col1")->Value;
I suspect that the DB Engine is returning that garbage. (in this case Access)

If some one can help me about this.... I will apretiate it.





0
Comment
Question by:Marsc
3 Comments
 
LVL 6

Accepted Solution

by:
WxW earned 250 total points
ID: 12312116
AS far as I can remember, ADOFields :: get_Item creates the VARIANT itself, and it does not return a char* .

I used this code, it may help:

         for(int i = 0 ; i < RecordCount ; i++)
               {
            ADOField* aF = 0;
            VARIANT vt;
            vt.vt= VT_I4;
            vt.intVal = i;

               aFS->get_Item(vt,&aF);
            if (!aF)
                  continue;

               wchar_t* Name = 0;
            aF->get_Name(&Name);

               VARIANT Value = {0};
            aF->get_Value(&Value);

         // Now use these 'Name' and 'Value'

}....
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now