Page 1 of 1
ZSQLMonitor error.
Posted: 19.12.2016, 02:42
by delphiec
When I actovate ZSQLMonitor my application is crash.
Problem was described here:
https://sourceforge.net/p/zeoslib/tickets/182/
How can I get SQL errors without using ZSQLMonitor?
Re: ZSQLMonitor error.
Posted: 20.12.2016, 09:47
by marsupilami
Hello delphiec,
it seems that TZSQLMonitor is not thread safe. But it is meant to be used as a debugging component for fining communication problems between your application and the database anyway.
SQL Errors usually should be raised as Exceptions that you can catch in your code and then log with a logging mechanism of your choice?
With best regards,
Jan
Re: ZSQLMonitor error.
Posted: 20.12.2016, 15:32
by delphiec
No, it is created in each stream separately.
Maybe I Do not know about some of the nuance. Or I need to enable some option?
Can you show example?
Re: ZSQLMonitor error.
Posted: 20.12.2016, 19:33
by marsupilami
Hello delphiec,
TZSQLMonitor is not a good component for doing what you want. You might want something like this:
Code: Select all
unit test
interface
procedure DoSomeThing;
procedure LogError(Message: String);
var
CriticalSection: TCriticalSection;
implementation
procedure DoSomeThing;
begin
// do soemthing that is not dbrelated here...
try
// do something db related here
except
on E: Exception do begin
LogError(E.Message);
end;
end;
end;
procedure LogError(Message: String);
var
LogFile: TextFile;
begin
try
CriticalSection.Enter;
AssignFile(TextFile, 'C:\test.log');
Append(TextFile);
Writeln(TextFile, Now, ' ', Message);
CloseFile(LogFile);
finally
CriticalSection.Leave;
end;
end;
initialization
CriticalSection := TCriticalSection.Create;
finalization
FreeAndNil(CriticalSection);
end.
Beware: This code was written without testing or even reading the delphi help files. But it should show you what I mean.
Re: ZSQLMonitor error.
Posted: 20.12.2016, 20:46
by delphiec
I wanna get sql error, but code above don't let me.
Re: ZSQLMonitor error.
Posted: 21.12.2016, 09:50
by marsupilami
Hello delphiec,
what exactly do you mean by sql error? What is your environment (Database, Zeoslib driver, Delphi / Lazarus version)? What is captured by TZSQLMonitor that doesn't get into the exception. Can you maybe post a log and higlight in there what information you want to have?
With best regards,
Jan
Re: ZSQLMonitor error.
Posted: 21.12.2016, 11:45
by delphiec
Zsqlmonitor code in "try except end" is experimental code, I need to get sql-server errors.
But if I set ZSQLMonitor1.Active:=true;, I get "double free or corruption error". Something wrong into ZSQLMonitor module.
Re: ZSQLMonitor error.
Posted: 21.12.2016, 17:59
by marsupilami
You don't need TZSQLMonitor to get SQL Server Errors. SQL Server Errors will be raised as Exceptions.