jeremyj54
asked on
Input array longer than number of columns Error importing csv to sql server using vb.net
I am trying to have this app search through a directory and everything in the directory that is not older than 20 hours import into sql server. If I use this app with the attached file "test file that works" everything works fine. If I use it with the attached file "test file that does not work" I get an error "Input array is longer than the number of columns in this table" at the time of filling the datatable. The only difference I can see is the one that doesn't work has many more rows of data than the one that does work. I also tryed taking the one that does not work and delete all rows but the first 20 and it worked.
code.txt
testStabilityDetail-501501-1.csv
StabilityDetail-501643-1.csv
code.txt
testStabilityDetail-501501-1.csv
StabilityDetail-501643-1.csv
There must be a row with a extra comma somewhere.
ASKER
There are not, actually what I found is that if I open that file and save it the application works fine but since I am trying to load many files a day that is not an option. Why is the application seeing it incorrectly.
It can be encoding. Do you know what encoding the input files are in?
ASKER
I don't, how would I find out, and what would I do with encoding?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There are not, actually what I found is that if I open that file and save it the application works fine but since I am trying to load many files a day that is not an option. Why is the application seeing it incorrectly.
It is also possible that no one have used the cells and cells are empty, so StreamReader can not evaluate if it is a used cell or not and returned less values than the no of columns.