Re: Reading one Record at a time till i reach EOF in VC++ using ODBC
Use CDatabase and CRecordSet classes.
// Embed a CDatabase object
// in your document class
CDatabase m_dbCust;
// Connect the object to a
// read-only data source where
// the ODBC connection dialog box
// will always remain hidden
m_dbCust.OpenEx( _T( "DSN=MYDATASOURCE;UID=JOES" ),
CDatabase::openReadOnly |
CDatabase::noOdbcDialog );
CRecordSet rs;rs.m_pDatabase=&m_dbCust;rs.Open( CRecordset::dynaset,
_T( "Select L_Name from Customer" ) );
short nFields = rs.GetODBCFieldCount( );
CString varValue ;
while( !rs.IsEOF( ) )
{
for( short index = 0; index < nFields; index++ )
{
rs.GetFieldValue( index, varValue );
// do something with varValue
}
rs.MoveNext( );
}
m_dbCust.Close( );
db.Close( );
<geetu.patil@gmail.com> wrote in message
news:1149594190.152580.258190@y43g2000cwc.googlegroups.com...
Hi,
i am working on Vc++6.0. I hve a req where in i need to read one record
at a time till i reach EOF from the database.Can anyone tell me how to
do this
Very urgent
Thanks