Not when dealing with JET databases, if your database code is limited to working with JET then DAO is much faster than ADO, you should use ADO if you are a VB developer or if your are a C++ developer and don't mind slow database access.
My work is mostly related to small to medium database. That would be about 100 records with about hundred fields. I use Jet database for all my work. Is that good enough? Or should I be using something else?
I did search for virtual lists, but from what I gathered, it looked like one cannot do many things with virtual lists - for example: sorting cannot be done.
This is not true. If you create a virtual list, you must handle the displaying of the data, and you can also handle the column click, call the requery function of the table and then invalidate the list control.
For example: Override the listviews column click virtual method...
Usually what I do is read data from the database and fill the list.
CDBcreate *p = new CDBcreate; // this is the class I have make to handle creating a database, adding tables, adding fields, getting value as double etc ...
CDaoDatabase *pdB=new CDaoDatabase();
CString TabNam = curTableName;
sql = ("SELECT * FROM "+TabNam+" WHERE param='budget' ORDER BY cat,payee");
rs = new CDaoRecordset(pdB);
CString strCategory, strPayee;
nCol = 2; ;
int nRow = 0;
m_XBudgetLIST_Main.DeleteAllItems(); // main list
m_XBudgetLIST_RowTotal.DeleteAllItems();// list on the side of main list to display row total values
nFeldCount = p->getFieldCount(pdB,strBudgetName);
while (!rs->IsEOF()) // looping through all the rows of the database
strCategory = p->GetAsString(rs,1);
strPayee = p->GetAsString(rs,2);
for ( int i = 3;i<nFeldCount;i++)// looping through the columns
strTp = pCol->SetValue(p->GetAsDouble(rs,i));
nCol = 2;
strRowTotal = pCol->SetValue(Payee_RowTotal(strCategory,strPayee));
When the number of colunms are too many, the time for the loop to be fully executed is looong.
Both lists should be virtual, this means that you must provide the information to be displayed as needed by the list control. There are lots of tuts on Code Project regarding virtual lists.
When you load the information from the DB, set the number of rows for each list useing the method I described in my last post. Keep a member variable of the DB, and an index of the current record, as an absolute value. When the list wnats to display a specific row, it will request the item value to be displayed, i.e. row 0, subitem 0, 1, 2, 3, etc. This you can do on the fly, reading the row from the DB, getting the corresponding sub item (field) and displaying it. I know this may seem slow, but it works a treat, as only the information that is to be ACTUALLY DISPLAYED is required.
As for your secondary list that is to display information, I would suggest that you create a query def using the information provided from the main table...
Who the f*** is General Failure, and why is he reading my harddisk?
Thanks a lot. So very kind of you to explain in such detail.
I shall change my program to use virtual lists. I am begining to understand them quite well now. I have been running away from it all this while. Lets see if I end up falling in love with virtual lists.
I have an application which reads a file of particular extension, say, *.abc.
When I run the application and invoke the CFileDialog to select a file of this extension, it opens the file correctly.
Similarly, Dragging and Dropping the file to the application also works fine.
But when I right-click on the .abc file and select Open With... and select my application.exe, the application comes up but it does not open the file.
the CFileDialog class doesn't open the file for you. it only provides you an interface (dialogBox) to pick the files you want to open, bu it only returns the absolute paths of these files. only then, when your application gets those files, it has the choice to actually opening them or not.
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value can be one of the following error codes.
- ERROR_ACCESS_DENIED The user does not have access to the requested information.
- NERR_InvalidComputer The computer name is invalid.
- NERR_UserNotFound The user name could not be found.
So the thing is I hard code the username and the servername is NULL (servername is NULL, the local computer is used.)
But still the function is not equal to NERR_Success, thus it returns a false.
why don't you ask this on the thread you began earlier on the subject ?
- Well first of all, I have no idea.....
why do you want only DavidCrow to answer you ?
- The question wasn't just indended for him, he was the one how answer the
question, and thus the reason his name appears.
why do you think forums are mad for ?
- ??? mad ???
Thanx for your comments
Last Visit: 27-Jan-20 22:43 Last Update: 27-Jan-20 22:43