QueryClass Query;
string UserName = "";
int UserId = 0;
string email = txtEmail.Text;
string name = txtUserName.Text;
string phone = txtPhone.Text;
byte[] buffer = new byte[100];
UserName = Query.GetUserName(email); //returns a string value
if (UserName != null)
{
MessageBox.Show(UserName + " is already in the database");
}
if (Query.AddNewUser(name, email, phone) == true) //returns a bool value
{
UserId = Query.GetUserId(email); //returns a int value
if (Query.AddNewImage(UserId, buffer) == true) //returns a bool value
{
MessageBox.Show("Done..!!");
}
}
MessageBox.Show("Error");
プログラムの挿入ボタン (コードの上) をクリックすると、次のエラーが表示されます。
System.NullReferenceException
Message="Object reference not set to an instance of an object."
次の場所でその例外が発生しています。(私は他の場所をチェックしませんでした)コードはこれらの場所を停止し、エラーを出します。
UserName = Query.GetUserName(email); //returns a string value
if (Query.AddNewUser(name, email, phone) == true) //returns a bool value
誰でもこのエラーを修正するのを手伝ってもらえますか? Visual Studio 2010 を使用しています。