System.NullReferenceException:'对象引用未设置为对象的实例。博士为空

时间:2019-12-05 12:18:06

标签: c#

private void LoadData()
        {
            cmd.CommandText = "Select Eno,Ename,Job,Salary,Status from Employee order by Eno";
            dr = cmd.ExecuteReader();
            ShowData();
        }
        private void ShowData()
        {
            if (dr.Read())
            {
                textBox1.Text = dr[0].ToString();
                textBox2.Text = dr[1].ToString();
                textBox3.Text = dr[2].ToString();
                textBox4.Text = dr[3].ToString();
                checkBox1.Checked = Convert.ToBoolean(dr[4]);
            }
            else
            {
                MessageBox.Show("No Data Exist");
            }
        }

0 个答案:

没有答案