DataAdapter select assuming integer

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

    #1

    DataAdapter select assuming integer

    How do I tell DataAdapter that Column 2 and 3 are string and not integer?
    Following is the example data that comes from the .csv file

    FEDERAL TAX,1084,0000
    COREHCR,1084,00 00
    CLIENT P,1084,0000

    The select is:

    Dim da2 As New OleDb.OleDbData Adapter("Select * from " &
    "CorelandGLConv ersion.csv", conn)

    The problem is that it thinks the 3rd column is an integer and changes the
    0000 to 0.

    Can I tell it in the Select statement that the column is a varChar? I can't
    do it after reading in the data as the data will already have changed the
    0000 to 0 at that point.

    Thanks,

    Tom.


  • tshad

    #2
    Re: DataAdapter select assuming integer

    "tshad" <t@home.comwrot e in message
    news:%23O2E%234 NcHHA.4888@TK2M SFTNGP02.phx.gb l...
    How do I tell DataAdapter that Column 2 and 3 are string and not integer?
    Following is the example data that comes from the .csv file
    >
    FEDERAL TAX,1084,0000
    COREHCR,1084,00 00
    CLIENT P,1084,0000
    >
    The select is:
    >
    Dim da2 As New OleDb.OleDbData Adapter("Select * from " &
    "CorelandGLConv ersion.csv", conn)
    >
    The problem is that it thinks the 3rd column is an integer and changes the
    0000 to 0.
    >
    Can I tell it in the Select statement that the column is a varChar? I
    can't do it after reading in the data as the data will already have
    changed the 0000 to 0 at that point.
    I tried to set up the table as:

    Dim DTGLConversion as DataTable

    DTGLConversion. Columns.Add("F1 ", System.Type.Get Type("System.St ring"))
    DTGLConversion. Columns.Add("F2 ", System.Type.Get Type("System.St ring"))
    DTGLConversion. Columns.Add("F3 ", System.Type.Get Type("System.St ring"))

    da2.Fill(DTGLCo nversion)
    DataSetObj.Tabl es.Add(DTGLConv ersion)

    This sets up the columns as strings in the DTGLConversion Table and adds it
    to the Dataset but it seems the Select in the DataAdapter must have already
    converted the string "0000" to integer 0 and then when I filled the
    DataTable it reconverted it to "0".

    How do I fix this?

    Thanks,

    Tom
    >
    Thanks,
    >
    Tom.
    >

    Comment

    • Branco Medeiros

      #3
      Re: DataAdapter select assuming integer

      tshad wrote:
      How do I tell DataAdapter that Column 2 and 3 are string and not integer?
      Following is the example data that comes from the .csv file
      >
      FEDERAL TAX,1084,0000
      COREHCR,1084,00 00
      CLIENT P,1084,0000
      >
      The select is:
      >
      Dim da2 As New OleDb.OleDbData Adapter("Select * from " &
      "CorelandGLConv ersion.csv", conn)
      >
      The problem is that it thinks the 3rd column is an integer and changes the
      0000 to 0.
      The way to tell the text driver the data type of your columns (and
      more) is to have a schema.ini file in the same forlder as your data
      file.
      In your case, your schema.ini could be something like:

      [CorelandGLConve rsion.csv]
      Format=CSVDelim ited
      ColNameHeader=F alse
      Col1=FirstColNa me Text
      Col2=SecondColN ame Long
      Col3=ThirdColNa me Text

      HTH.

      Regards,

      Branco.

      Comment

      Working...