SQL Commands
-
Hello, I am using of CDaoDatabase CDaoRecordset Classes and I want to know that How can I use SQL Commands by them? Like this(I want to have filter) "select * from Name where name='something'" and How can I Set a Field to an Edit Object? Best Wishes, Thanks.
-
Hello, I am using of CDaoDatabase CDaoRecordset Classes and I want to know that How can I use SQL Commands by them? Like this(I want to have filter) "select * from Name where name='something'" and How can I Set a Field to an Edit Object? Best Wishes, Thanks.
the follwing piece of code might help you... CDaodatabase database; database.Create("C:\sample_log.mdb"); CString SqlCmd = "CREATE TABLE list (NAME VARCHAR(20), AGE INT, DATE VARCHAR(20), TIME VARCHAR(20));"; database.Execute(SqlCmd); database.Close(); now to search.... build a query string and execute it... CString query = "Select * from list where NAME='ABCD'" CDaoDatabase db; db.Open("C:\sample_log.mdb"); CDaoRecordSet record(&db); record.Open(AFX_DAO_USE_DEFAULT_TYPE,query,0); Then... while(!recor.IsEOF()) { ..... use GetFieldValue() for each record in the recordset } record.Close(); db.Close();