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

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

 2008-09-25 19:27:00 来源:WEB开发网   
核心提示: 货币 CURRENCY系统自动编号 COUNTER五、 对列的操作:1、 取得SQL语句中的列数:int SuperRecordSet::GetColCount(){SWORD swColCount;if (m_hstmt == NULL)return -1;if (SQL_SUCCESS

货币 CURRENCY

系统自动编号 COUNTER

五、 对列的操作:

1、 取得SQL语句中的列数:

  int SuperRecordSet::GetColCount()
  {
  SWORD swColCount;
  if (m_hstmt == NULL)
  return -1;
  if (SQL_SUCCESS == ::SQLNumResultCols(m_hstmt,&swColCount))
  return swColCount;
  else
  return -1;
  }

七、数据的读取

1、列绑定:

  CString strSQLString;
  RETCODE ReturnCode;
  SQLHSTMT hstmt;
  if (SQL_SUCCESS != SQLAllocHandle(SQL_HANDLE_STMT,theApp.m_hdbc,&hstmt))
  return;
  FF_DB_HHZHICHU_SET_FIELDS dbdata;
  SDWORD cb1;
  SDWORD cb2;
  SDWORD cb3;
  SDWORD cb4;
  SDWORD cb5;
  SDWORD cb6;
  SDWORD cb7;
  SDWORD cb8;
  SDWORD cb9;
  // Build the SQL Statement
  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,&cb1);
  SQLBindCol(hstmt,2,SQL_C_TIMESTAMP,&dbdata.m_Ariqi,0,&cb2);
  SQLBindCol(hstmt,3,SQL_C_DOUBLE,&dbdata.m_Njine,0,&cb3);
  SQLBindCol(hstmt,4,SQL_C_CHAR,dbdata.m_Ashuoming,HHZhiChu_aShuoMing_SIZE,&cb4);
  SQLBindCol(hstmt,5,SQL_C_CHAR,dbdata.m_Alaiyuan,HHZhiChu_aLaiYuan_SIZE,&cb5);
  SQLBindCol(hstmt,6,SQL_C_CHAR,dbdata.m_Acunzhe,HHZhiChu_aCunZhe_SIZE,&cb6);
  SQLBindCol(hstmt,7,SQL_C_CHAR,dbdata.m_Ayongtu,HHZhiChu_aYongTu_SIZE,&cb7);
  SQLBindCol(hstmt,8,SQL_C_CHAR,dbdata.m_Axiaofei,HHZhiChu_aXiaoFei_SIZE,&cb8);
  SQLBindCol(hstmt,9,SQL_C_CHAR,dbdata.m_Abeizhu,HHZhiChu_aBeiZhu_SIZE,&cb9);
  // Fetch and store...
  if (SQL_SUCCESS == (ReturnCode = SQLFetch(hstmt)))
  {
  m_Record.m_Nid = dbdata.m_Nid;
  m_Record.m_Ariqi.SetDateTime(dbdata.m_Ariqi.year,
  dbdata.m_Ariqi.month,
  dbdata.m_Ariqi.day,
  dbdata.m_Ariqi.hour,
  dbdata.m_Ariqi.minute,
  dbdata.m_Ariqi.second);
  m_Record.m_Njine = dbdata.m_Njine;
  m_Record.m_Ashuoming = dbdata.m_Ashuoming;
  m_Record.m_Alaiyuan = dbdata.m_Alaiyuan;
  m_Record.m_Acunzhe = dbdata.m_Acunzhe;
  m_Record.m_Ayongtu = dbdata.m_Ayongtu;
  m_Record.m_Axiaofei = dbdata.m_Axiaofei;
  m_Record.m_Abeizhu = dbdata.m_Abeizhu;
  }
  }
  ::SQLFreeHandle(SQL_HANDLE_STMT,hstmt);

上一页  2 3 4 5 6 7 8 9 10  下一页

Tags:AppBuilder 进行 直接

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