ArgumentNullException未处理....在下面的代码中需要一个解决方案

时间:2016-01-01 09:15:06

标签: c# datagridview

以下代码导致ArgumentNullException。为什么呢?

private void textBox1_KeyUp(object sender, KeyEventArgs e)
    {
        //SELECT Job_no, Order_No, Revision, DesignSpec, Engine_Type, LE_IN_Designer, 
        //       CPH_Designer, Exp_Del_Week, Action_code, Rev_Description, Ref_pattern, 
        //       Name_of_mock_up, EPC_Drawing, Turbocharger_no_Type, Engine_Specific_Requirement, 
        //       Draft_sketch_with_details, Air_cooler_type, Description_of_Job 
        // FROM JDS_Data WHERE AUR_No 

        string str = "SELECT * fROM JDS_Data WHERE AUR_No like '" + textBox1.Text + "%'";
        OleDbDataReader dr = mdlconnection.getRecord(str);
        DataTable dt = new DataTable();
        dt.Load(dr);
        dataGridView1.DataSource = dt;
    }

1 个答案:

答案 0 :(得分:-1)

请准确地说,您打算做什么。我建议你把你的代码放在try ... catch块中

try
{
    //code goes here
}
Catch(exception e) 
{
  MessageBox.Show(e.Message);
}