代码拉取完成,页面将自动刷新
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.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。