Retrieving database messages (for example, Print outputs, but not error messages) in ADO

I am using ASP 3.0 for IIS 7 and SQL Server 2008 as my dbms. I have a stored procedure encoded in SQL Server. I have some Print instructions, as well as a select statement that returns a set of records after the procedure. I can get a recordset using

Set recordSet = Server.CreateObject ("ADODB.RecordSet")

recordSet.Open "Run my_procedure", dbConn

What I want to do is get the output from the Print statements that I execute in the stored procedure. Please help. Thanks in advance!

+4
source share
2 answers

In ADO, the output from PRINT statements is entered into the Errors collection, so you just need to go through this collection

 Dim e For Each e In dbConn.Errors Response.Write e.Description Next 
+4
source

You can try to use the SqlInfoMessage event to catch the print statement from the connection object.

 SQLConnection.InfoMessage += delegate(object sender, SqlInfoMessageEventArgs e) { string printresponse = e.Message; }; 

You can get more information at this link, http://www.dotnetcurry.com/ShowArticle.aspx?ID=344

Hope this helps.

+1
source

Source: https://habr.com/ru/post/1391195/


All Articles