-3

嘿伙计们,我如何在文本框中显示当前的日志用户?同样,当我在数据库中插入数据时,它还将包括输入它的用户是谁。

这是我的代码:

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

我只需要将它放在文本框上..

4

1 回答 1

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

于 2012-11-22T14:02:06.837 回答