Advanced Logs: ODBC Insert with _'_ Char

General chat about HostMonitor (all messages posted before March 07, 2003 available here).
Locked
user24
Posts: 2
Joined: Wed Sep 11, 2002 6:00 pm

Post by user24 »

I use a SQL-Server-Table to write LOG-Messages.
The QUERY-String is "Insert into tbl_Hostmon_Log (Datetime, testname, status, reply, SimpleStatus) VALUES ('%DateTime%', '%TestName%', '%Status%', '%Reply%', '%SimpleStatus%')"

This works fine, but if there ist a _'_ in the Reply-Field of HM (in NT-Log-Test very often), the QUERY fails because the _'_ is for SQL a Text-Delimeter.
Is there any Workaround ?

<font size=-1>[ This Message was edited by: user24 on 2002-09-12 04:19 ]</font>

<font size=-1>[ This Message was edited by: user24 on 2002-09-12 06:17 ]</font>
simonl
Posts: 49
Joined: Wed Apr 03, 2002 6:00 pm
Contact:

Post by simonl »

Change data type char to varchar or nvarchar.
user24
Posts: 2
Joined: Wed Sep 11, 2002 6:00 pm

Post by user24 »

Thats not the Solution.
The Reply-Field of the SQL-Server-Table is already Text-Type.
The Problem is:
The QUERY-String is "Insert into tbl_Hostmon_Log (Datetime, testname, status, reply, SimpleStatus) VALUES ('%DateTime%', '%TestName%', '%Status%', '%Reply%', '%SimpleStatus%')"

The Macro of HM replaces the Field-Names with the Value.
If the Reply-Field contains "This is a 'Test' for me", then the QUERY-String looks like:
"Insert into tbl_Hostmon_Log (... VALUES ('...', '...', '...', 'This is a 'Test' for me', '...')".
The ' near "Test" produce the Error.
If HM can konvert ' to '', then i think it Works.

Help me please...
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Please try the patch at http://www.ks-soft.net/download/hm327.zip
This version can replace any characters in "Reply" field to any other. Just add 2 lines in hostmon.ini file, section [Misc].
[Misc]
SubstituteFieldFrom= '
SubstituteFieldTo = "

BTW you can replace several characters. E.g. if you want to replace '1' to 'A', '2' to 'B', '3' to 'C', add follow lines:
SubstituteFieldFrom= 123
SubstituteFieldTo = ABC

Regards
Alex
Locked