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

📄 ex571_odbc.cpp

📁 there are OTL exampless,it s a good examples
💻 CPP
字号:
#include <iostream>using namespace std;#include <stdio.h>#define OTL_ODBC//#define OTL_ODBC_UNIX // Compile OTL 4.0/ODBC#include <otlv4.h> // include the OTL 4.0 header fileotl_connect db; // connect objectvoid select(){  otl_stream s; s.set_all_column_types(otl_all_num2str|otl_all_date2str);     // map all numeric and date/time output columns to strings for simplicity. db.auto_commit_on(); s.open(100, // buffer size         "$SQLTables",         // get a list of all tables in the current database         db // connect object        );  otl_column_desc* desc; int desc_len; desc=s.describe_select(desc_len);     // describe the structure of the output columns of the result set. int rpc=0; while(!s.eof()){   ++rpc;   char str[512];   cout<<"ROW#"<<rpc<<" ";   for(int col_num=0;col_num<desc_len;++col_num){     s>>str;     if(s.is_null())       cout<<desc[col_num].name<<"=NULL ";     else       cout<<desc[col_num].name<<"="<<str<<" ";   }   cout<<endl; } db.auto_commit_off();}int main(){ otl_connect::otl_initialize(); // initialize ODBC environment try{  db.rlogon("scott/tigger@freetds_sybsql"); // connect to ODBC  db.auto_commit_off();  select(); // query the system data dictionary via ODBC functions. } catch(otl_exception& p){ // intercept OTL exceptions  cerr<<p.msg<<endl; // print out error message  cerr<<p.stm_text<<endl; // print out SQL that caused the error  cerr<<p.sqlstate<<endl; // print out SQLSTATE message  cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from ODBC return 0;}

⌨️ 快捷键说明

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