0

As I am new to Vb, I am not sure if this is even possible.

i have created a program and now we are testing the maximum clients possible for the server.the thing is since, we are at the beggining stage, we come across numerous errors and so the person remains logged in without logging out.after a while it becomes a hassle to keep removing logged in members from the database so that they can login again.

so my question is, on any error if the program crashes, is there a way to run two lines of code

strnew2 = New SqlCommand("DELETE FROM loggedin WHERE usernam = '" & Me.LinkLabel1.Text & "' ", thisConnection)
                strnew2.ExecuteNonQuery()

this way i can run it more smoothly.
Thanks.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by choosechrist
1

I think you can Use Try-Catch

Try
thisConnection.Open()
strnew2 = New SqlCommand("DELETE FROM loggedin WHERE usernam = '" & Me.LinkLabel1.Text & "' ", thisConnection)
                strnew2.ExecuteNonQuery()
Catch(e As Exception)
'If error or crash occure catch will get executed .
MsgBox("Error "+e.Message)
Finally
'Error occur or not Finally execute both time. So thisConnection.Close() is guaranteed
thisConnection.Close()
End Try

Edited by kingsonprisonic: n/a

Votes + Comments
quick to reply
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.