The Print statement is a little different than the select, it doesn't
actually return the printed information as part of the returned records, it
is returned as a message.
This piece of code will display the message in a popup dialog.
this.sqlConnection1.ConnectionString = "<your connection string>";
this.sqlConnection1.InfoMessage += new
System.Data.SqlClient.SqlInfoMessageEventHandler(this.InfoMessage);
private void btnRunQuery_Click(object sender, System.EventArgs e)
{
this.sqlConnection1.Open();
this.sqlSelectCommand1.ExecuteNonQuery();
this.sqlConnection1.Close();
}
private void InfoMessage(object sender,
System.Data.SqlClient.SqlInfoMessageEventArgs e)
{
// This event will be fired when a message is sent from the
SQL Server -
including
// message "Printed" with the PRINT function.
MessageBox.Show(e.Message);
}
-----Original Message-----
From: T. Bradley Dean [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 04, 2002 8:47 PM
To: dotnet
Subject: RE: Getting results of SQL stored procedure 'Print' statements
>This allow you to send a string of your choosing
That's exactly what I'm doing. But how do I retrieve that string? My
stored procedure always returns strings through the print statement - it
never returns any records.
~Brad
-----Original Message-----
From: Tom Vande Stouwe [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 04, 2002 3:27 PM
To: dotnet
Subject: RE: Getting results of SQL stored procedure 'Print' statements
The PRINT function does not 'Print' it is a term in TSQL to mean the
same as select, with out the need for a query. This allow you to send a
string of your choosing without using a variable and select.
The SP uses Print statements to format screen output
If (Select count (*)
From tblMessages
Where ...conditions...) > 0
Begin
Print 'Messages with Charles Carroll as Sender'
Select msgno MsgNumber
, msgsubj Subject
, msgDate Date
from tblMessages
Where ...conditions...)
End
Else
Print 'No messages from Charles Carroll are in the message base'
This will produce a headline and then the records if there are messages,
or the line that there are no message if not.
Tom
-----Original Message-----
From: T. Bradley Dean [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 04, 2002 4:51 PM
To: dotnet
Subject: RE: Getting results of SQL stored procedure 'Print' statements
No, Err.Number is 0 and Err.Description is blank.
~Brad
-----Original Message-----
From: David L. Penton [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 04, 2002 7:17 AM
To: dotnet
Subject: RE: Getting results of SQL stored procedure 'Print' statements
Check the errors collection. IIRC, PRINT statements will be there.
David L. Penton, Microsoft MVP
JCPenney Application Specialist / Lead
"Mathematics is music for the mind, and Music is Mathematics for the
Soul. - J.S. Bach" [EMAIL PROTECTED]
Do you have the VBScript Docs or SQL BOL installed? If not, why not?
VBScript Docs: http://www.davidpenton.com/vbscript
SQL BOL: http://www.davidpenton.com/sqlbol
-----Original Message-----
From: T. Bradley Dean [mailto:[EMAIL PROTECTED]]
I've created a SQL stored procedure that, instead of return a recordset,
"Print"s out it's results. The problem is, I can't see these results
anywhere but in the SQL Query Analyzer!
I'm using ASP.net with VB.net code, I've tried doing a Scalar Command
and also just a regular SQLDataReader, both return nothing.
Any tips would be appreciated.
Thanks,
~Brad
---
You are currently subscribed to dotnet as: [EMAIL PROTECTED] To
unsubscribe send a blank email to %%email.unsub%%
---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search Subscription
Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/
---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%
---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search Subscription
Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/
---
You are currently subscribed to dotnet as: [EMAIL PROTECTED] To
unsubscribe send a blank email to
%%email.unsub%%
---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search Subscription
Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/
---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to %%email.unsub%%
---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/
---
You are currently subscribed to dotnet as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/