我想在插入会员ID时自动填充/填写会员名称 我在成员ID的文本更改事件上处理以下代码 -
try
{
//int RowsAffected = 0;
DataAccess oDataAccess = new DataAccess();
con.Open();
oDataAccess.cmd.CommandText = "SELECT MemberName FROM AccountInfo where MemberID='" + tbMemberID.Text + "'";
oDataAccess.cmd.Connection = con;
tbMemberName.Text = ((string)cmd.ExecuteScalar());
//@this line it shows error - object reference not set to an instance of object
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}