For 25+ years, the owner of my company didn't updated his original code from the days of early 1980's RPG. (Don't be surprised if you you've never heard of RPG, neither had I when I started working here. It was a dead language by the time I graduated 20+ years ago.) He finally began migrating from RPG to VB.Net 2-3 years ago and has resisted moving to any database platform. (We all pleaded with him to do so, he wouldn't listen.) I have no choice but to work with flat- files all the time. Not XML, not comma-delimited, true flat-files whose only structure is what we impose upon it through code at run- time. 60-100 files, some with 10's of thousands of records, per company that we sell our software too,
I have done what you are asking. Over the last two years I have had to build, from scratch, what is essentially a database engine for managing flat-files, including: 1) Multi-part indexes, often more than one per datafile, with unique and duplicate keys, that are automaitcally updated whenver data is changed. Note that the boss also likes to have multiple record formats in THE SAME FILE that have a 1-many relationship with each other. That's right, master and detail records together in one file. Try keeping those indexes straight! 2) Run-time data type conversion and verification. i.e. Is this field an integer, string, a date, or one of the wacky odd-ball types the boss came up with that change depending on the value in another field. (On this record its an integer, on this record its a date because there is an "A" in position 12. ARGHH!) We also pack and unpack numeric fields so we can shave a couple of bytes off the record lengths here and there. (It mattered back when these files were first created.) 3) Many-to-Many lookups between datafiles depending on matching fields or index values. So far I have managed to avoid, just barely, creating a SQL interperter so I can write simple queries and imposing enforced relational integrity between the files. I consider myself a fair expert on working with flat-files, so trust me when I say you REALLY want to use a database. Get SQL Server Express if nothing else (its free) and learn to love it. It will make your life MUCH easier and may prevent you from going postal on someone. If you go the Flat-File route you will be ***FOREVER*** fighting problems you can easily solve with a database. And you can avoid wasting precious hours, days, weeks, months, of your life recreating what EVERY databse gives you automatically -- easy, verifiable, reliable, access to your data. -- R.B. Davidson On Jan 25, 8:15 pm, Mark <[email protected]> wrote: > I've been developing websites for how long, I don't even know how to > tackle this problem in a C# windows app. > > I have to classes, ClassA and ClassB, with a many-to-many > relationship. Given an instance of ClassA, I need to be able to pull > up all the ClassBs that it has, and vice-versa. I don't want to run a > SQL server on my computer... there has to be a way to do this with > flat files? We're looking at a few thousand instances of each. > > Any tips would be appreciated. Thanks! > > Mark
