怎样实现在程序中动态的连接数据库?
使用dbexpress中的TSQLConnection连接数据库时怎样写动态代码连接,不是在IDE中设置选项,我是这样做的:
procedure TForm1.FormCreate(Sender: TObject);
var
Str:TStrings;
con:TSQLConnection;
begin
try
str:=TstringList.Create;
str.Add('DriverName=Oracle');
str.Add('DataBase=adv');
str.add('User_Name=djw');
str.add('Password=djw');
str.add('RowsetSize=20');
str.add('BlobSize=-1');
str.add('ErrorResourceFile= ');
str.add('LocaleCode=0000');
str.add('Oracle TransIsolation=ReadCommited');
str.Add('OS Authentication=False');
str.Add('Multiple Transaction=False');
str.Add('Trim Char=False');
//ShowMessage(str.Text);
con:=TSQLConnection.Create(self);
con.Params:=str;
con.ConnectionName:='OracleConnection';
con.DriverName:='Oracle';
con.GetDriverFunc:='getSQLDriverORACLE';
con.LibraryName:='dbexpora.dll';
con.VendorLib:='oci.dll';
con.LoginPrompt:=false;
con.Connected:=true;
ShowMessage('Success');
str.Free;
except
on E:Exception do
ShowMessage(E.Message);
end;
end;
提示'Missing DriverName property'错误。