これはログイン コードであり、その人物が単なる「管理者」なのか「スタッフ」なのかを確認することも想定されています。
Private Sub btnopenapplication_Click(sender As System.Object, e As System.EventArgs) Handles btnlogin.Click
Dim reader As SqlDataReader
Dim verify_account_type As String
Dim sqlstatement As SqlCommand = New SqlCommand
sqlstatement.Connection = connection
Try
sqlstatement.CommandText = "Select account_username, account_password, account_type " &
"from login_account where account_username='" & txtusername.Text & "' and account_password='" & txtpassword.Text & "'"
reader = sqlstatement.ExecuteReader()
If (reader.Read()) Then
Dim account_type As String = "Administrator"
verify_account_type = CStr(reader("account_type").ToString)
If String.Compare(account_type, verify_account_type) = 0 Then
application_form.Show()
Me.Visible = False
Else
MsgBox("you are not an administrator")
End If
sqlstatement.Dispose()
reader.Close()
Else
MsgBox("Invalid")
End If
reader.Close()
Catch ex As Exception
MsgBox(vbCrLf & ex.Message)
End Try
End Sub
ここが失敗しそうなところ
If String.Compare(account_type, verify_account_type) = 0 Then
application_form.Show()
Me.Visible = False
Else
MsgBox("you are not an administrator")
End If
ログインは機能しますが、比較に失敗します。基本的に、アカウントの種類(「管理者」と「スタッフ」)のデータベースがあります。account_type を読み取り、その値を変数に入れ、その変数が「管理者」または「スタッフ」のいずれかの値を持つ別の変数と比較することを想定していますが、そうではありません。
いくつかの助けをいただければ幸いです、ありがとう。