こんにちは、現在のログ ユーザーをテキスト ボックスに表示するにはどうすればよいですか? また、データベースにデータを挿入すると、データを入力したユーザーも含まれます。
これは私のコードです:
Conn = New MySqlConnection("host=localhost; uid=root; pwd=root; database=lmsdbase")
'Try
Conn.Open()
Dim mystr As String = "Select * from tbluser where Username = '" + txtUsername.Text + "' and Password = '" + txtPassword.Text + "'"
Dim mydr As MySqlDataReader
Dim myda As New MySqlDataAdapter
Dim mycmd As New MySqlCommand
mycmd.CommandText = mystr
mycmd.Connection = Conn
myda.SelectCommand = mycmd
mydr = mycmd.ExecuteReader
'If CheckBox1.Checked Then
' Dim mystr2 As String = "Select * from tbluser where Usertype = '" +
'End If
If mydr.HasRows = 0 Then
MessageBox.Show("Incorrect Username or Password.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
abc -= 1
txtUsername.Clear()
txtPassword.Clear()
Else
MessageBox.Show("Welcome!")
Me.Visible = False
txtUsername.Text = ""
txtPassword.Text = ""
frmMain.Show()
End If
If abc = 0 Then
MsgBox("Program is closing due to login mistakes")
MsgBox("Please make sure the the username/password is correct", MsgBoxStyle.OkOnly)
End
End If
End Sub
テキストボックスに配置するだけです..