Not exactly elegant, but performance may be better:
- load the whole file into a table with just one column "Line" as long text (similar to what you do now locally
- use stored procedures to split the fields apart and create the inserts
- execute the inserts on the server
While you are still inserting each line seperately, you wouldn't create quite as much network traffic.
To elaborate, the original method generates the statements on the client and then executes them on the client, resulting in network traffic for each line. My suggestion would be to generate the statements on the server (in a stored procedure) and have them execute on the server, resulting in no new network traffic.
The "correct" solution would be to use a database specific import tool (like SQL Loader for Oracle). The performance gains are enormous. (We are loading huge tables with 20 million lines in about 5 minutes). But of course, that is not very generic.