June 10, 2005 at 12:00 pm
Alas, why this proc i cant capture the print 'hello' ?????????
create proc SP_test
as
begin
select '1'
print 'hello'
select '2'
end
----------------------------------------------------------------------
My visual script
--------------------------------------------------------------------------
on error goto error:
Set cnn1 = New ADODB.Connection
cnn1.ConnectionString = "driver={SQL Server};" & _
"server=" & Trim(server) & ";uid=" & Trim(login) & ";pwd=" & Trim(pwd) & ";database=" & Trim(base)
cnn1.ConnectionTimeout = 120
cnn1.Open
Set reg = New ADODB.Recordset
Set reg = cnn1.Execute("exec SP_test")
error:
Dim Err As error
For Each Err In cnn1.Errors
MsgBox Err.Description & " : " & Err.Source & " : " & Err.SQLState & " : " & Err.Number
Next
cnn1.Close
But if i take out the 'selects' i can do it
create proc SP_test
as
begin
print 'hello'
end
June 10, 2005 at 12:03 pm
Hey dude, you don't need to start 5 threads for the same question. You'll get your answer, don't worry.
June 10, 2005 at 12:11 pm
Ok sorry, i will say to the wemaster that delete this
June 10, 2005 at 12:28 pm
Why can't you use a select to do this already?
June 10, 2005 at 12:28 pm
Just don't start another one .
June 10, 2005 at 12:42 pm
the problem consists in that if exists some 'select' before the print, the print can not be captured, it does not show nothing...........
with this i can capture 'Hello'
create proc SP_test
as
begin
print 'hello'
end
this i canot do it !
create proc SP_test
as
begin
select '1'
print 'hello'
end
the select avoid the capture????......
June 10, 2005 at 12:46 pm
See my other answer in the other thread.
I've given you what I found... But I don't see how this can be done in vba. I suspect it can be done in .NET, but I still wouldn't know how...
June 10, 2005 at 1:12 pm
Thank you a lot of i have to invite some beer for my disturbings......
June 10, 2005 at 1:21 pm
No thanx... I don't drink.
June 10, 2005 at 7:08 pm
Hector I am a little confused do you want to have the sp print the variable in vb or in query analyzer? Your offer of a cold beer reminded me that it was time for one so cheers. Let me know where you want your printed output.
Mike
June 10, 2005 at 7:44 pm
That's exactly why I didn't want him to pen 5 threads for this problem.
IIRC, he wanted to be able to show the print messages (probabely for debuging) client side, in a msgbox. He didn't say much more than that except that he couldn't change the application but could alter the procs.
June 11, 2005 at 4:48 am
Check BOL for Handling Errors and Messages in ADO . Index key word error object. The example uses a list object to store the error values but it should be simple to modify this code to place a string in a message box to display the error information. Also check BOL under RAISEERROR.
HTH Mike
June 11, 2005 at 5:01 am
Any thing printed in back ground like the string you have printed or the record count which query processor through create problem in vba.
That is why its good practice to suppress this sort of prints by setting nocount on and ansiiwarning off
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply