[b]主要控件:[/b]
ADOConnOrcale: TADOConnection; //连接Oracle
ADOConnSQLServer: TADOConnection; //连接SQL Server
O1: TADOQuery; //连接Oracle
S1: TADOQuery; //连接SQL Server
S2: TADOQuery; //连接SQL Server
ProgressBar1: TProgressBar; //进度条
Memo1: TMemo; //显示出错信息
EdtServer: TEdit; //
EdtDataBase: TEdit; //数据库名称
EdtUser: TEdit; //用户名
EdtPass: TEdit; //口令
Button1: TButton; //执行按钮
//常量
const
ORAConnStr='Provider=MSDAORA.1;Data Source=%S;User ID=%S;Password=%S;Persist Security Info=True';
SQLConnStr='Provider=SQLOLEDB.1;Data Source=%S;Initial Catalog=%S;User ID=%S;Password=%S;Persist Security Info=False';
在执行前先进行Oracle和SQL Server数据库的连接。
[b]连接Oracle:[/b]
ADOConnOrcale.ConnectionString :=Format(ORAConnStr,[trim(EdtDataBase.Text),
trim(EdtUser.Text),trim(EdtPass.Text)]);
try
ADOConnOrcale.Open;
MsgBox('Oracle数据库连接成功!');
Except
MsgBox('Oracle数据库连接失败!');
end;
[b]连接SQL Server:[/b]
ADOConnSQLServer.ConnectionString :=Format(SQLConnStr,[trim(EdtServer.Text),
trim(EdtDataBase.Text),trim(EdtUser.Text),trim(EdtPass.Text)]);
try
ADOConnSQLServer.Open;
MsgBox('SQL Server数据库连接成功!')
except
MsgBox('SQL Server数据库连接失败!');
end;
--------------------next---------------------
阅读(295) | 评论(0) | 转发(0) |