(Gast)
n/a Beiträge
|
AW: Exception EReadError in Modul - Ungültiger Eigenschaftswert
14. Apr 2016, 13:38
FormCreate :
Delphi-Quellcode:
DefaultFont.Name := 'Tahoma';
DefaultFont.Size := 9;
Tables := TStringList.Create;
C := nil;
with TSQLConnection.RecordProps do
begin
AddFilterOrValidate('Ident', TSynFilterTrim.Create);
AddFilterOrValidate('Ident', TSynValidateText.Create);
// AddFilterOrValidate('Server',TSynValidateText.Create);
end;
MainCaption := Caption;
if (ParamCount = 1) and FileExists(paramstr(1)) then
begin
FN := paramstr(1);
if IsJetFile(FN) then
CmdLine := ctJet_mdbOLEDB
else if IsSQLite3File(FN) then
CmdLine := ctSqlite3
else
begin
ShowMessage(FN + '?', True);
exit;
end;
C := TSQLConnection.Create;
try
C.Connection := CmdLine;
C.Ident := S2U(FN);
C.Server := C.Ident;
TryConnect(C, True);
finally
C.Free;
end;
end
else
begin
Conns := TSQLRestStorageInMemory.Create(TSQLConnection, nil,
ChangeFileExt(ExeVersion.ProgramFileName, '.config'), false);
try
Conns.ExpandedJSON := True; // for better human reading and modification
Task.Title := MainCaption;
Task.Inst := sSelectAConnection;
Task.Content := sSelectOrCreateAConnection;
if Conns.Count = 0 then
Btns := [cbCancel]
else
begin
for i := 0 to Conns.Count - 1 do
Task.Selection := Task.Selection +
U2S(TSQLConnection(Conns[i]).Ident) + #10;
Btns := [cbOk, cbCancel];
Task.Query := U2S(TSQLConnection(Conns[0]).Ident);
Task.Verify := sUpdateConnection;
end;
Task.VerifyChecked := false;
Task.Buttons := sNew;
res := Task.Execute(Btns, 0, [], tiQuestion);
case res of
mrOk:
if Task.VerifyChecked then
begin
C := TSQLConnection(Conns[Task.SelectionRes]);
msg := Task.Verify;
end
else
TryConnect(TSQLConnection(Conns[Task.SelectionRes]), false);
100:
begin
C := TSQLConnection.Create;
msg := sNew;
end;
end;
if C <> nil then
with TRecordEditForm.Create(self) do
try
C.Password := Crypt(C.Password);
SetRecord(nil, C, nil, nil, sConnectionHints, 0, msg);
if ShowModal = mrOk then
begin
C.Password := Crypt(C.Password);
if TryConnect(C, True) and (res = 100) then
Conns.AddOne(C, false, '')
else if res = 100 then
FreeAndNil(C);
end
else
FreeAndNil(C);
finally
Free;
end;
finally
Conns.Free;
end;
end;
end;
|
|
Zitat
|