
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.