⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqlrecordset.h

📁 应用VC++编的简单的ODBC访问接口。(我已经是会员了! 挖哈哈!!!)
💻 H
字号:
// SQLRecordset.h
// 
// Encapsulates the basic ODBC API select statement eliminating
// the need to remember to free handles and other generic arguments.
//
// Revision Log
//
// Date       Programmer SAR     Notes
// ========== ========== ======= =====================================
// 1999-10-30 mph        00069   Initial coding
// 
// Revision log
//
// Sample
#ifdef SAMPLE_CODE
   try 
   {
      CSQLRecordset rs = g_db;
      rs._stmt << "";
      rs.SetWhere( "" );
      rs.SQLExecDirect();
      while ( rs.SQLFetch() )
      {
         int n = 1;
         string sPatient = rs.SQLGetData( n++ );
      }
   }
   catch ( CSQLException* e )
   {
      //HANDLEEXCEPTION( e ); // part of CByteRiteRules::HandleException( ... )
      AfxMessageBox( e->m_strError );
      e->Delete();
   }
#endif
//
//////////////////////////////////////////////////////////////////////

#ifndef AFX_SQLRECORDSET_H
#define AFX_SQLRECORDSET_H

#include "sqldatabase.h"
#include "sqlbasewhere.h"

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

class CSQLRecordset : public CSQLBaseWhere
{
// constructor/destructor
public:
   CSQLRecordset();
   CSQLRecordset( SQLHDBC a_hdbc );
   CSQLRecordset( CSQLDatabase& db );
   virtual ~CSQLRecordset();
   void Connect( CSQLDatabase& db );
   void ResetContent();

   void operator <<( const char* statement );

   bool SQLExecDirect();
   bool SQLExecDirect( const char* a_szStmt );
   bool SQLFetch();
   const char* SQLGetData( int a_uRow, int a_eDataType=CSQLBase::STRING );

   void     SetOrderBy( const char * a_szOrderBy );
   void     SetGroupBy( const char* a_szGroupBy );

public:
	double   dblSQLGetData( int column );
	int      nSQLGetData( int column );
   bool     bSQLGetData( int column );
	long     lSQLGetData( int column, int a_eDataType );
	int      GetColumnType( int a_nColumn );
   int      GetColumns();
   void     SetHDBC( HDBC* a_hdbc );
   bool     SQLAllocStmt();
	void     SQLFreeStmt( SQLUSMALLINT a_uType=SQL_DROP );

protected:
   void ThrowError();
private:

   SQLRETURN _rc;

   SQLHDBC   _hdbc;
   SQLHSTMT  _hstmt;

   std::string   _orderBy;
   std::string   _groupBy;

   std::string _result;
};

#endif // !defined( AFX_SQLRECORDSET_H__D1794F02_8E5C_11D3_A73F_004F4904ABE2__INCLUDED_ )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -