File name problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tshad

    #1

    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.R PT_8511_3-15-07.CSV

    I am doing the following:

    Dim ConStr As String = _
    "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
    path & ";Extended Properties=""Te xt;HDR=No;FMT=D elimited\"""
    Dim conn As New OleDb.OleDbConn ection(ConStr)

    Dim da2 As New OleDb.OleDbData Adapter("Select * from " &
    "PAYROLL.ALLOC. RPT_8511_3-15-07.CSV", conn)
    da2.Fill(DTDepa rtment)

    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


  • =?ISO-8859-1?Q?G=F6ran_Andersson?=

    #2
    Re: File name problem

    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.

    tshad wrote:
    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.R PT_8511_3-15-07.CSV
    >
    I am doing the following:
    >
    Dim ConStr As String = _
    "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
    path & ";Extended Properties=""Te xt;HDR=No;FMT=D elimited\"""
    Dim conn As New OleDb.OleDbConn ection(ConStr)
    >
    Dim da2 As New OleDb.OleDbData Adapter("Select * from " &
    "PAYROLL.ALLOC. RPT_8511_3-15-07.CSV", conn)
    da2.Fill(DTDepa rtment)
    >
    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
    >
    >

    --
    Göran Andersson
    _____
    Göran Anderssons privata hemsida.

    Comment

    • Doug Bell

      #3
      Re: File name problem

      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

      "tshad" <t@home.comwrot e in message
      news:eiJX51VcHH A.2068@TK2MSFTN GP06.phx.gbl...
      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.R PT_8511_3-15-07.CSV
      >
      I am doing the following:
      >
      Dim ConStr As String = _
      "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
      path & ";Extended Properties=""Te xt;HDR=No;FMT=D elimited\"""
      Dim conn As New OleDb.OleDbConn ection(ConStr)
      >
      Dim da2 As New OleDb.OleDbData Adapter("Select * from " &
      "PAYROLL.ALLOC. RPT_8511_3-15-07.CSV", conn)
      da2.Fill(DTDepa rtment)
      >
      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
      >
      >

      Comment

      Working...