嘿伙计们,我如何在文本框中显示当前的日志用户?同样,当我在数据库中插入数据时,它还将包括输入它的用户是谁。
这是我的代码:
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
我只需要将它放在文本框上..