Solved

Ado Big Problem

Posted on 2004-10-14
3
286 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

705 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