Hi,

I am having a problem getting error messages from an update script if I run it using ODBC SQL Server. It happens when I use cursor and catch error on its excecution.
Below you can find an example that works perfectly fine when you use Query Analizer and fails (well it does not fail it seems like it does not proceed) in ODBC. I cannot get any warning messages that I am supposed to get (from PRINT or RAISERROR) from this code.

ODBC calls for this code: SQLPrepare, SQLExecute and catching errors using SQLGetDiagRec.

Results: In Query Analizer - full set of data
ODBC: "start" - only

Please not: I do procced all the messages in ODBC not the first one only. It shows multiple messages for other parts of the code.

Has anybody ran into this problem before? What the solution?
Thanks,


print 'start'
declare @categoryname nvarchar(15)
declare curQL cursor local for select distinct CategoryName from northwind.dbo.categories

if (@@error <> 0)
begin
print 'error on declare'
end
else
print 'declare success'

open curQL
print 1
if (@@error <> 0)
begin
print 'error on open'
end
else
print 'open success'

goto fetchCursor

while @@FETCH_STATUS <> -1
begin
if @@FETCH_STATUS <> -2
begin
print @categoryname
end
fetchCursor:
fetch next from curQL into @categoryname
if (@@error <> 0)
begin
print 'error on fetch'
end
else
print 'fetch success'
end
print 'end'
close curQL
deallocate curQL