This post has been edited by chdboy: 18 January 2013 - 08:07 AM
25 Replies - 945 Views - Last Post: 03 February 2013 - 08:38 PM
#16
Re: How to clear variable value after logout?
Posted 18 January 2013 - 08:07 AM
It is the form where I have stored the username(Current user logged in) who can change the password (Only user logged in )using password recovery form (recoverpass)so in my recoverpass lies the field(txtuname) which holds the (u) username ,that is the field I wanted to make empty when logged out
#17
Re: How to clear variable value after logout?
Posted 18 January 2013 - 01:56 PM
I'd really like to see the code of your login form, not the recoverpass form.
#18
Re: How to clear variable value after logout?
Posted 18 January 2013 - 10:22 PM
Please see my #1 post in this thread .
#19
Re: How to clear variable value after logout?
Posted 19 January 2013 - 11:23 AM
chdboy, on 18 January 2013 - 11:22 PM, said:
Please see my #1 post in this thread .
That post contains only a few snippets that are not shown in context. If you expect anyone to actually provide help, you need to pay attention to what is being asked of you, and you also need to pay attention to the advice that's being given.
torind_2000 asked you for the code for the login form, and you have not supplied it.
You were advised to clear out the TextBox that supplies the user name when you log out, yet in your post #7 in this thread, in which you post the code of your logout button, there is no code to clear out u or TextBox1.Text.
None of the volunteers here are very good at reading your mind, so you have to follow advice and follow directions if you want help.
This post has been edited by lar3ry: 19 January 2013 - 11:23 AM
#20
Re: How to clear variable value after logout?
Posted 22 January 2013 - 09:40 AM
Here is the code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Mainfrm.mnuLlogout.Enabled = True
'LinkLabel2.Enabled = True
If (TextBox1.Text.Trim = "") Then
MessageBox.Show("PLEASE DO NOT USE BLANK SPACES", "Data Entry Error")
ElseIf (TextBox2.Text.Trim = "") Then
MessageBox.Show("PLEASE DO NOT USE BLANK SPACES", "Data Entry Error")
Else 'if user has not entered a blank space
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Danial\documents\visual studio 2010\Projects\ESI_PF_Payroll_V1\ESI_PF_Payroll_V1\Pay.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT * FROM tbllogin where username = '" & TextBox1.Text & "' and password = '" & TextBox2.Text & "';"
u = TextBox1.Text
cmd.Connection = con
adaptor.SelectCommand = cmd
adaptor.Fill(dataset, "O")
Dim count = dataset.Tables(0).Rows.Count
If count > 0 Then
MessageBox.Show("Welcome to the program!")
Mainfrm.mnuLlogin.Enabled = False
Mainfrm.mnuLchangepass.Enabled = True
Mainfrm.MmEmplmaster.Enabled = True
Mainfrm.MmEmpmaster.Enabled = True
Mainfrm.Mmforms.Enabled = True
Mainfrm.Mmwindows.Enabled = True
Me.Hide()
con.Close()
Else
MsgBox("INCORRECT USERNAME OR PASSWORD", MsgBoxStyle.Critical)
TextBox1.Clear()
TextBox2.Clear()
TextBox1.Focus()
con.Close()
End If
End If
End Sub
#21
Re: How to clear variable value after logout?
Posted 22 January 2013 - 09:56 AM
Have you tried putting
U = String.Empty right before the f.close() in your logout code?
In other words you ask if the user want to log out. When they click yes, you close the form but prior to closing the form, set u = String.Empty or u = "" or any other equivalent of setting a string to empty.
Also, in your login code, why are you even setting U = TextBox1.Text before you even check to see if the login was successful? I would think that only upon a successful login would you store the user into your public u variable.
U = String.Empty right before the f.close() in your logout code?
In other words you ask if the user want to log out. When they click yes, you close the form but prior to closing the form, set u = String.Empty or u = "" or any other equivalent of setting a string to empty.
Also, in your login code, why are you even setting U = TextBox1.Text before you even check to see if the login was successful? I would think that only upon a successful login would you store the user into your public u variable.
#22
Re: How to clear variable value after logout?
Posted 23 January 2013 - 05:02 AM
Login Page code ,some changes I have made
and my logout button code
As you can see I have used two line that you provided.
But the username from earlier login is still there in the recoverpass form.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Mainfrm.mnuLlogout.Enabled = True
'LinkLabel2.Enabled = True
If (TextBox1.Text.Trim = "") Then
MessageBox.Show("PLEASE DO NOT USE BLANK SPACES", "Data Entry Error")
ElseIf (TextBox2.Text.Trim = "") Then
MessageBox.Show("PLEASE DO NOT USE BLANK SPACES", "Data Entry Error")
Else 'if user has not entered a blank space
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Danial\documents\visual studio 2010\Projects\ESI_PF_Payroll_V1\ESI_PF_Payroll_V1\Pay.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT * FROM tbllogin where username = '" & TextBox1.Text & "' and password = '" & TextBox2.Text & "';"
'u = TextBox1.Text(I have changed this line)
cmd.Connection = con
adaptor.SelectCommand = cmd
adaptor.Fill(dataset, "O")
Dim count = dataset.Tables(0).Rows.Count
If count > 0 Then
u = TextBox1.Text'( and I have inserted line here)
MessageBox.Show("Welcome to the program!")
Mainfrm.mnuLlogin.Enabled = False
Mainfrm.mnuLchangepass.Enabled = True
Mainfrm.MmEmplmaster.Enabled = True
Mainfrm.MmEmpmaster.Enabled = True
Mainfrm.Mmforms.Enabled = True
Mainfrm.Mmwindows.Enabled = True
Me.Hide()
con.Close()
Else
MsgBox("INCORRECT USERNAME OR PASSWORD", MsgBoxStyle.Critical)
TextBox1.Clear()
TextBox2.Clear()
TextBox1.Focus()
con.Close()
End If
End If
End Sub
and my logout button code
Private Sub LogOutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuLlogout.Click
' Declare a Form object and call the Close event
Dim f As Form
For Each f In Me.MdiChildren
If MessageBox.Show("Do you want to Logout?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult = vbYes Then
u = ""
u = String.Empty
f.Close()
Recoverpass.txtuname.Text = String.Empty
Else
If DialogResult = vbNo Then
Exit Sub
End If
End If
Next
mnuLchangepass.Enabled = False
mnuLlogout.Enabled = False
mnuLlogin.Enabled = True
MmEmplmaster.Enabled = False
MmEmpmaster.Enabled = False
Mmforms.Enabled = False
Mmwindows.Enabled = False
End Sub
As you can see I have used two line that you provided.
But the username from earlier login is still there in the recoverpass form.
#23
Re: How to clear variable value after logout?
Posted 23 January 2013 - 05:22 AM
instead of f.close() put f.Dispose()
I've had trouble with some MDI forms that don't seem to dispose after a close. See if that clears the field.
I've had trouble with some MDI forms that don't seem to dispose after a close. See if that clears the field.
#24
Re: How to clear variable value after logout?
Posted 23 January 2013 - 07:22 AM
f.Dispose()
It also does not work.
#25
Re: How to clear variable value after logout?
Posted 23 January 2013 - 10:08 AM
Quote
But the username from earlier login is still there in the recoverpass form.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'..........
Else 'if user has not entered a blank space
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Danial\documents\visual studio 2010\Projects\ESI_PF_Payroll_V1\ESI_PF_Payroll_V1\Pay.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT * FROM tbllogin where username = '" & TextBox1.Text & "' and password = '" & TextBox2.Text & "';"
'......
End Sub
Private Sub LogOutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuLlogout.Click
' Declare a Form object and call the Close event
Dim f As Form
For Each f In Me.MdiChildren
If MessageBox.Show("Do you want to Logout?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult = vbYes Then
u = ""
u = String.Empty
f.Close()
Recoverpass.txtuname.Text = String.Empty
Else
If DialogResult = vbNo Then
Exit Sub
End If
End If
Next
mnuLchangepass.Enabled = False
mnuLlogout.Enabled = False
mnuLlogin.Enabled = True
MmEmplmaster.Enabled = False
MmEmpmaster.Enabled = False
Mmforms.Enabled = False
Mmwindows.Enabled = False
End Sub
Let's try it this way.
Where, in the second code example (logout), do you clear TextBox1.Text?
Because, in your first code example, you check to see if TextBox1.Text is blank, and if it isn't, you use its contents.
Inquiring minds want to know.
#26
Re: How to clear variable value after logout?
Posted 03 February 2013 - 08:38 PM
here is the code ...Just checking if the textboxes are blank or not.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Mainfrm.mnuLlogout.Enabled = True
'LinkLabel2.Enabled = True
If (TextBox1.Text.Trim = "") Then
MessageBox.Show("PLEASE DO NOT USE BLANK SPACES", "Data Entry Error")
ElseIf (TextBox2.Text.Trim = "") Then
MessageBox.Show("PLEASE DO NOT USE BLANK SPACES", "Data Entry Error")
Else 'if user has not entered a blank space
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Danial\documents\visual studio 2010\Projects\ESI_PF_Payroll_V1\ESI_PF_Payroll_V1\Pay.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT * FROM tbllogin where username = '" & TextBox1.Text & "' and password = '" & TextBox2.Text & "';"
'u = TextBox1.Text
cmd.Connection = con
adaptor.SelectCommand = cmd
adaptor.Fill(dataset, "O")
Dim count = dataset.Tables(0).Rows.Count
If count > 0 Then
u = TextBox1.Text
MessageBox.Show("Welcome to the program!")
|
|

New Topic/Question
Reply




MultiQuote





|