Last active
September 4, 2022 02:30
-
-
Save chenbojian/d3cf5c60328049d7054afe1a9404e1ee to your computer and use it in GitHub Desktop.
MFC CRecordset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void func() { | |
CDatabase db; | |
CRecordset rs(&db); | |
db.OpenEx("Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\\dbo.mdb;"); | |
db.ExecuteSQL("select * from Sporter"); | |
rs.Open(CRecordset::dynaset, "select * from [Sporter]", CRecordset::none); | |
BOOL a = rs.CanAppend(); | |
CDBVariant varValue; | |
int count = 0; | |
int nFields = rs.GetODBCFieldCount(); | |
while (!rs.IsEOF()) | |
{ | |
for (int index = 0; index < nFields; index++) | |
{ | |
rs.GetFieldValue(index, varValue); | |
// do something with varValue | |
} | |
rs.MoveNext(); | |
count++; | |
} | |
rs.Close(); | |
db.Close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment