Sir,
I am currently writing a VB.Net application that uses Random Access File storage to store all the records.
I have been able to write/find and delete records from the random file however i also wish to update records once i have searched for them.
When the update takes place that's where my problems occur.
Once i have updated the record, then go to enter a new record it continues to produce copies of the updated record regardless of the entry details for the new record.

The code for my Update Button is as follows:

1:      Dim OneMember As MemberType
2:      FileOpen(1, Filename, OpenMode.Random, , , _Len(OneMember))
3:      Seek(1, NumberOfRecords)
4:      OneMember.MemberID = Val(txtSID.Text) 'Update                   _MemberInfo
5:      OneMember.Title = cboSTitle.Text
6:      OneMember.FirstNames = txtSFName.Text
7:      OneMember.Surname = txtSSName.Text
8:      OneMember.DOB = txtSDOB.Text
9:      OneMember.AddressLine1 = txtSAddressL1.Text
10:     OneMember.AddressLine2 = txtSAddressL2.Text
11:     OneMember.PostCode = txtSPCode.Text
12:     OneMember.Email = txtSEmail.Text
13:     OneMember.Tele = txtSTele.Text
14:     OneMember.Mob = txtSMob.Text
15:     FilePut(1, OneMember, )
16:     FileClose(1)

I would greatly appreciate any input for my problem, thank you.

AOD

Recommended Answers

All 5 Replies

Update = Get data from file -> put data in memory -> delete data from file -> update the data in memory -> insert data into file.

P.S: data may be record or records.

Update = Get data from file -> put data in memory -> delete data from file -> update the data in memory -> insert data into file.

P.S: data may be record or records.

I am unsure how to pursue the steps you stated above, as in trying to do so i ended up damaging the add record function in the process.
This means that when i go to add a new record and display the record it comes out as the same record i was trying and failed to update.

When you say Put the Data in memory, do you mean in a Temporary File or a Variable.

Any more help would be much appreciated.

First based on first post you said you can Just Insert\Delete record and that's enough for my algorithm.

I am unsure how to pursue the steps you stated above, as in trying to do so i ended up damaging the add record function in the process.

debug your code and see from where the damage happen.

When you say Put the Data in memory, do you mean in a Temporary File or a Variable.

YES

Your logic worked out properly and i can now update the records.
This is odd as i also retested my original method and this also worked(Seek & Put).
Thank you very much for all your help, it has been a definite learning experience
Thanks

You're welcome :) I'm happy you solved the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.