Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ! I am storing the following information about my user:

UserID
FirstName
Surname
Address Line One
Address Line Two

I am using random access with back-end textfiles in order to store my data. How can I show my data that I have stored in my text files to my datagridview? every time I try anything it's only printing it to the first column in the first row and I know that's because its saving the data to the text file like this

What I have tried:

I have tried using vb.net techniques but it works with stream readers and writers.
Posted
Updated 6-Jan-18 6:02am
Comments
Maciej Los 7-Jan-18 5:15am    
You have to show the way you store user information in a text file. You have to provide the code you used too!

1 solution

There's no such thing as a "random access" text file because all of the records are different lengths. In order to get to any specific record, you would have to read every record from the beginning of the file and count each one until you get to the one you want.

A true "random access" file is just the record number times the length of each record, giving you the offset form the beginning of the file to the first byte of the record to which you can Seek without reading everything in front of that to get there.

Without seeing your code that reads the file and builds a table in memory to which you can bind your grid, it's impossible to tell you what you did wrong.

Oh, and why on earth are you using VB6? The language has been dead for quite some time now. You can get the Community edition of Visual Studio and VB.NET for FREE from here[^]!
 
Share this answer
 
Comments
Maciej Los 7-Jan-18 5:21am    
5!Small note: VB is still alive... until some users still use it. :laugh:
Dave Kreskowiak 7-Jan-18 10:34am    
I don't recommend it for new users because the support base is dwindling fast.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900