my system cant close after get pass the log-in form

micheal

Member
Joined
Nov 8, 2011
Messages
6
Location
Malaysia
Programming Experience
Beginner
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True")
Dim cmd As SqlCommand = New SqlCommand("SELECT * FROM Staff WHERE username = '" & UsernameTextBox.Text & "' AND password = " & PasswordTextBox.Text, con)
con.Open()
Dim sdr As SqlDataReader = cmd.ExecuteReader()
If (sdr.Read() = True) Then
MessageBox.Show("The user is valid!")
Me.Hide()
Form17.ShowDialog()
con.Close()
Else
MessageBox.Show("Invalid username or password!")
End If
End Sub

comment
'where i do wrong,please help,your kind help much more appreciated.
 
You are hiding your startup form (and never close it), while you have application shutdown mode to close when startup form closes.
May I suggest you do login dialog from applications startup event handler, and set your main form as startup form?

Also update your forum profile, you can't be using .Net 1.0.
 
the reason why i hiding the start up(and never close it) because if i put me.close on the log-in form,the from will automatically close after click submit username and password,without enter the main form application,how to do as your suggestion?

my application should be run like this :- log-in form(start up) ->main form application
'thank you for your advise.
 
Back
Top