WEB开发网
开发学院软件开发VC AppBuilder中进行直接ODBC API数据库调用访问的基... 阅读

AppBuilder中进行直接ODBC API数据库调用访问的基本方法!

 2008-09-25 19:27:00 来源:WEB开发网   
核心提示: 的资源,因为很多DBMS对同时连接的每一个许可人员或用户都是收费的,AppBuilder中进行直接ODBC API数据库调用访问的基本方法!(3),当连接完成时,应当把它返回,SQLDisconnect的语法如下:RETCODESQLDisconnect(hdbc)SQLDisconnec

的资源,因为很多DBMS对同时连接的每一个许可人员或用户都是收费的。当

连接完成时,应当把它返回,以便其它用户能注册进入该系统。下面描述的ODBC

函数SQLDisconnect处理这一操作过程。

SQLDisconnect关闭与指定的连接句柄相关的数据源连接。SQLDisconnect

的语法如下:

  RETCODESQLDisconnect(hdbc)

SQLDisconnect的返回码是:

  SQL-SUCCESS
  SQL-SUCCESS-WITH-INFO
  SQL-ERROR
  SQL-INVALID-HANDLE

如果数据源连接成功的话,就可以继续下一步;

  CString strSQLString;
  RETCODE ReturnCode;
  SQLHSTMThstmt;
  if (SQL_SUCCESS != SQLAllocHandle(SQL_HANDLE_STMT,theApp.m_hdbc,&hstmt))
  return;
  strSQLString.Format(
  "SELECT "
  "NID,"
  "ARIQI,"
  "NJINE,"
  "ASHUOMING,"
  "ALAIYUAN,"
  "ACUNZHE,"
  "AYONGTU,"
  "AXIAOFEI,"
  "ABEIZHU"
  " FROM HHZhiChu "
  " WHERE NID=%u",
  nID);
  if (SQL_SUCCESS == (ReturnCode = SQLExecDirect(hstmt,(UCHAR*)((LPCTSTR)strSQLString),SQL_NTS)))
  {
  SQLBindCol(hstmt,1,SQL_C_SLONG,&dbdata.m_Nid,0,&cb);
  SQLBindCol(hstmt,2,SQL_C_TIMESTAMP,&dbdata.m_Ariqi,0,&cb);
  SQLBindCol(hstmt,3,SQL_C_DOUBLE,&dbdata.m_Njine,0,&cb);
  SQLBindCol(hstmt,4,SQL_C_CHAR,dbdata.m_Ashuoming,HHZhiChu_aShuoMing_SIZE,&cb);
  SQLBindCol(hstmt,5,SQL_C_CHAR,dbdata.m_Alaiyuan,HHZhiChu_aLaiYuan_SIZE,&cb);
  SQLBindCol(hstmt,6,SQL_C_CHAR,dbdata.m_Acunzhe,HHZhiChu_aCunZhe_SIZE,&cb);
  SQLBindCol(hstmt,7,SQL_C_CHAR,dbdata.m_Ayongtu,HHZhiChu_aYongTu_SIZE,&cb);
  SQLBindCol(hstmt,8,SQL_C_CHAR,dbdata.m_Axiaofei,HHZhiChu_aXiaoFei_SIZE,&cb);
  SQLBindCol(hstmt,9,SQL_C_CHAR,dbdata.m_Abeizhu,HHZhiChu_aBeiZhu_SIZE,&cb);
  if (SQL_SUCCESS == (ReturnCode = SQLFetch(hstmt)))
  {
  //读数据成功,可一对数据进行处理了。
  }
  }
  ::SQLFreeHandle(SQL_HANDLE_STMT,hstmt);

上一页  1 2 3 4 5 6 7 8  下一页

Tags:AppBuilder 进行 直接

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接