1
我正在執行這個存儲過程,我想改變它,而不是僅僅返回所有結果,然後處理它們。我想從存儲過程的第三列返回並顯示信息到我的winforms應用程序的label.text中。我怎麼去做這件事。執行SqlCommand語句並在標籤中顯示結果
public IEnumerable GetGuids(int id)
{
using (SqlCommand _command = new SqlCommand("StoredProc"))
{
_command.Connection = new SqlConnection(conString);
_command.Connection.Open();
_command.CommandType = CommandType.StoredProcedure;
_command.Parameters.AddWithValue("@ItemID", id);
return _command.ExecuteReader();
}
}
我想顯示,這將在第3列從存儲過程如下返回的項目:itemRow1/itemRow2。
應該有()在'結束List ...'我也收到一個錯誤,說明不能從'object'轉換爲'string' for'items.Add(reader [2])' –
Masriyah
看到我的更改。 – Jonesopolis
完美地工作 - 謝謝! – Masriyah