-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 に答える