Problem while filling the dataset where the data source is a .CSV file



I am trying to reading a .csv file from a remote desktop.

the connection string that i am using is as follows:

strConn = "Provider=MS Remote;"+"Remote Server=//<ComputerName>/
<FolederName>;" + " Remote Provider=Microsoft.Jet.OLEDB.4.0;"+"Data

With this connection string i am able to open the connection but when
i try to fill the data set it gives me the error:

"Specified Cast is not valid"

the line is


where 'da' is the OleDbDataAdapter and 'ds' is the dataset

The complete Block of code is as follows:

string strConn;
OleDbConnection conn ;
OleDbDataAdapter da;

strConn = "Provider=MS Remote;"+"Remote Server=//ind-spz4dxp612/
trial;" + " Remote Provider=Microsoft.Jet.OLEDB.4.0;"+"Data

conn = new OleDbConnection(strConn);
da = new OleDbDataAdapter("SELECT * FROM [TRY1.CSV]",conn);
da.Fill(ds);========== This Is The line which gives this error.

Your help and inputs will be appreciated.


Thank you so much for your reply.
i went thru the link provided but couldnt find helpk relavant to my

also i would like add some more information to the same........

hope i can find some more help........

i would also like to bring to your note dat i m using an impersonated
user (programatically)
there are two cases:


if i include the <identity impersonate="true"> in web config

and use the following string

strConnA = "Provider=MS Remote;"+"Remote Server="+@"\\<comp name>
\<foleder name>;" + " Remote Provider=Microsoft.Jet.OLEDB.4.0;"+"Data

i get the error "MS remote is not registered in the local machine"

and if i use the following string
strConnB ="Provider=Microsoft.Jet.Oledb.4.0;"+"Data Source="+"\\<comp
name>\<foleder name>;"+"Extended

i get the error " Microsoft.Jet.Oledb.4.0 is not registered in the
local machine"
whereas Microsoft jet with the latesh version is available on my
machine (win XP)

and the second is

if i set <identity impersonate="false"> then with

the strConnA i get the error "specified cast is not valid"

and with strConnB i get "Unspecified error"

i m really not sure which is the right path dat i should go ahead with
there being so many option

it would be really helpful if you could tell me wut would ideally be
the right path(i mean whc string should i use and should i set the
idedntity to true o not)

i really need this.have been racking my head since quite some time now
on this
plz do help


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