I am having problems with this function. I call it upon a datagrid "Delete". I am passing in:
DBConnection = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=192.168.10.1;DATABASE=TEST;USER=TestUser;PASSWORD=;OPTION=35;"
SelectQuery = "SELECT * FROM SecurityForms WHERE FormID=13 and UserID=152"
When the user pushes delete on the datagrid for the second time, the code locks up the whole software on the "myRS.Source = SelectQuery". This function works GREAT on the first delete, then the second time around it locks tighter than a drum and the program has to be "end tasked".
I am using visual basic v6 and MySQL ODBC 3.51 Driver.
Anyone got any clues? I have never had a problem like this before.
--------------------------------------------------------
Function DeleteRecords(DBConnection As Variant, SelectQuery As Variant)
On Error GoTo Err_DeleteRecords
Dim myConn As New ADODB.Connection
Dim myRS As New ADODB.Recordset
myConn.Open DBConnection
myRS.Source = SelectQuery
Set myRS.ActiveConnection = myConn
myRS.CursorLocation = adUseClient
myRS.Open , , adOpenDynamic, adLockOptimistic
With myRS
If .RecordCount > 0 Then
.MoveLast
.MoveFirst
While Not .EOF
.Delete
.MoveNext
Wend
End If
.Close
End With
myConn.Close
Set myRS.ActiveConnection = Nothing
Exit Function
Err_DeleteRecords:
MsgBox Err.Number & ": " & Err.Description
End Function
DBConnection = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=192.168.10.1;DATABASE=TEST;USER=TestUser;PASSWORD=;OPTION=35;"
SelectQuery = "SELECT * FROM SecurityForms WHERE FormID=13 and UserID=152"
When the user pushes delete on the datagrid for the second time, the code locks up the whole software on the "myRS.Source = SelectQuery". This function works GREAT on the first delete, then the second time around it locks tighter than a drum and the program has to be "end tasked".
I am using visual basic v6 and MySQL ODBC 3.51 Driver.
Anyone got any clues? I have never had a problem like this before.
--------------------------------------------------------
Function DeleteRecords(DBConnection As Variant, SelectQuery As Variant)
On Error GoTo Err_DeleteRecords
Dim myConn As New ADODB.Connection
Dim myRS As New ADODB.Recordset
myConn.Open DBConnection
myRS.Source = SelectQuery
Set myRS.ActiveConnection = myConn
myRS.CursorLocation = adUseClient
myRS.Open , , adOpenDynamic, adLockOptimistic
With myRS
If .RecordCount > 0 Then
.MoveLast
.MoveFirst
While Not .EOF
.Delete
.MoveNext
Wend
End If
.Close
End With
myConn.Close
Set myRS.ActiveConnection = Nothing
Exit Function
Err_DeleteRecords:
MsgBox Err.Number & ": " & Err.Description
End Function