|
-
September 20th, 1999, 10:04 AM
#1
MFC SQL join
I am trying to use the MFC ODBC database classes to solve a particular problem. However, knowing only the basics, I am unable to figure out how to implement a recordset for SQL statements that will contain a "join" command. For example, I need to implement the statement:
select count(nameid), max(currentdate)
from events join eventday on events.dayid = eventday.dayid
group by eventday.dayid
order by eventday.dayid
This joins the tables "events" and "eventday". What is the procedure for doing something like this using MFC?
Thanks in advance.
-
September 20th, 1999, 10:15 AM
#2
Re: MFC SQL join
Hi. To execute SQL statements without deriving a new class from CRecordset, you can call CRecordset itself by supplying the SQL statement:
CRecordset set(pDatabase);
CString strSelect = "SELECT SUM(Field1) FROM TestTable", strValue;
set.Open(CRecordset::forwardOnly, strSelect, CRecordset::readOnly |
CRecordset::noDirtyFieldCheck | CRecordset::executeDirect);
set.GetFieldValue(0, strValue); // use GetFieldValue to get the field values, because
double dSum = atof(strValue); // we haven't derived a class with member variables
set.Close();
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
|