- 增加库文件 #pragma comment(lib, "odbccp32.lib ")
- 包含头文件 #include <odbcinst.h>
- 调用函数
123456::SQLConfigDataSource(NULL,ODBC_ADD_DSN,
"Oracle in OraDb10g_home1"
,
"DSN=mT\0"
"Description=DATASOURCE\0"
"Server=his\0"
))
1示例:
12345678910111213141516171819202122232425262728293031323334353637#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(
"失败"
);
}