Solved

Ado Big Problem

Posted on 2004-10-14
3
281 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

9 Experts available now in Live!

Get 1:1 Help Now