Home All Groups Group Topic Archive Search About

Connection String error in VB.net

Author
15 Apr 2006 7:44 AM
Manoj Nair
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

Author
15 Apr 2006 12:27 PM
tommaso.gastaldi
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
Author
15 Apr 2006 1:24 PM
Manoj Nair
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
>
Author
15 Apr 2006 2:39 PM
tommaso.gastaldi
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