MFC的ODBC操作Access
有MFC的ODBC操作Access相关教程吗?刚开始学,有的话帮助一下,谢谢
邮箱:yyzq52@126.com
[解决办法]
http://www.vckbase.com/document/finddoc.asp?keyword=odbc
[解决办法]
- C/C++ code
#include "afxdb.h"//---------------------------// Create and open a database object;// do not load the cursor libraryCDatabase db;//db.OpenEx( NULL, CDatabase::forceOdbcDialog );db.OpenEx( "DSN=rsgl;UID=;PWD=", CDatabase::noOdbcDialog );// Create and open a recordset object// directly from CRecordset. Note that a// table must exist in a connected database.// Use forwardOnly type recordset for best// performance, since only MoveNext is requiredCRecordset rs( &db );rs.Open( CRecordset::forwardOnly, _T( "SELECT * FROM test" ) );// Create a CDBVariant object to// store field dataCDBVariant varValue;// Loop through the recordset,// using GetFieldValue and// GetODBCFieldCount to retrieve// data in all columnsshort nFields = rs.GetODBCFieldCount( );while( !rs.IsEOF( ) ){ for( short index = 0; index < nFields; index++ ) { rs.GetFieldValue( index, varValue ); // do something with varValue AfxMessageBox(*varValue.m_pstring); } rs.MoveNext( );}rs.Close( );db.Close( );
[解决办法]
楼上,请问一下,ADO与ODBC有什么相同点么?