In MFC - with ODBC - How to select only few columns from a table



Hello!

My scenario is:

I made a project in Visual C++.NET (2003) - MFC with ODBC. CDatabase and
CRecordset.

In Sql Server 2000 I made a table Tab1 with 10 columns for sample.
Nr_doc, Data_doc, Val_1, Val_2, Val_3, Val_4, Val_5, Val_6, Val_7 and
Val_Tot



In Visual C++ - MFC I want to select only 2 columns from this table use
CRecordset - Open()....

In this moment my code is (for sample):

CDatabase dbDateServ;
CRs_Tab1* rsTab; //CRs_Tab1 - is a class MFC - ODBC -
Consummer
//bind to table Tab1
CString szConectSql;

szConectSql = "ODBC; DSN=SQL_Server; UID=sa; PWD=florin; DATABASE=DateServ";

dbDateServ.Open(szConectSql);
rsTab = new CRs_Tab1(&dbDateServ);
rsTab->Open(CRecordset::snapshot, "SELECT * FROM Tab1");

......... other commands etc


rsTab->Close();
delete rsTab;

dbDateServ.Close();

In this situation in my recordset are selected all columns from the table
Tab1.
But I don't this thing. I want in rsTab->Open(CRecordset::snapshot, "....");
to execute the comand
SELECT Nr_doc, Data_doc FROM Tab1.
I want to select only 2 columns from my table in this recordset.

If I will write
rsTab->Open(CRecordset::snapshot, "SELECT Nr_doc, Data_doc FROM Tab1");
or
rsTab->Open(CRecordset::snapshot, "SELECT Nr_doc AS Nr_doc, Data_doc AS
Data_doc FROM Tab1");
It's not OK because appear an error "Invalid descriptor index."

My question is How to do this thing?


Thank You very much!
Please!!!!!!






.