0

我有以下代码。当我运行程序并使用参数(例如 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();
        }
    }
4

2 回答 2

1

我想chkdListBoxServers.DisplayMember = "server_name";会没事的。

于 2013-03-15T13:59:00.303 回答
0

用此代码替换

//DataSet ds = new DataSet("Servers"); //delete this

            var ds = dbManager.ExecuteDataSet(CommandType.StoredProcedure, "sp_get_servers_from_report_test");              
于 2013-03-15T12:35:17.843 回答