Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CRecordset 1

Status
Not open for further replies.

jl3574

Programmer
Jun 5, 2003
76
CA
Specification : I am using ODBC as my interface, visual c++ to develope my front end application and MS sql server as my database.

i'm having trouble trying to retrive data from the last column of my table.

CDatabase* theDb = new CDatabase;
theDb->OpenEx("DSN=local");

CRecordset* theRec = new CRecordset(theDb);
theRec->Open(AFX_DB_USE_DEFAULT_TYPE,"select STYLE_ID from STYLES",CRecordset::readOnly);

//Tablename is STYLE_ID, column name is STYLES

if(theRec->IsEOF()!=0)
theRec->MoveLast();
//now that i move to the last record what CRecordset do i use to retreive the data?


 
Hi,
you can with theRec->GetFieldValue(short(0),strValue0)
read the first column and so on :

theRec->GetFieldValue(short(0),strValue0)
theRec->GetFieldValue(short(1),strValue1)
...
 
Hi jl3574,
Just looking at your post while searching for an answer...
theRec->Open(AFX_DB_USE_DEFAULT_TYPE,"select STYLE_ID from STYLES",CRecordset::readOnly);

//Tablename is STYLE_ID, column name is STYLES

Looks like your backwards in your SELECT statement...the FROM clause specifies the table, and the SELECT specifies the columns...
maybe just a typo on your part also..
just my $.02
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top