C#中throw处出现未处理 System.NullReferenceException该怎么解决
namespace Hotel{
public partial class LoginForm : Form
{
public LoginForm()
{
InitializeComponent();
}
String strConn = string.Empty;
private void LoginForm_Load(object sender, EventArgs e)
{
strConn = "server=.;database=HotelManagement;uid=sa;pwd=123;";
}
private void btnOK_Click(object sender, EventArgs e)
{
SqlConnection mySqlConnection = new SqlConnection();
mySqlConnection.ConnectionString = strConn;
try
{
object ReturnValue = null;
mySqlConnection.Open();
SqlCommand mySqlCommand = new SqlCommand();
= "select AdminPwd from Administrator where AdminID='" + textBox1.Text + "'";
mySqlCommand.Connection = mySqlConnection;
ReturnValue = mySqlCommand.ExecuteScalar();
string pwd = ReturnValue.ToString();
if (pwd == textBox2.Text)
MessageBox.Show("OK");
else
MessageBox.Show("NO");
}
catch
{
throw;
}
finally
{
mySqlConnection.Close();
}
}
}
}
求高手