为什么组合框显示错误System.data.datarowview c#?

时间:2018-01-30 07:25:12

标签: c# combobox

我需要为患者调查更新组合框机器名称的值,当我从数据库中检索输入的机器名时,以下错误始终出现在system.data.datarowview中。 这是我的代码:

1-存储过程:

create proc [GET_RESULT_MACHINES]
@Criteria nvarchar(20)
AS 
SELECT machines.machine_id , MACHINE_NAME AS 'MACHINE NAME'  FROM MACHINES
inner join LAB_RESULTS on LAB_RESULTS.machine_id = Machines.Machine_id
where CONVERT(varchar,[LAB_RESULTS].ORDER_ID) = ''+@Criteria+''

2-班级c#void:

public DataTable GET_RESULT_MACHINES(string Criteria)
        {
            DAL.DataAccessLayer DAL = new DAL.DataAccessLayer();
            DataTable dt = new DataTable();

            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@Criteria", SqlDbType.VarChar,20);
            param[0].Value = Criteria;

            dt = DAL.SelectData("GET_RESULT_MACHINES", param);
            DAL.close();
            return dt;
        }

3- Key_Down按Enter键时出现空代码我正在使用以下代码:

private void txtOrder_KeyDown(object sender, KeyEventArgs e)
        {
            sqlconnection = new SqlConnection(@"server= KAASH-AV-SRV; database=mamlakalab; Integrated Security=true; ");

            if (checkInitialResult.Checked == true && checkApproveResult.Checked == false && txtOrder.Text != string.Empty && e.KeyCode == Keys.Enter )
            {
                dgvResult.DataSource = result.GetOrderForResult(txtOrder.Text);

                comboMachines.DataSource = result.GET_RESULT_MACHINES(txtOrder.Text);
                comboMachines.DisplayMember = "MACHINE_NAME";
                comboMachines.ValueMember = "machine_id";
            }
}

我检查了之前的问题,但我找不到答案 请你的建议。

1 个答案:

答案 0 :(得分:0)

答案是从机器名称中删除下划线谢谢你Nino

/projectb