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?
ZSQLMonitor error.
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: ZSQLMonitor error.
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
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.
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?
Maybe I Do not know about some of the nuance. Or I need to enable some option?
Can you show example?
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: ZSQLMonitor error.
Hello delphiec,
TZSQLMonitor is not a good component for doing what you want. You might want something like this:
Beware: This code was written without testing or even reading the delphi help files. But it should show you what I mean.
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.
Re: ZSQLMonitor error.
I wanna get sql error, but code above don't let me.
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: ZSQLMonitor error.
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
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.
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.
But if I set ZSQLMonitor1.Active:=true;, I get "double free or corruption error". Something wrong into ZSQLMonitor module.
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: ZSQLMonitor error.
You don't need TZSQLMonitor to get SQL Server Errors. SQL Server Errors will be raised as Exceptions.