Connection String error in VB.net

M

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
 
T

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:
 
M

Manoj Nair

hi Tommaso,

The solution worked.
This was needed for a project am currently working on.

Thanks
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:
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
 
T

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top