摘要:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { webCrm.SAG tmp = new webCrm.SAG(); protected void Page_Load(object sender, EventArgs e) { /*获取 sql print的消息信息*/ string connectionString = "data source=***********;initial catalog=boss;user id=sa;password=erp;"; using (SqlConnection sqlcon = new SqlConnection(connectionString)) { sqlcon.Open(); sqlcon.InfoMessage += new SqlInfoMessageEventHandler(OnReceivingInfoMessage); /* 查询某个表上的索引碎片的详细信息 */ SqlCommand cmd = new SqlCommand("print '输出消息1'; set statistics io on ;select * from [ierror] ; print '输出sql消息完毕'", sqlcon); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); } Console.Read(); } private void OnReceivingInfoMessage(object sender, SqlInfoMessageEventArgs e) { Response.Write("输出sql消息:" + e.Message.ToString()); } } }
----------------------输出------------------------------------------------------------------------- |
|