drixx2
04-17-2004, 06:22 AM
Hi everyone,
i was recently given an assignment to write a program in visual basic 6 which reads in a textfile's path, a database table, and a 'field map', a delimited char, and a couple other parameters which aren't important to this discussion.
Now, what this program's task to do is: import the values in the text file to the SQL 2k database table based on the 'field map'. This 'field map' basically will come in the form of, for example, 1=2, 3=4 (ie, column 1 in the text file goes in column 2 in the table, column 3 in the text file goes in column 4 in the table, ect).
So far i have created a BulkInsert Task object and i am able to import data into the table when there is an exact mapping, but i'm stuck on the 'field mapping' part. Originally, i was going to execute a stored procedure to the bcp to create a format file, but decided against this. Next i was just going to create my own 'format file' class in visual basic and build my own format file from scratch, but i think there HAS to be an easier solution.
So, i guess..basically, my question is this: Is there anyway to dynamically create a format file in a relatively 'painless' manner?
Thanks for the help!
i was recently given an assignment to write a program in visual basic 6 which reads in a textfile's path, a database table, and a 'field map', a delimited char, and a couple other parameters which aren't important to this discussion.
Now, what this program's task to do is: import the values in the text file to the SQL 2k database table based on the 'field map'. This 'field map' basically will come in the form of, for example, 1=2, 3=4 (ie, column 1 in the text file goes in column 2 in the table, column 3 in the text file goes in column 4 in the table, ect).
So far i have created a BulkInsert Task object and i am able to import data into the table when there is an exact mapping, but i'm stuck on the 'field mapping' part. Originally, i was going to execute a stored procedure to the bcp to create a format file, but decided against this. Next i was just going to create my own 'format file' class in visual basic and build my own format file from scratch, but i think there HAS to be an easier solution.
So, i guess..basically, my question is this: Is there anyway to dynamically create a format file in a relatively 'painless' manner?
Thanks for the help!