我有以下代码。当我运行程序并运行一次带有参数的存储过程时223然后我用参数例如315 ant运行它,之后再次使用参数运行System.Data.DataRowView“而不是实际值。你可以帮我下面的吗?
private void GetServers()
{
IDBManager dbManager = new DBManager (DataProvider.SqlServer);
dbManager.ConnectionString = @"Data Source=server; Initial Catalog=base; Integrated Security = SSPI;";
try
{
dbManager.Open();
dbManager.CreateParameters(1);
dbManager.AddParameters(0,"@report_id", (txtReportID.Text));
DataSet ds = new DataSet("Servers");
ds = dbManager.ExecuteDataSet(CommandType.StoredProcedure, "sp_get_servers_from_report_test");
if (ds.Tables[0].Rows.Count > 0)
{
chkdListBoxServers.DataSource = ds.Tables[0];
chkdListBoxServers.DisplayMember = "Servers";
chkdListBoxServers.ValueMember = "server_name";
}
else
{
MessageBox.Show("No servers or incorrect report id");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
dbManager.Dispose();
}
}
答案 0 :(得分:1)
我猜chkdListBoxServers.DisplayMember = "server_name";
会好的。
答案 1 :(得分:0)
替换为此代码
//DataSet ds = new DataSet("Servers"); //delete this
var ds = dbManager.ExecuteDataSet(CommandType.StoredProcedure, "sp_get_servers_from_report_test");