Re: CDynamicAccessor and database row number problem
On 30 May 2007 09:27:21 -0700, krawiec83@gmail.com wrote:
Snippet looks like that:
Even if the main problem is the while loop condition, you might also
consider the following notes, if you want:
CString path = "D:\\temp\\dbase.mdb";
Better decorating the string with _T(""):
CString path = _T("D:\\...");
So, it will compile in both Ansi and Unicode builds.
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;
}
You may want to simplify a bit your code, like this:
if ( FAILED( hr ) )
{
// Error
AfxMessageBox( _T("Error ...explain..."), MB_ICONEXCLAMATION );
// Your error flag
err = TRUE;
}
You might also want to load the error string from string table in
resources, using an ID for the error string (this will make
localization easier); see AfxMessageBox description for more info.
IMHO, it is more clear than
if ( SUCCEEDED( hr ) ) ;
else
{
...
}
float *tabflend;
tabflend = new float[cmd.GetColumnCount()-1];
You might consider std::valarray<float> or std::vector<float> here,
insted of the C++ operator new[].
std::vector< float > tabflend();
tabflend.resize( cmd.GetColumnCount() - 1 );
In this way, you won't need the "delete [] tabflend;" (you may forget
to delete[] in more complex code).
HTH
MrAsm