【发布时间】:2015-12-17 04:08:50
【问题描述】:
我有这个调用存储过程的方法。我的问题是它没有返回一行,但它打印了一条消息。我正在尝试将该打印消息捕获到一个变量中。我的问题是我以前从未使用过InfoMessage,我在网上查看了它,我这辈子似乎无法理解它。有人可以帮助我或指出正确的方向吗?
这是我的代码:
public List<showWhatClass> showWhatMethod(string deviceWhat, int tagWhat, Decimal latit, Decimal longit, int Process, string CallNext, int CallNextVar)
{
showWhatCell = new List<showWhatClass>();
try
{
using (connection = new SqlConnection(connectionString))
{
using (SqlCommand command = new SqlCommand("iosShowWhat", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@DeviceId", deviceWhat);
command.Parameters.AddWithValue("@TagId", tagWhat);
command.Parameters.AddWithValue("@Latitude", latit);
command.Parameters.AddWithValue("@Longitude", longit);
command.Parameters.AddWithValue("@Process", Process);
command.Parameters.AddWithValue("@CallNext", CallNext);
command.Parameters.AddWithValue("@CallNextVar", CallNextVar);
connection.Open();
/*SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
showWhatClass item = new showWhatClass();
item.CallNext = reader.GetValue(0).ToString();
item.CallNextVar = (int)reader.GetValue(1);
showWhatCell.Add(item);
}*/
}
}
}
finally
{
connection.Close();
}
return showWhatCell;
}
我尝试了以下方法:
connection.Open();
connection.InfoMessage += delegate(object sender, SqlInfoMessageEventArgs e)
{
showWhatClass item = new showWhatClass();
item.CallNext += "\n" + e.Message;
showWhatCell.Add(item);
};
什么都不返回。
【问题讨论】:
-
你打印什么值?
-
CallNext 和 CallNextVar
-
@MairajAhmad 我正在尝试打印 CallNext 和 CallNextVar
标签: asp.net sql-server stored-procedures