SQL query does not run via host monitor

General chat about HostMonitor (all messages posted before March 07, 2003 available here).
unclelude
Posts: 20
Joined: Wed Jan 22, 2003 6:00 pm

Post by unclelude »

Alex,

I downloaded the file and now I am using HM 3.65

Tried, but same error "Incorrect Syntax near 'emmWirelessType_EwnIDFK' with and without SQLFetch... option.

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

Post by KS-Soft »

I checked code, documentation, and web forums. But now I am out of ideas, I don't know what can be wrong :sad:

Regards
Alex
Guest

Post by Guest »

When trying the ODBC query test on my end, I found that the entire statement had to be on the same line. Unlike in Query Analyzer where you can put parts of the query on seperate lines for easier viewing. I just pasted it into notepad, turned wordwrap off, and made sure it was all on one line.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You can use many lines, HostMonitor makes single line anyway (at least latest version).

Regards
Alex
unclelude
Posts: 20
Joined: Wed Jan 22, 2003 6:00 pm

Post by unclelude »

Hi Alex,

You are correct, HM expects all the code in one line. I tried your suggestion and it worked. I am very greatful for your help.

Thanks,

Adnan
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Ok, I found what was wrong. HostMonitor makes one line from multiline query. But HM just removed 0A and 0D characters and did not insert spaces. My testing multiline requests work because I usually use space in first position for any line except first. Very simple error, I just had to look into right place :smile: Thanks
Update available at http://www.ks-soft.net/download/hm366.zip

Regards
Alex
unclelude
Posts: 20
Joined: Wed Jan 22, 2003 6:00 pm

Post by unclelude »

Hi Alex,

I think the code needs a little bit of tweeking. If you have a couple of lines of SQL code in HM, it removes the space between the lines. For example, the code

select * from tbl1
where a = 1

will become
select * from tbl1where a = 1

to test it, enter few lines of code in HM, then do a cut/paste in notepad without word wrap and you will know what I am referring to.

If I have a code that works in other ODBC applications, should it always work in HM as well, or are there some exceptions ? Should the following work in HM ?

declare @counter1 int,@counter2 int
set @counter1 = (select count(*) from tbl1..tblWooWorkorder)
set @counter2 =(select * from openrowset('SQLOLEDB','ServerName';'username';'password',
'SELECT count(*) FROM tbl2.dbo.tblWooWorkorder ') )

if @counter1 = @counter2
begin
print 0
end
else
begin
print 1
end

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

Post by KS-Soft »

>to test it, enter few lines of code in HM, then do a cut/paste in notepad without word wrap and you will know what I am referring to.

Please, check my message above. There is patch available :smile:

>Should the following work in HM ?

I don't know, it depends on driver and server. HostMonitor does not care about syntax of the query. It just send ONE statement to ODBC driver and get responce.

Regards
Alex
jricha34
Posts: 59
Joined: Sun Jul 07, 2002 6:00 pm
Location: USA

Post by jricha34 »

This is probably late by the ODBC command line test tool for SQL Server is OSQL. It comes with SQL Server.
Locked