Results 1 to 28 of 28

Thread: Transfer login info to label/textbox

Threaded View

  1. #1

    Thread Starter
    Junior Member Danii's Avatar
    Join Date
    Jun 2019
    Location
    Lisbon
    Posts
    22

    Transfer login info to label/textbox

    Hey again, another problem, same project.

    Well, I'm working on a project where I want a login, register, and a profile form. I've accomplished to make login and register work perfectly, but I have no clue on how to make the profile. I want to make a profile form where I show the info of the user, that he introduced in the registration process (Username, Profile Nome) as well as some information like country and birthday that I want them to fill later on, inserted in text boxes or even labels. I will let the login and registration code below so you guys can understand the methods I used. Thx in advance!

    Login Code:
    Code:
    Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
        Dim uname As String = ""
        Dim pword As String
        Dim username As String = ""
        Dim pass As String
        If txtUser.Text = "" Or txtPassword.Text = "" Then
            MsgBox(erro1)
        Else
            uname = txtUser.Text
            pword = txtPassword.Text
            Dim querry As String = "Select PalavraPasse From tblusers where Username= '" & uname & "';"
            Dim dbsource As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Users.accdb"
            Dim conn = New OleDbConnection(dbsource)
            Dim cmd As New OleDbCommand(querry, conn)
            conn.Open()
            Try
                pass = cmd.ExecuteScalar().ToString
            Catch ex As Exception
                MessageBox.Show("O Username não existe", "Login Info", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
                txtUser.Text = ""
                txtPassword.Text = ""
            End Try
            If (pword = pass) Then
                MessageBox.Show("Login realizado com sucesso!", "Login Info", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
                'Substituir Message box por um personalizado com timer
                FormHome.Show()
                If FormHome.Visible Then
                    Me.Hide()
                Else
                    MessageBox.Show("O login falhou!", "Login Info", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
                    txtUser.Text = ""
                    txtPassword.Text = ""
                End If
            End If
        End If
    End Sub
    Register Code:
    Code:
    If txtPassw.Text = txtConfirmarPassw.Text Then
            If txtUsername.Text = "" Or txtNomePerfil.Text = "" Or txtPassw.Text = "" Then
                MsgBox(erro1)
            Else
                Try
                    Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Users.accdb")
                    Dim insert As String = "Insert into tblUsers(Username , NomePerfil , PalavraPasse) values('" & txtUsername.Text & "','" & txtNomePerfil.Text & "','" & txtPassw.Text & "');"
                    Dim cmd As New OleDbCommand(insert, conn)
                    conn.Open()
                    cmd.ExecuteNonQuery()
                    MsgBox("Conta criada com sucesso!")
                    Me.Close()
                    FormLogin.Visible = True
                Catch ex As Exception
                    MsgBox(erro2)
                End Try
            End If
        Else
            MsgBox(erro2)
            txtPassw.Text = ""
            txtConfirmarPassw.Text = ""
        End If
    Disclaimer: I have made a question in the forum earlier where I was clear that I'm using an Access database, and many people answered me saying that my SQL code was wrong, so I want to make sure that it is clear that I'm using MS Acess. Ty

    Edit: You might not understand some msgbox messages because they are in Portuguese, any doubt pls comment bellow
    Last edited by Danii; Jun 26th, 2019 at 08:39 AM. Reason: Clarifications

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width