-
December 13th, 2012, 09:26 AM
#1
how to order records in ACCESS by MFC objects like CDaodatabase or CDaoRecordset?
table with primary key already set-down in ACCESS. when insert records into the table by Execute() function of cdaodatabase, to some extense, the records are not put behind the last record as wished, otherwise randomly into other places!
now i want to do some kind of operation to order the table after insertion by cdaodatabase or some others. how to?
waiting for your help!!
-
December 13th, 2012, 09:42 AM
#2
Re: how to order records in ACCESS by MFC objects like CDaodatabase or CDaoRecordset?
If you look at the documentation for CDaoRecordset, I think you'll find a member with a pretty obvious name that does what you want.
-
December 13th, 2012, 10:39 AM
#3
Re: how to order records in ACCESS by MFC objects like CDaodatabase or CDaoRecordset?
in CDaoRecordset, with m_strSort member i can get the order records. but nothing changes in table! the code as follows,
/*
table aa: ind as the primary key
/////////
ind ind2
21 111
23 333
24 444
/////////
*/
CDaoRecordset ret(&db);
ret.m_strSort = _T("[ind] DESC");
sql = _T("select * from aa");
ret.Open(dbOpenDynaset,sql,0);
COleVariant var,var1;
// get the first record! with setting above surly the first record is (24 444)
// but nothing changes with table aa: records ordered ascently!!
ret.GetFieldValue(0,var);
ret.GetFieldValue(1,var1);
sql.Format(_T("%d, %d"),var.lVal, var1.lVal);
GetDlgItem(IDC_SHOW)->SetWindowText(sql);
ret.Close();
-
December 13th, 2012, 10:51 AM
#4
Re: how to order records in ACCESS by MFC objects like CDaodatabase or CDaoRecordset?
I've never used a CDaoRecordset, but it's possible your sql statement is overriding the m_strSort. Try adding ORDER BY to sql, or leaving sql NULl and using m_strFilter and m_strSort.
-
December 13th, 2012, 11:07 AM
#5
Re: how to order records in ACCESS by MFC objects like CDaodatabase or CDaoRecordset?
thanks for your help! i am trying to deal with it!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|