Need help importing csv file into sql database using vb RRS feed

  • Question

  • I have a program that I need to import a csv file into sql database/tables.  I am using Visual Basic 2008 express and sql server. When complete I have to distribute this to several users where they will have csv files in the same format but with unique data.  It has been several years since I have done any programming and then it was vb6.  I have quickly realized that my vb6 books are going to do me no good. I have spent an entire day watching tutorial and reading forums to no use.

    The csv file is full of junk, where some of the records are 92 fields and some are 122.  The fields have data that may have dozens of characters before and/or after the data that I need.  On the good side I was able to pull the file into access and load it into two tables by using something along the lines of (where this = this, fill this table and the same for the second table.) So I have my 92 char records in one file and the 122 in another.  Unfortunately though I can not use access to do this as many of the users do not have it.  But by doing this I was able to work with the data in the file to get all of the fields set for name, length, type ect.   So then I went into my vb project and created the database with two files.  I set the fields up according to the information I got from the access tables.  So I know that these two tables are a perfect fit for the data in this file.

    What I need to be able to do is have the user browse through the program to find the csv file they will be using.  If they have followed my directions, they should have placed it in the same folder as they program I will send them.  I then need the program to take that file and import the data into my sql database/tables.  I have come to the conclusion, given the condition of this file, that rather than try and clean it up before using it, it will make more sense to just get it loaded into the two tables.  Then have my forms ect go and get the information that they need from the tables.  Then after we are done using the records save them to a clean tables.  I hope this all makes sense.  I have been hunting for information and watching various tutorials all day to no use.  Could someone please point me in the correct direction?

    Thursday, February 4, 2010 3:11 PM


All replies