Ok I have read the FAQ's and searched I don't even know how many boards so now it's time to beg some help.
I have several functions that read/write to a backend SQL database. I have read that it is not good to leave open a record set and to let connection pooling do its job. I had the recorsets opening on form load and closing on form close but since the form stays open for several days I think this was messing up the SQL server.
So now I have this code that opens the record set and closes the record set for each call to the function. This is not working fast enough since this application is reading barcodes at a much faster rate than it is processing them.
ANY suggestions would be GREATLY appreciated. Please and Thanks.
I have several functions that read/write to a backend SQL database. I have read that it is not good to leave open a record set and to let connection pooling do its job. I had the recorsets opening on form load and closing on form close but since the form stays open for several days I think this was messing up the SQL server.
So now I have this code that opens the record set and closes the record set for each call to the function. This is not working fast enough since this application is reading barcodes at a much faster rate than it is processing them.
ANY suggestions would be GREATLY appreciated. Please and Thanks.
Code:
Private Function CountMolding()
MySQL = "SELECT * FROM TblItemTransactionTracking"
Set MC_RS = MyDB.OpenRecordset(MySQL, dbOpenDynaset, dbSeeChanges)
MySQL = "SELECT * FROM TblItemTransactionTrackingHistory"
Set MCH_RS = MyDB.OpenRecordset(MySQL, dbOpenDynaset, dbSeeChanges)
MCFC = MC_RS.Fields.Count
MC_RS.FindFirst "[ITT_CJHLI] = '" & Right(Me.MM_BarCodeScanned, Len(Me.MM_BarCodeScanned) - 7) & "'"
If MC_RS.NoMatch Then
Me.MM_CurrentCount.Value = 1
With MC_RS
.AddNew
.Fields("ITT_StationID").Value = Left(Me.MM_BarCodeScanned, 6)
.Fields("ITT_Action").Value = "Count"
.Fields("ITT_CJHLI").Value = Right(Me.MM_BarCodeScanned, Len(Me.MM_BarCodeScanned) - 7)
.Fields("ITT_Location").Value = Me.MM_CurrentCount.Value
.Fields("ITT_Inserter").Value = CurrentUser()
.Fields("ITT_DateStamp").Value = Now()
DoEvents
.Update
End With
Else
Me.MM_CurrentCount.Value = Val(MC_RS.Fields("ITT_Location").Value) + 1
MCH_RS.AddNew
For MCCount = 0 To MCFC - 1
MCH_RS.Fields(MCCount + 1).Value = MC_RS.Fields(MCCount).Value
DoEvents
Next MCCount
MCH_RS.Fields("ITTH_AppendedDate").Value = Now()
MCH_RS.Fields("ITTH_AppendedBy").Value = CurrentUser()
MCH_RS.Update
With MC_RS
.Edit
.Fields("ITT_StationID").Value = Left(Me.MM_BarCodeScanned, 6)
.Fields("ITT_Action").Value = "Count"
.Fields("ITT_Location").Value = Me.MM_CurrentCount.Value
.Fields("ITT_Inserter").Value = CurrentUser()
.Fields("ITT_DateStamp").Value = Now()
DoEvents
.Update
End With
End If
MC_RS.Close
MCH_RS.Close
End Function