|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Connection String error in VB.netWhen I load a csv file into a dataset with the column containing numeric data the header name string does not show up .Where as if the data in the columnis alphanumeric or text then the heading appears. I have tried thefollowing connection strings String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""text;HDR=Yes;FMT=Delimited""", Path.GetDirectoryName(mDataSource)) --------------------- String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Text;", Path.GetDirectoryName(mDataSource)) would appreciate help on this. thanks is advance Manoj Ni Manoj
Try this and let me know if it works: -Make a text file called "schema.ini" and place it in the same directory of your delimited file mDataSource -Place the following text into schema.ini [NameOfYourFile_mDataSource] ColNameHeader=True Format=Delimited(,) MaxScanRows=0 where in place of NameOfYourFile_mDataSource you write the file name of your delimited text file (example: [MyText.csv] ) -Run again your program (if delimiter is not a comma change the schema.ini accordingly) Manoj Nair ha scritto: Show quoteHide quote > Hi, > > When I load a csv file into a dataset with the column containing numeric > data the header name string does not show up .Where as if the data in the > columnis alphanumeric or text then the heading appears. > > I have tried thefollowing connection strings > String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended > Properties=""text;HDR=Yes;FMT=Delimited""", > Path.GetDirectoryName(mDataSource)) > > --------------------- > > String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended > Properties=Text;", Path.GetDirectoryName(mDataSource)) > > would appreciate help on this. > > thanks is advance > > Manoj hi Tommaso,
The solution worked. This was needed for a project am currently working on. Thanks Manoj <tommaso.gasta***@uniroma1.it> wrote in message Show quoteHide quote news:1145104041.245804.223100@i39g2000cwa.googlegroups.com... > Ni Manoj > > Try this and let me know if it works: > > -Make a text file called "schema.ini" and place it in the same > directory of your delimited file mDataSource > > -Place the following text into schema.ini > > [NameOfYourFile_mDataSource] > ColNameHeader=True > Format=Delimited(,) > MaxScanRows=0 > > where in place of NameOfYourFile_mDataSource you write the file name of > your > delimited text file (example: [MyText.csv] ) > > -Run again your program (if delimiter is not a comma change the > schema.ini accordingly) > > Manoj Nair ha scritto: > >> Hi, >> >> When I load a csv file into a dataset with the column containing numeric >> data the header name string does not show up .Where as if the data in >> the >> columnis alphanumeric or text then the heading appears. >> >> I have tried thefollowing connection strings >> String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended >> Properties=""text;HDR=Yes;FMT=Delimited""", >> Path.GetDirectoryName(mDataSource)) >> >> --------------------- >> >> String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended >> Properties=Text;", Path.GetDirectoryName(mDataSource)) >> >> would appreciate help on this. >> >> thanks is advance >> >> Manoj > Good.
It's quite annoying having to resort to the schema.ini file. Actually I would like to do it programmatically, but so far my attempts have failed. IMEX=1 (Intermixed data) in the connection string seems to work only with EXCEL. Problem is that the TEXT driver attempts to recognize the type and (by default) assigns it based on the mayority of data. Setting MaxScanRows=0 prevents this scanning and it is forced to choose "string" for all fields. If anyone knows a programmatic way, I'd very happy to know... -tom |
|||||||||||||||||||||||