CDynamicAccessor and database row number problem
Hello
I'm in need of writing a code of getting data from Access database.
Everything works fine except that I have no idea how to get number of
rows (in while loop it goes just forever).
Snippet looks like that:
CLSID clsid = {0xdee35070L,0x506b,0x11cf,
{0xb1,0xaa,0x0,0xaa,0x0,0xb8,0xde,
0x95}}; //Microsoft.Jet.OLEDB.4.0
CDataSource ds;
CSession session;
HRESULT hr;
BOOLEAN err = FALSE;
CString path = "D:\\temp\\dbase.mdb";
hr=ds.Open(clsid,path,NULL,NULL,DB_MODE_SHARE_EXCLUSIVE);
if(SUCCEEDED(hr)) ;
else
{
MessageBox(::GetActiveWindow(),L"Error",L"Error",MB_ICONEXCLAMATION);
err = TRUE;
}
hr=session.Open(ds);
if(SUCCEEDED(hr)) ;
else
{
MessageBox(::GetActiveWindow(),L"Error",L"Error",MB_ICONEXCLAMATION);
err = TRUE;
}
if (err == FALSE)
{
CCommand<CDynamicAccessor> cmd;
CString query,n1;
int i=0;
query.Format(L"SELECT ....");
hr=cmd.Open(session,query,NULL,NULL,DBGUID_DBSQL,true);
float *tabflend;
tabflend = new float[cmd.GetColumnCount()-1];
int j=0;
cmd.MoveFirst();
while(SUCCEEDED(hr))
{
float *ikkk,*ikk;
//acutPrintf(L"\n%d: ",j+1);
for (i=2;i<=cmd.GetColumnCount();i++)
{
ikkk=static_cast<float
*>(cmd.GetValue(i)); //all values are float-type
//CString temp;
//temp.Format(L"%f",*ikkk);
//acutPrintf(L" %s ",temp);
}
j++;
if (j > 351) break; //There are 352
rows, but there is a possibility of more
hr=cmd.MoveNext(); //even if it is the
last row it just takes another one (actually the same as last one
used)
}
cmd.Close();
session.Close();
ds.Close();
delete [] tabflend;
}