|
Is ADO faster than DAO?
Fortitudine Vincimus!
|
|
|
|
|
Tara14 wrote: Is ADO faster than DAO?
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.
What you should be using is OLEDB.
regards,
Darka [ Xanya]
"When you're taught to love everyone, to love your enemies, then what value does that place on love?"
|
|
|
|
|
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?
Fortitudine Vincimus!
|
|
|
|
|
Tara14 wrote: Is that good enough
It should be ok, I would just stick with Jet and DAO if you have to use a Microsoft Access database.
Darka [ Xanya]
"When you're taught to love everyone, to love your enemies, then what value does that place on love?"
|
|
|
|
|
Thanks.
Fortitudine Vincimus!
|
|
|
|
|
Besides switching from DAO, I think you can try to improve the speed by disabling redraw operations:
myListCtrl.SetRedraw(FALSE);
. . .
myListCtrl.SetRedraw(TRUE);
If you know the number of items to be added, you can call SetItemCount before.
Additionally, you can investigate the "virtual list" concept.
For some information see http://www.pocketpcdn.com/articles/list_view.html[^].
I hope this helps.
|
|
|
|
|
Viorel. wrote: If you know the number of items to be added, you can call SetItemCount before.
I did that, but it did not help much.
Viorel. wrote: Additionally, you can investigate the "virtual list" concept.
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.
Fortitudine Vincimus!
|
|
|
|
|
Tara14 wrote:
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...
void YourListControlView::OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult){
if(NULL == pYourTable){
return;
}
*pResult = 1;
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
ASSERT(pNMLV);
CString _sOrderBy;
CString _sOrder;
CString _sFieldName;
CDaoFieldInfo info;
ZeroMemory(&info, sizeof(CDaoFieldInfo));
m_bSortAscending = (m_nSortColumn != pNMLV->iSubItem) ? true : !m_bSortAscending;
m_nSortColumn = pNMLV->iSubItem;
if(m_bSortAscending){
_sOrder = _T(" ASC");
}
else{
_sOrder = _T(" DESC");
}
try{
pYourTable->GetFieldInfo(nSortColumn, info);
_sFieldName = info.m_strName;
_sOrderBy.Format(_T("%s %s"), _sFieldName, _sOrder);
// Requery the table
// *****************
pYourTable->m_strSort = _sOrderBy;
pYourTable->m_strFilter = _T(""); // You may need to change this !!
pYourTable->Requery();
pYourTable->MoveFirst();
}
catch(CDaoException* px_e){
#ifdef _DEBUG
px_e->ReportError();
#endif
px_e->Delete();
}
// Invalidate the list control so
// that it will be refreshed
// ******************************
GetListCtrl().Invalidate();
....
}
This assumes that your table class is derived from CDaoRecordSet. I use my own classes for DAO access, and any of the main functions (Requery, Movexx etc are capsled)
In this example, I have two member variablesto keep track of the current column and the order of sorting (m_nSortColumn, m_bSortAscending)
Also, using GetListCtrl().SetItemCountEx(nNumberOfRecordsPresnet) will speed up the displaying of the data.
Hope this helps a bit
mfg
Phil
Who the f*** is General Failure, and why is he reading my harddisk?
-- modified at 6:06 Thursday 3rd August, 2006
|
|
|
|
|
Thank you. I shall try it out.
Usually what I do is read data from the database and fill the list.
void CXBudget::AddPayeeList2()
{
CDBcreate *p = new CDBcreate;
CDaoDatabase *pdB=new CDaoDatabase();
pdB->Open(path,FALSE,FALSE,pwd);
CString TabNam = curTableName;
sql = ("SELECT * FROM "+TabNam+" WHERE param='budget' ORDER BY cat,payee");
CDaoRecordset *rs;
rs = new CDaoRecordset(pdB);
rs->Open(AFX_DAO_USE_DEFAULT_TYPE,sql,NULL);
CString strCategory, strPayee;
CString strTp;
int nFeldCount;
nCol = 2; ;
int nRow = 0;
CString strRowTotal;
m_XBudgetLIST_Main.DeleteAllItems();
m_XBudgetLIST_RowTotal.DeleteAllItems();
nFeldCount = p->getFieldCount(pdB,strBudgetName);
while (!rs->IsEOF())
{
strCategory = p->GetAsString(rs,1);
m_XBudgetLIST_Main.InsertItem(nRow,strCategory);
strPayee = p->GetAsString(rs,2);
m_XBudgetLIST_Main.SetItemText(nRow,1,strPayee);
for ( int i = 3;i<nFeldCount;i++)
{
strTp = pCol->SetValue(p->GetAsDouble(rs,i));
m_XBudgetLIST_Main.SetItemText(nRow,nCol,strTp);
nCol++;
}
nCol = 2;
strRowTotal = pCol->SetValue(Payee_RowTotal(strCategory,strPayee));
m_XBudgetLIST_RowTotal.InsertItem(nRow,strRowTotal);
rs->MoveNext();
nRow++;
}
pdB->Close();
rs->Close();
delete p;
delete pdB;
delete rs;
When the number of colunms are too many, the time for the loop to be fully executed is looong.
Fortitudine Vincimus!
|
|
|
|
|
I would consider the following:
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...
mfg
Phil
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 shall let you know what happens.
Thanks again.
Fortitudine Vincimus!
|
|
|
|
|
I just now added SetRedraw to my lists. They are loading significanly faster now.
Thanks a lot.
Fortitudine Vincimus!
|
|
|
|
|
Hai frens,
I need to get only the date info. Need to set time to 0.
// Get the current date.
COleDateTime DateValidTill = COleDateTime::GetCurrentTime();
Wud like to get a better solution than the following.
DateValidTill.SetDateTime( DateValidTill.GetYear(),DateValidTill.GetMonth(),DateValidTill.GetDay(),0, 0, 0 );
|
|
|
|
|
Try:
COleDateTime DateValidTill = COleDateTime::GetCurrentTime();
DateValidTill.SetTime(0, 0, 0);
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
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.
How should I accomplish this?
Cutebug
|
|
|
|
|
Your application need to accept the file path as a parameter when it's run, so typing "yourapp.exe file.abc" on the command line should open the image.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
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.
|
|
|
|
|
Process your command line arguments.
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
|
|
|
|
|
Well the function returns:
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.
For example:
============
LPWSTR domaincontroller = NULL;
NET_API_STATUS nStatus;
WCHAR *uni_username = NULL;
uni_username =L"richardb"
nStatus = NetUserGetInfo(domaincontroller, uni_username, 3, (LPBYTE*)&buffer);
if(nStatus != NERR_Success){
retval = NULL;
return false;
}else{
return true;
}
}
===========
I have no idea what could be wrong.
David could you plz help or know of a site or something ... anything
Thanx
Regards
Programm3r
|
|
|
|
|
<br />
...<br />
...<br />
GetUserName(lpuser, &dword);<br />
USES_CONVERSION;<br />
nStatus = NetUserGetInfo(NULL, A2W(lpuser), 3, (LPBYTE*)&buffer);<br />
then nStatus =0<br />
|
|
|
|
|
WhiteSky .... you lost me ..
Regards
Programm3r
|
|
|
|
|
Programm3r wrote: eSky .... you lost me ..
offcourse
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Programm3r wrote: Question: @ DavidCrow
why don't you ask this on the thread you began earlier on the subject ?
why do you want only DavidCrow to answer you ?
why do you think forums are mad for ?
|
|
|
|
|
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
Regards
Programm3r
|
|
|
|
|
Programm3r wrote: why do you think forums are mad for ?
- ??? mad ???
made
|
|
|
|
|