The following snippet reads the fields "SomeText" and "SomeNumber" from the
query "SomeQuery" in a file db4.mdb. You can use the other functions of
CDaoRecordset (MoveNext() and IsEOF()) to iterate through all of the rows.
You'll have to pull apart the COleVariant structures to get the useful data
out of them. You can use a CDaoTableDef it is just a plain table and not a
query.
#include <afxdao.h>
void foo() {
CDaoDatabase DB;
DB.Open("db4.mdb");
CDaoQueryDef TD(&DB);
TD.Open("SomeQuery");
CDaoRecordset RS(&DB);
RS.Open(&TD);
RS.MoveFirst();
COleVariant U, V;
U= RS.GetFieldValue("SomeText");
V= RS.GetFieldValue("SomeNumber");
Quote:
}
The following snippet stuffs values into a list box. The variable m_List1
is of type CListBox and was creating using the Class Wizard in my example.
void bar() {
m_List1.AddString("Foo");
m_List1.AddString("Bar");
m_List1.AddString("Hag");
Quote:
}
>All,
>I am working on a DialogBox app that get the information from a .mdb file
>and put the info in a list view. All I want to do is Open the file, get
the
>info and and put it in a list control then close the file. I can open and
>close the file(thats easy) but I cannot get any info out of it. It might
>be easier with VB, but I am not that good with it and I would rather do it
>with VC++ 5.0. If any one has a sample that does something like that I
>would love to see the code. Thanks in advance...