How do i retrieve invidual field name s and values from a table 
Author Message
 How do i retrieve invidual field name s and values from a table

CDatabase db;
int reccount;

if(db.OpenEx(_T("DSN=mail;UID=sa"),CDatabase::noOdbcDialog))
AfxMessageBox("connected",NULL,MB_OK);
else
AfxMessageBox("not connected",NULL,MB_OK);

CRecordset rec(&db);

CString strSQL;
strSQL = "client_information";
strSQL = _T("SELECT * FROM ") + strSQL;

rec.Open(CRecordset::snapshot, strSQL,
CRecordset::readOnly | CRecordset::useMultiRowFetch);

while(!rec.IsEOF())
{
rec.MoveNext();

Quote:
}

reccount=rec.GetRecordCount();
printf("count = %d",reccount);

I am getting the "connected dialog box"
Now I wanna know how can u retrieve the individual field-names and the values in that table.
E.g.
Table structure is:
firstname varchar(50),
lastname varchar(50),
....
.....
.....
And there are approx. 500 records in it and may change dynamically.
I wanna know how do u get the field name and the value in it at that time.
For every record fetched I wanna store the value of each field in some variable.
for(int i=0;i<getrecordcount;i++)
xyz=firstname
abc=lastname
...
...
...
etc
How do I achieve this?
Please some part of code will be highly recommended.



Sun, 28 Jul 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. retrieve field value from table

2. ? Bug: no : and _ permit in the same table field name

3. Set default value to table fields

4. Official naming guidelines for const field names

5. ~Sum existing values with values from another table

6. getting CDB file name from Table name

7. retrieving data field from when binding a Datagrid to a dataset

8. Doing graphs and tables in C

9. ODBC API, SQL_C_DATE - how to retrieve field data?

10. Retrieving auto inc fields with ODBC

11. Need help on retrieving memo field

12. Retrieving field descriptions using ODBC and VC++

 

 
Powered by phpBB® Forum Software