[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

Ado Big Problem

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
Marsc
Asked:
Marsc
1 Solution
 
WxWCommented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now