2 Star 8 Fork 3

闲散居士/数据库备份

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
U_datamod.pas 2.54 KB
一键复制 编辑 原始数据 按行查看 历史
闲散居士 提交于 2021-12-08 10:58 . 清理源码注释
unit U_datamod;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, ADODB;
type
TDM_Main = class(TDataModule)
Database1: TADOConnection;
Query1: TADOQuery;
private
{ Private declarations }
public
{ Public declarations }
end;
var
DM_Main: TDM_Main;
function StartMulSelect(user,pass,serv,sqlstr:pchar;var inSelectValues:TStrings; isOnlyOne:Boolean=false):TStrings;stdcall;
function GetStringsList(user,pass,serv,sqlstr:pchar):TStrings;stdcall;
function GetADOConnectString(user, pass, serv: String): String;
procedure QueryClose(dataset: TDataset);
procedure setDatabaseParam(u, p, s: String);
implementation
uses mulselect;
{$R *.DFM}
function GetADOConnectString(user,pass,serv:String):String;
begin
Result:='Provider=MSDAORA.1;Persist Security Info=True;'
+'User ID='+user+';Password='+pass+';Data Source='+serv;
end;
procedure QueryClose(dataset: TDataset);
begin
if not dataset.Active then exit;
try
if (dataset is TADOQuery) and (dataset.Eof) then
dataset.Last
else if (dataset is TADOQuery) and (dataset.Bof) then
dataset.First;
dataset.Close;
except end;
end;
procedure setDatabaseParam(u,p,s:String);
var con:String;
begin
con:=DM_Main.Database1.ConnectionString;
If (pos(';User ID='+u+';',con)>0)
and (pos(';Password='+p+';',con)>0)
and (pos(';Data Source='+s,con)>0)
Then
exit;
DM_Main.Database1.Connected:=false;
DM_Main.Database1.ConnectionString:=GetADOConnectString(u,p,s);
end;
function StartMulSelect(user,pass,serv,sqlstr:pchar;var inSelectValues:TStrings; isOnlyOne:Boolean=false):TStrings;
var selectValues:TStrings;
begin
setDatabaseParam(user,pass,serv);
DM_Main.Query1.Close;
DM_Main.Query1.SQL.Text:=sqlstr;
DM_Main.Query1.Open;
selectValues:=MulSelectForm.StartSelect(DM_Main.Query1,inSelectValues,isOnlyOne);
result:=selectValues;
end;
function GetStringsList(user,pass,serv,sqlstr:pchar):TStrings;
var
s:String;
r:TStrings;
begin
r:=TStringList.Create;
If sqlstr='' Then Exit;
setDatabaseParam(user,pass,serv);
ShowMessage(sqlstr);
try
DM_Main.Query1.Close;
DM_Main.Query1.SQL.Text:=sqlstr;
DM_Main.Query1.Open;
while Not DM_Main.Query1.Eof do
begin
s:=DM_Main.Query1.fields[0].AsString;
R.Add(s);
DM_Main.Query1.Next;
end;
QueryClose(DM_Main.Query1);
except
end;
result:=r;
end;
end.
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Delphi
1
https://gitee.com/xyxia/oraback.git
git@gitee.com:xyxia/oraback.git
xyxia
oraback
数据库备份
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385