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

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

 2008-09-25 19:27:00 来源:WEB开发网   
核心提示: 2、参数绑定:bool CCddataSet::Insert(pDB_CDDATA_SET_FIELDS pData, bool bFirstTime /* true */){RETCODE ReturnCode;CString strSQLString;static FF_DB_CDDA

2、参数绑定:

  bool CCddataSet::Insert(pDB_CDDATA_SET_FIELDS pData, bool bFirstTime /* true */)
  {
  RETCODE ReturnCode;
  CString strSQLString;
  static FF_DB_CDDATA_SET_FIELDS HostData;
  // Prepare the statement and bind the columns once
  if (bFirstTime)
  {
  memset(&HostData,0,sizeof(HostData));
  SQLFreeStmt(m_hstmt, SQL_CLOSE); // Close the cursor if any
  SQLFreeStmt(m_hstmt, SQL_RESET_PARAMS); // Reset the statement handle
  strSQLString.Format("INSERT INTO CDData ("
  "NGUANGPAN,"
  "NWENJIAN,"
  "NCLASS,"
  "AWENJIAN,"
  "NSHANGJI,"
  "NSHUXING,"
  "ABEIZHU )"
  "VALUES ("
  "?," // nGuangPan
  "?," // nWenJian
  "?," // nClass
  "?," // aWenJian
  "?," // nShangJi
  "?," // nShuXing
  "? )" // aBeiZhu
  ); // end format
  ReturnCode = SQLPrepare(m_hstmt, (UCHAR*)((LPCTSTR)strSQLString),SQL_NTS);
  if (ReturnCode != SQL_SUCCESS)
  {
  return false;
  }
  SQLBindParameter(m_hstmt,1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0,
  0,&HostData.m_Nguangpan,0,&HostData.m_NguangpanInd );
  SQLBindParameter(m_hstmt, 2,SQL_PARAM_INPUT,SQL_C_SLONG,SQL_INTEGER, 0,
  0,&HostData.m_Nwenjian,0, &HostData.m_NwenjianInd );
  SQLBindParameter(m_hstmt,3,SQL_PARAM_INPUT, SQL_C_SLONG,SQL_INTEGER, 0,
  0,&HostData.m_Nclass,0,&HostData.m_NclassInd );
  SQLBindParameter(m_hstmt,4,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_VARCHAR,
  CDData_aWenJian_SIZE,0,HostData.m_Awenjian,0,&HostData.m_AwenjianInd );
  SQLBindParameter(m_hstmt,5,SQL_PARAM_INPUT,SQL_C_SLONG,SQL_INTEGER,0,
  0,&HostData.m_Nshangji, 0, &HostData.m_NshangjiInd );
  SQLBindParameter(m_hstmt,6,SQL_PARAM_INPUT,SQL_C_SLONG,SQL_INTEGER, 0,
  0, &HostData.m_Nshuxing, 0,&HostData.m_NshuxingInd );
  SQLBindParameter(m_hstmt, 7,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_VARCHAR,
  CDData_aBeiZhu_SIZE,0, HostData.m_Abeizhu, 0,&HostData.m_AbeizhuInd );
  }
  // Move the data to host structure and execute the statement
  HostData.m_Nguangpan = pData->m_Nguangpan;
  HostData.m_Nwenjian = pData->m_Nwenjian;
  HostData.m_Nclass = pData->m_Nclass;
  HostData.m_AwenjianInd = SQL_NTS;
  memcpy(HostData.m_Awenjian, pData->m_Awenjian, CDData_aWenJian_SIZE);
  HostData.m_Nshangji = pData->m_Nshangji;
  HostData.m_Nshuxing = pData->m_Nshuxing;
  HostData.m_AbeizhuInd = SQL_NTS;
  memcpy(HostData.m_Abeizhu, pData->m_Abeizhu, CDData_aBeiZhu_SIZE);
  ReturnCode = SQLExecute(m_hstmt);
  if (ReturnCode != SQL_SUCCESS)
  {
  return false;
  }
  return true;
  }

上一页  5 6 7 8 9 10 

Tags:AppBuilder 进行 直接

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