![](/img/trans.png)
[英]c# - SqlConnection InfoMessage triggering only at end of execution
[英]Using InfoMessage to display SQL Server messages in C#
我希望將消息從SQL Server存儲過程打印出來,並顯示在C#的列表框中。 使用InfoMessage
是一個好的開始嗎?
我正在使用SqlConnection,SqlCommand和SqlDataReader連接到數據庫。
這是您問題的一個很好的例子。
public DataTable MyExample(string connectionString)
{
DataSet ds = new DataSet();
using (DALHelper dal = new DALHelper(connectionString))
{
try
{
dal.OpenDB();
ParameterInfo[] param = new ParameterInfo[0];
ds = dal.ExecuteDataSet("StoredProcedure", CommandType.StoredProcedure, param);
}
//Here where message goes. if there's an error. So it's up to you.
catch (Exception er)
{
throw er;
}
finally
{
//Here is, if successful..
//Do the Code here....
}
}
}
我希望這個能幫上忙! ^ _ ^
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.