嘿伙计们如何在文本框中显示当前日志用户? 当在数据库上插入数据时,它也会包括输入数据的用户。
这是我的代码:
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
我只需将它放在文本框中..
答案 0 :(得分:0)
尝试更具体,并在发布此类问题之前在Google上进行更多研究:)为了指出正确的方向,请查看:
Dim User As New System.Security.Principal.WindowsIdentity(System.Security.Principal.WindowsIdentity.GetCurrent().Token)
和 http://msdn.microsoft.com/en-us/library/system.security.principal.windowsidentity.aspx