Hi Cowboy (or do you prefer Gregory ?),
Thanks very much for the response.
Sorry if I wasn't clear, but when I said that the files included integers I
meant that they were two byte binary integers 'PUT' there by VB.
There are also longs, dates, bools and maybe even a couple of floating point
numbers...
Hence my need to read the file in binary.
There doesn't seem to be a way to dynamically set the type structure at
runtime (I have to either recompile the exe to import each database, or run
in design mode).
I wanted to be able to point my app at any 'flat binary file', tell it
(manually or by pointing at the UDT) the record structure and then export to
CSV or SQL.
The only stumbling block is the limitation of VB6 - if only I could create a
dynamic UDT...
I did have one idea I've yet to try - tell me what you think :-
Could I load each record into a dynamic array of bytes (having REDIM'd the
array size to the record size) and then extract the data into a CSV byte by
byte (processing according to the record structure which we've specified) ?
It sounds promising, but I'm not sure if you can 'GET' into a dynamic
array...
All this would be so easy if VB had an 'eval' command like VBScript or
Java...
Another question : can the BinaryReader class be used in VB6 or is it
exclusive to .NET ?
Thanks again.
Dave MC.
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:#I**************@TK2MSFTNGP09.phx.gbl...
As the files sound like they are ultimately text, I am not sure I see the
value of using a BinaryReader. BinaryReaders are better for binary files
(Excel files, graphics, et al) not for fixed length text.
I would read in the text, line by line, and break it out. You can then use
your old classes to create the UDT, or place the info into SQL Server.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
************************************************** ********************
Think Outside the Box!
************************************************** ********************
"David Compton" <dc******@nomorespam.autoclimate.com> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl... Hi all,
Can anyone tell me if this is possible ? :-
I have several flat files created in VB6 using UDTs and the PUT command.
They include integers, etc. and are all of fixed record length.
I want to export them to SQL, but the only way I can read these files is
from VB using GET fileno, recordno, userdefinedtype.
The UDT must be specified at designtime so I can't dynamically read
different databases from the same app.
I was wondering if I could use VB.NET and the BinaryReader class to read
these records and export them to a CSV to direct to SQL ?
I already have the code that reads the .BAS file containing the type
structure, it then works out the record length and compares it to the
binary file to see how many records it contains (or if the size doesn't match).
Can anyone confirm this is possible ? (I don't want to spend a week
learning VB.NET only to find out it's not !).
OR - Does anyone know of a program that allows you to do this already ?
I believe flat binary files are similar to SAS databases ?
Any help will be gratefully received !
Cheers.
David Compton
Autoclimate Ltd.