OK, Im making a server, nothing too fancy, (For now), which people can chat in...

and in it, im using MySQL (Until i get round to learning MS Access & PHP)..

Any howz,

With this code:

VB Code:
  1. Public Sub LogOff(ConIndex As Integer, txtLog As RichTextBox)
  2. On Error GoTo ErrorSub:
  3.  
  4.     ' Just make a log message
  5.     txtLog.SelStart = Len(txtLog.Text)
  6.     txtLog.SelColor = vbBlack
  7.     txtLog.SelText = Now & ":" & vbTab & "User Logged Out (Connection: " & ConIndex & ");" & vbCrLf
  8.        
  9.     ' Dim the stuff to use in this "Sub"
  10.     Dim oConn As New ADODB.Connection, oConn2 As New ADODB.Connection
  11.     Dim myRS As New ADODB.Recordset, myRS2 As New ADODB.Recordset
  12.     Dim UName As String, LocURL As String
  13.  
  14.     ' Set the connection to the database
  15.     oConn.Open "Driver={mySQL};" & _
  16.                "Server=" & MySQLServer & ";" & _
  17.                "Port=" & MySQLPort & ";" & _
  18.                "Option=131072;" & _
  19.                "Stmt=;" & _
  20.                "Database=" & ServerDB & ";" & _
  21.                "Uid=" & MySqlUID & ";" & _
  22.                "Pwd=" & MySqlPass & ";"
  23.  
  24.     Set myRS = oConn.Execute("SELECT Username, LocationURL FROM online WHERE ConIndex='" & ConIndex & "'")
  25.     ' We need to use these, to notify the room people, of the leaving.
  26.     ' But we are gonna delete the user from the DB, so we need to get the details first
  27.     UName = myRS("Username")
  28.     LocURL = myRS("LocationURL")
  29.     ' Get rid of the "Online User"
  30.     oConn.Execute ("DELETE FROM online WHERE ConIndex='" & ConIndex & "'")
  31.     ' And now get who was in the room, and who we need to notify of the leaving
  32.     Set myRS2 = oConn.Execute("SELECT ConIndex FROM online WHERE LocationURL='" & LocURL & "'")
  33.    
  34.     Do Until myRS2.EOF
  35.         ' And now tell the people S/he has left the room
  36.         frmServerWindow.ServerSocket(myRS2("ConIndex")).SendData (" ## -cmdRoomLeave :$: " & UName)
  37.         myRS2.MoveNext
  38.     Loop
  39.    
  40.     ' Since there may not have been anyone in the room, there would have been an error
  41.     ' So i made the "Closing up" A "Sub-Routine"
  42.     GoTo CloseUp:
  43.  
  44. Exit Sub
  45. ErrorSub:
  46.     If Err.Number = "3021" Then
  47.         ' No users where in the same room has the user
  48.         ' So no need to do anything more then clean up
  49.     Else
  50.         Call frmServerWindow.ErrorSub(Err.Description, Err.Number)
  51.         Err.Clear
  52.     End If
  53.     ' Clean up the Database Connections
  54.     GoTo CloseUp:
  55. Exit Sub
  56. CloseUp:
  57.     ' Get rid of all those extra database connections,
  58.     ' And delete the "Stuff" from the Memory
  59.     myRS.Close
  60.     myRS2.Close
  61.     oConn.Close
  62.     Set myRS = Nothing
  63.     Set myRS2 = Nothing
  64.     Set oConn = Nothing
  65. End Sub

Perticularly the "CloseUp:" Sub...

Will this make other things caled "myRS, myRS2, and oConn" for different LogOffs, Errased, or just THIS sections?

(What i mean clearer, Will it DELETE both oConns, if the sub is called twice at the same time, and even if the Second "LogOff" is in the middle of a process?

Or is it "Process Independant"?

Tnx