Drydo's Blog

Teenager of the Internet

This blog hosted by:
http://blogs.vbcity.com
  Home :: Syndication  :: Login   Community Forums   :: vbCity.com   :: DevCity.NET  

I guess as developers we're used to solving the difficult problems, this task isn't working because of dependancy X, Y and Z - so we code around that, handshake with this and validate the other. But as a developer its always the simple things that catch you out.

For instance, I've spent the last 4 hours messing around with loading a comma delimited textfile into a typed dataset using one dataadapter, do some funky things to it and then upload those records into an SQL Server using an SQLDataAdapter. Sounds easy, and it is - check out this previous post for an example.

So, I coded it up and interestingly it loaded the datarows correctly - but all the fields were NULL! Now things shouldn't be more easier than this - you SELECT the data, it flys into the strongly typed dataset and job done. I then spent my time working backwards through the code, exploring the various problems that might be occuring (tablemapping and that kinda thing). However, the problem was much easier to diagnose - basically, a similar issue came up in the forums with someone using the same code as linked and the answer was...

Change the file extension of the textfile being imported! It turns out that the JET driver has certain restrictions placed upon it, by using a '.txt' extension it was expecting a tab delimited file - by changing the extension to '.csv' everything started working. Check out this MS Support Page on the very subject, where only certain file extensions are supported and are subtlly dealt with in different ways.

HTHs somebody - M

posted on Monday, January 28, 2008 11:22 AM

Feedback

# re: Importing a textfile to a typed dataset (failing and resolving) 7/26/2008 12:42 PM Andreas M.
You know about schema.ini?
--> http://www.connectionstrings.com/?carrier=textfile

Post Feedback

Title:
Name:
Url:
Comments: 
Protected by Clearscreen.SharpHIPEnter the code you see: