469,948 Members | 2,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,948 developers. It's quick & easy.

File name problem

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
Mar 28 '07 #1
1 1277
On Mar 28, 7:21 pm, "tshad" <t...@home.comwrote:
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
Enclose the name in square brackets

Select * from [PAYROLL.ALLOC.RPT_8511_3-15-07.CSV]

Mar 28 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Sean Ross | last post: by
3 posts views Thread by Abhas | last post: by
4 posts views Thread by robin1983 | last post: by
185 posts views Thread by jacob navia | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.