(*1)-There is no way to know if connected successfully,
even without a server running it does not generate exception.
(*2)-In INSERT with invalid data, not write, and does not generate exception.
(*3)-There is a problem when used in the conversion and enhancement of characters Portuguese WIN1252.
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
try
ZConnection1.connect;
except
begin
showmessage('Could not open database (1)'); //(*1)does not generate exception
exit;
end;
end;
if not ZConnection1.Connected then
begin
showmessage('Could not open database (2)'); //(*1)true is not connecting
exit;
end;
Zconnection1.StartTransaction;
ZQuery1.SQL.Clear;
ZQuery1.SQL.Append('insert into TBFRUTAS (');
ZQuery1.SQL.Append('FRU_ID, ');
ZQuery1.SQL.Append('FRU_NAME, ');
ZQuery1.SQL.Append('FRU_DATE ');
ZQuery1.SQL.Append(') VALUES( ');
ZQuery1.SQL.Append('3, ');
ZQuery1.SQL.Append(Quotedstr('maçã') + ','); {"maçã" recorded in the database (*3)}
//ZQuery1.SQL.Append(Quotedstr('05/29/2009') + ')');
ZQuery1.SQL.Append(Quotedstr('05*x9/2x09') + ')'); {is wrong does not generate an error or exception (*2)}
try
Begin
ZQuery1.ExecSQL;
Zconnection1.Commit;
end
except On E:Exception do
Begin
Zconnection1.Rollback;
MessageDlg(E.Message, mtError, [mbCancel], 0);
exit;
end
end;
end;
end.
Code: Select all
function PrepareStatement(PlainDriver: IZInterbasePlainDriver;
Handle: PISC_DB_HANDLE; TrHandle: PISC_TR_HANDLE; Dialect: Word;
SQL: string; var StmtHandle: TISC_STMT_HANDLE):
TZIbSqlStatementType;
var
StatusVector: TARRAY_ISC_STATUS;
StatementTmp :Ansistring;
begin
{ Allocate an sql statement }
PlainDriver.isc_dsql_alloc_statement2(@StatusVector, Handle, @StmtHandle);
CheckInterbase6Error(PlainDriver, StatusVector, lcExecute, Sql);
{ Prepare an sql statement }
{$IFDEF DELPHI12_UP}
StatementTmp := UTF8String(SQL);
PlainDriver.isc_dsql_prepare(@StatusVector, TrHandle, @StmtHandle,
// 0, PAnsiChar(UTF8String(SQL)), Dialect, nil); {<<problem}
0, PAnsiChar(StatementTmp), Dialect, nil); {<<solution}
{$ELSE}
PlainDriver.isc_dsql_prepare(@StatusVector, TrHandle, @StmtHandle,
0, PAnsiChar(SQL), Dialect, nil);
{$ENDIF}
CheckInterbase6Error(PlainDriver, StatusVector, lcExecute, SQL);
{ Set Statement Type }
Result := GetStatementType(PlainDriver, StmtHandle);
if Result in [stUnknown, stGetSegment, stPutSegment, stStartTrans] then
begin
FreeStatement(PlainDriver, StmtHandle, DSQL_close);
raise EZSQLException.Create(SStatementIsNotAllowed);
end;
end;