c++ builder 配置数据源
- 增加库文件 #pragma comment(lib, "odbccp32.lib ")
- 包含头文件 #include <odbcinst.h>
- 调用函数
::SQLConfigDataSource(NULL,ODBC_ADD_DSN, "Oracle in OraDb10g_home1", "DSN=mT\0" "Description=DATASOURCE\0" "Server=his\0" ))示例:#include <vcl.h> #pragma hdrstop #include <odbcinst.h> #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" #pragma comment(lib, "odbccp32.lib ") TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //-------www.cnblogs.com/zhangdongsheng-------------------------------------------------------------------- void __fastcall TForm1::btn_1Click(TObject *Sender) { if(::SQLConfigDataSource(NULL,ODBC_ADD_DSN, "Oracle in OraDb10g_home1", "DSN=mT\0" "Description=DATASOURCE\0" "Server=his\0" )) /* if(::SQLConfigDataSource(NULL,ODBC_ADD_DSN, "Microsoft Excel Driver (*.xls)", "DSN=New Excel Data Source\0" "Description=New Excel Data Source\0" ))*/ ShowMessage("成功"); else ShowMessage("失败"); }
本博客注有“转”字样的为转载文章,其余为本人原创文章,转载请务必注明出处或保存此段。c++/lua/windows逆向交流群:69148232