MartyConnelly
martyconnelly at shaw.ca
Tue Oct 21 13:21:16 CDT 2003
Are you writing to a sequential file with an append? How about writing 1 record to a random file. The disadvantage to a sequential file is that it must always be read from the beginning every time you read or append to it. There is probably a threshold for this method too. You could also check, your sequential method is using For Append Shared rather than Output Open "G:\ReportLog.txt" For Append Shared As #1 Some sample code for random access. Private Type MyPasswordData password as string * 15 description as string * 30 location as string * 30 expiry as date End Type Dim MPD as MyPasswordData Private Sub Command3_Click() 'WRITE A RANDOM ACCESS RECORD TO DISK Dim fileNo As Integer Dim totalRecords As Integer Dim newRecordNo As Integer Dim sfileName As String 'retrieve the typed-in values, this time 'assigning them to the appropriate 'MyPasswordData member (MPD) MPD.password = txtPassword MPD.description = txtDescription MPD.location = txtLocation MPD.expiry = CDate(txtExpiry) sfileName = "d:\password.dat" 'get the next free file handle fileNo = FreeFile 'save to disk using Random Access Write Open sfileName For Random Access Write As #fileNo Len = Len(MPD) 'determine how many records exist 'in the file right now, so none are overwritten totalRecords = LOF(fileNo) \ Len(MPD) 'the new record will be total records + 1 newRecordNo = totalRecords + 1 Put #fileNo, newRecordNo, MPD Close #fileNo End Sub Private Sub Command4_Click() 'READ A RANDOM ACCESS RECORD FROM DISK Dim fileNo As Integer Dim recordToGet As Integer Dim sfileName As String sfileName = "d:\password.dat" 'get the next free file handle fileNo = FreeFile 'read the first record from disk Open sfileName For Random Access Read As #fileNo Len = Len(MPD) recordToGet = 1 'load the record indicated by recordToGet 'into the MPD data Get #fileNo, recordToGet, MPD Close #fileNo 'show the retrieved values txtPassword = MPD.password txtDescription = MPD.description txtLocation = MPD.location txtExpiry = Format$(MPD.expiry, "general date") End Sub Private Sub Command5_Click() 'READ ALL RECORDS FROM DISK INTO A COMBO Dim fileNo As Integer Dim recordToGet As Integer Dim totalRecords As Integer Dim sfileName As String sfileName = "d:\password.dat" 'get the next free file handle fileNo = FreeFile 'read the first record from disk '(all on 1 line!) Open sfileName For Random Access Read As #fileNo Len = Len(MPD) 'determine how many records exist 'in the file totalRecords = LOF(fileNo) \ Len(MPD) 'if none, abort If totalRecords > 0 Then 'there must be some, so get them all Do 'set the record number to retrieve 'and Get the record recordToGet = recordToGet + 1 Get #fileNo, recordToGet, MPD 'add the description to the combo 'and in the combo items ItemData 'property, save the record number 'of the item retrieved for use later Combo1.AddItem MPD.description Combo1.ItemData(Combo1.NewIndex) = recordToGet Loop While recordToGet < totalRecords End If Close #fileNo End Sub Private Sub Combo1_Click() 'READ THE SELECTED RANDOM ACCESS RECORD FROM DISK Dim recordToGet As Integer Dim fileNo As Integer Dim sfileName As String sfileName = "d:\password.dat" 'bail out if nothing is selected If Combo1.ListIndex > -1 Then 'retrieve the record associated with 'the description from the info stored 'in the ItemData property recordToGet = Combo1.ItemData(Combo1.ListIndex) 'bail out if its 0 - an error If recordToGet > 0 Then 'get the next free file handle fileNo = FreeFile 'read the specified record from disk Open sfileName For Random Access Read As #fileNo Len = Len(MPD) Get #fileNo, recordToGet, MPD Close #fileNo 'display the data for the record txtPassword = MPD.password txtDescription = MPD.description txtLocation = MPD.location txtExpiry = Format$(MPD.expiry, "general date") End If End If End Sub Martin Reid wrote: >Anyone have any ideas re the following? > >I have a system whereby each PC in the SCCs sends in one short line per >minute to a central server. Each line is of the form IP address, time, >date[, user id]. The central server is only a P450 with 256Mb memory but >I have used a P733 with the same results. > >When a user logs in to a PC, it writes a line to the same file on the >central server as all the other used PCs. Each PC writes at the same >second each minute, but the PCs determine their second to write by >chance, basically. Thus the incoming data for the file is reasonably >well spread across 60 seconds. > >On the minute, the software on the central server renames the input >file, thereby causing a new one to be created with the next record sent >to it. The central file is held on a share to which each PC has to >authenticate. > >When enough PCs are active, and I have not been able to deduce if there >is a threshold figure for that number, some or most of a record may be >lost. That can be seen from the input files. > >During stress tests, when my PC was the only system communicating with >the server, My PC could send in about 630 lines per minute and none >would be lost. And this over a period of say an hour. However, when >multiple PCs send in lines, the data loss may arise with 50 PCs active. >The difference is the number of active network connections. > >As I don't believe the data is being lost on the network (I have >monitored this and have not seen losses so far), it is most likely being >lost through the networking code/file system combination, and probably >the former. > >I was wondering if anyone had a better method for collecting this >asynchronous auditing information, one which did not lose data. >_______________________________________________ >dba-Tech mailing list >dba-Tech at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-tech >Website: http://www.databaseadvisors.com > > > -- Marty Connelly Victoria, B.C. Canada