I'm dealing with following code
private void tbMemberID_TextChanged(object sender, EventArgs e)
{
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());
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
When I insert memberID
, it shows error
object reference is not set to an instance of object
Is something wrong with my code?