2012-11-22 62 views
-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 

我只需要它被放置在文本框中..

回答

0

嘗試更加具體和發佈這樣的問題之前,研究多一點在谷歌: )要指向你到正確的方向看看:

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

+0

等待不是這個爲計算機的用戶 即時通訊不知道這 即時通訊從我創建的登錄表單談用戶 –

+0

這是從計算機的用戶。它不會在你的問題中清楚你到底想做什麼:) – pkoszka

相關問題