File name problem

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I found that if I do a select from .csv file, it won't work if the filename
has "." or "-" in them such as:

PAYROLL.ALLOC.RPT_8511_3-15-07.CSV

I am doing the following:

Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)

Dim da2 As New OleDb.OleDbDataAdapter("Select * from " &
"PAYROLL.ALLOC.RPT_8511_3-15-07.CSV", conn)
da2.Fill(DTDepartment)

If I replace 1st 2 periods (".") and dashes with underscores it works fine.

But this works:

If f.Exists(path & "PAYROLL.ALLOC.RPT_8511_3-15-07.CSV") Then

And this works:

objStreamWriter = New StreamWriter(
"PAYROLL.ALLOC.RPT_8511_3-15-07.CSV")

I assume that the periods and dashes are illegal characters for a file name
in the Select statement but why not in the other cases?

The problem is that I am getting this file from a Java system and that is
what they are calling their filename. Is there a way around this?

Thanks,

Tom
 
Standard question #1:
What do you mean by "not working"?

Standard question #2:
What error message do you get?

As I have no error message to go on, I can only guess to the cause, and
I guess that it's the parsing of the connection string that fails rather
than the use of the path.

I don't know if it's supported, but try to put quotes around the path,
just like there are quotes around the extended properties.
 
Tom,

Why don't you try renaming the file to something simple and succint before
you open the DataAdapter?

My guess is that the Microsoft Jet Engine ISAM handling doesn't like the "."
or "-" s.
Just because MS File handling and Dot Net can handle them doesn't mean other
MS components will! That would cause too much standardisation and remove too
many challenges :-)

Doug
 
Back
Top