library adodll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
IniFiles,
StdCtrls,
ComCtrls,
DB,
ADODB,
ExtCtrls;
type
TADOC = class(TAdoconnection)
private
{ Private declarations }
public
{ Public declarations }
end;
var
ADOC:TADOC;
{$R *.res}
procedure FADOCFREE()stdcall;
begin
adoc.Free;
end;
procedure FADOC(CCMESSAGE,CFMESSAGE,sServer, sDBLogin, sLoginPass, sDBName: String;LoginPrompt,KeepConnection:boolean;ConnectionTimeout:integer) stdcall;
var
ConnPerfix, ConnAftFix: String;
begin
begin
if sDBName='' then
SDBName:='Master';
if sDBLogin<>'' then
begin
//如果使用SQL SERVER验证
ConnPerfix := 'Provider=SQLOLEDB.1;Password='+sLoginPass+';Persist Security Info=false;User ID='+sDBLogin+';Initial Catalog=';
ConnAftFix := ';Data Source='+sServer;//这一段为True则保存密码
end else
begin
//如果使用NT验证
ConnPerfix := 'Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=';
ConnAftFix := ';Data Source='+sServer;//
end;
end;
ADOC:=TADOC.Create(application);
ADOC.LoginPrompt:=LoginPrompt;
ADOC.KeepConnection := KeepConnection;
ADOC.ConnectionTimeout := ConnectionTimeout;
ADOC.ConnectionString:=ConnPerfix+sDbName+ConnAftfix;
try
ADOC.Connected:=True;
showmessage('CCMESSAGE')
except
showmessage('CFMESSAGE')
end;
end;
exports
FADOC;
FADOCFREE;
begin
end.