Any Borland C++ Builder users??//slash

On the basis that this is a question about creativity I place this in Cafe Society.

(Not that I expect to get any replies regardless of where it’s put)

I have recently bought the Pro version (before you say anything… my place of employment will pay for it if I can produce what they want from it) and I am suffering a case of coder’s block.

I’ve had many versions of Builder in the past and with each one I’ve been able to code to my heart’s content. But now I can do little more than stare at a blank form.
I want to be able to write an application capable of importing pipe delimited data from ascii text files into an SQL queriable table.

I am good at SQL and I was good with C++ 6 years ago… but now I am blocked by the IDE and the inability to put the bits in place to enable the above.

It seems like the wrong tool for the job. A high-level scripting language like Perl or Python can do that sort of stuff in no time flat.

Also, a lot of database engines are happy to import data from ASCII files directly. MySQL, for example, has the LOAD DATA INFILE command which allows you to specify delimiters and line endings and so forth to load a table from a file.

Yeah, I don’t know the details of your situation, but most DBMSs have a command like friedo mentioned (in Informix, it’s LOAD FROM <filename> INSERT INTO <table>). You should be able to do this by running the proper SQL command in the database or through an ODBC connection. If you need to massage the ASCII a bit to get in into the right format for the import, perl or python would be the easiest bet.

If you wanted to do it in C++, you’d need to open an ODBC connection to insert into the database anyway, but I suppose you could either massage the ASCII file with C++ commands (needlessly complex) or read in each line of the ASCII file and build INSERT statements for them.

(on preview, I see your file is pipe delimited. I’d imagine just about and DBMS should be able to handle this with some variant of a LOAD command. If you insist on using C++, I suppose the trick would be to create a connection to the database and run the proper SQL command.)

If you’re using SQL Server, Enterprise Manager has a wizard to do this without you writing a single line of code. It can import data from text files that use arbitrary delimeters.

Umm… “Creativity” isn’t the criteria for Cafe Society, it’s (basically) arts and entertainment. Yeah, OK, computer craperoo can be entertaining, but I think you’ll get better responses in GQ. Computer questions tend to drift to there, and I’m thinking you’ll have a better shot at getting knowledgable responses.

GQ-Mods, if this ain’t right for GQ, I’m sorry. It’s Greek to me. [sub]Hey, aren’t all posts supposed to be in English?[/sub]

Have a look at TFileStream, TStringList. Use two TStringLists, one for loading the data from TFileStream, and one for parsing the text.

A TOpenDialog will allow you to pick the file, if you don’t already know the file name, or you can use ParamStr to retrieve the file name from the command line.

That should get you started.