下面是个简单易学的ADO带密码的数据连接、查询一个记录集、执行一SQL语句教程,小编详细图解介绍包你轻松学会,喜欢的朋友赶紧get起来吧!
unit UDataModule;
interface
uses
Controls,SysUtils, Classes, DB, ADODB,windows,forms,CustomCom_TLB;
type
TDataModule1 = class(TDataModule)
ADOConnection1: TADOConnection;
dsDataSet: TADODataSet;
ADOQuery1: TADOQuery;
procedure DataModuleCreate(Sender: TObject);
private
{ Private declarations }
public
;
{ Public declarations }
end;
var
DataModule1: TDataModule1;
loginMan : string;
;
;
myCom : ICustomMG ; // COM 对象
function OpenSQL(s: string;):integer;
function DoSQL(s: string;):boolean;
implementation
{$R *.dfm}
procedure (Sender: TObject);
var SQL,;
begin
//连接ADO
try
pwd := 'deliSerial';
SQL := 'Provider= Source='+
extractfilepath(paramstr(0))+'+
';Persist Security Info=False;' +
'Jet Password="'+pwd+'"';
:= false;
:= SQL;
:= true;
ConnOK:=true;
except
ConnOK:=false;
end;
end;
function OpenSQL(s: string;):integer;
var ;
begin
old_Cursor:=;
:=crSQLWait;
try
try
with query do
begin
close;
commandtext:=s;
open;
result:=;
end;
except
result:=0;
end;
finally
:=old_Cursor;
end;
end;
function DoSQL(s: string;):boolean;
var ;
begin
result:=true;
old_Cursor:=;
:=crSQLWait;
try
try
with query do
begin
close;
;
();
ExecSQL;
end;
except
result:=false;
end;
finally
:=old_Cursor;
end;
end;
end.