Login problem

desperateboy

Active member
Joined
Dec 11, 2007
Messages
30
Programming Experience
Beginner
hi friends,

I have made login form.After login when i logout then again login that time without filling username and password show main form during clik on login button.

Plz sort it out.

I am using following coding:
VB.NET:
        Try

            conn.Open()

            cmd = New SqlCommand("select * from usrs where uname = @user and upwd = @pwd", conn)
            cmd.Parameters.AddWithValue("@user", Trim(TextBox1.Text))
            cmd.Parameters.AddWithValue("@pwd", Trim(TextBox2.Text))
            dr = cmd.ExecuteReader
           
            While dr.Read()
                a = dr.Item("upwd")
                b = dr.Item("uname")
                If TextBox1.Text = a And TextBox1.Text = b Then
                    sid = dr.Item("uid")
                    ProgressBar1.Visible = True
                    'Button1.Visible = False
                    'Button2.Visible = False
                    valid = True
                    Me.TextBox1.Clear()
                    Me.TextBox2.Clear()
                End If
            End While
                      dr.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            conn.Close()
            cmd = Nothing
        End Try
 
Last edited:
Are you clearing the username and password when the second form is closed? Do you have any kind of 'Log out' button provided?

Those are the obvious two things I would do in this case, when the form closes or they click a log out button (close the form here too) i would clear the username and password variables. Then I would show the login form or let the app close itself altogether.

I'd need to know more about how your apps works before I can really give any "good" advice for ya
 
I have not logout button .I use this code a.string.empty in second form close event bcaz anyone an close form two ways (one click on logout button or directly closing form).
 
so in the form's closing event put these in:
VB.NET:
a = String.Empty
b = String.Empty
If you use a boolean variable like a "isLoggedIn", set it to false at that time too.
 
If you are showing the LogIn form using the Form.ShowDialog method, you must call Form.Dispose afterwards to completly get rid of it.
 
Back
Top