LoginSignup
x9jdzhcc72mxib2azgcyo
@x9jdzhcc72mxib2azgcyo

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

DB一致チェックのエラー文

解決したいこと

vs2017 でDBを接続してログイン認証チェック(id,pw)をしています。DBにid,pwの値が存在しない場合に”このidは存在しません”と表示させることはできるのですが、DBに値はあるが、ユーザ1のid、ユーザ2のpwが選択された場合に”idが間違っています”と表示させることができません。

 int ID = int.Parse(TextBox1.Text);
                string PW = TextBox2.Text;
                bool a = false, b = false;



                while (dataReader.Read())
                {
                    if ((int)dataReader[0] == ID)
                    {
                        a = true;

                    }
                    if ((string)dataReader[8] == PW)
                    {
                        b = true;
                        break;
                    }
                }



                if (!a)
                {
                    errorms.Text = "IDが存在しません";
                    topMessage.Visible = true;
                }
                else if (!b)
                {
                    errorms1.Text = "パスワードが間違っています";
                    topMessage.Visible = true;
                }

                else
                {

自分で試したこと

ここに問題・エラーに対して試したことを記載してください。

0

1Answer

Your answer might help someone💌