DataAdapter select assuming integer

Discussion in 'ASP .Net' started by tshad, Mar 28, 2007.

  1. tshad

    tshad Guest

    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,0000
    CLIENT P,1084,0000

    The select is:

    Dim da2 As New OleDb.OleDbDataAdapter("Select * from " &
    "CorelandGLConversion.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, Mar 28, 2007
    #1
    1. Advertising

  2. tshad

    tshad Guest

    "tshad" <> wrote in message
    news:...
    > 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,0000
    > CLIENT P,1084,0000
    >
    > The select is:
    >
    > Dim da2 As New OleDb.OleDbDataAdapter("Select * from " &
    > "CorelandGLConversion.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.GetType("System.String"))
    DTGLConversion.Columns.Add("F2", System.Type.GetType("System.String"))
    DTGLConversion.Columns.Add("F3", System.Type.GetType("System.String"))

    da2.Fill(DTGLConversion)
    DataSetObj.Tables.Add(DTGLConversion)

    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
     
    tshad, Mar 28, 2007
    #2
    1. Advertising

  3. On Mar 28, 5:11 am, "tshad" <> wrote:
    > "tshad" <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > > 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,0000
    > > CLIENT P,1084,0000

    >
    > > The select is:

    >
    > > Dim da2 As New OleDb.OleDbDataAdapter("Select * from " &
    > > "CorelandGLConversion.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.GetType("System.String"))
    > DTGLConversion.Columns.Add("F2", System.Type.GetType("System.String"))
    > DTGLConversion.Columns.Add("F3", System.Type.GetType("System.String"))
    >
    > da2.Fill(DTGLConversion)
    > DataSetObj.Tables.Add(DTGLConversion)
    >
    > 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- Hide quoted text -
    >
    > - Show quoted text -


    Try to use schema.ini file

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcjetschema_ini_file.asp

    I think it should be similar to this

    [CorelandGLConversion.csv]
    Format=Delimited(;)
    ColNameHeader=True
    Col1=F1 Char
    Col2=F2 Char
    Col3=F3 Char

    and place that file in the same folder as the CSV file
     
    Alexey Smirnov, Mar 28, 2007
    #3
  4. tshad

    tshad Guest

    "Alexey Smirnov" <> wrote in message
    news:...
    > On Mar 28, 5:11 am, "tshad" <> wrote:
    >> "tshad" <> wrote in message
    >>
    >> news:...
    >>
    >>
    >>
    >>
    >>
    >> > 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,0000
    >> > CLIENT P,1084,0000

    >>
    >> > The select is:

    >>
    >> > Dim da2 As New OleDb.OleDbDataAdapter("Select * from " &
    >> > "CorelandGLConversion.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.GetType("System.String"))
    >> DTGLConversion.Columns.Add("F2", System.Type.GetType("System.String"))
    >> DTGLConversion.Columns.Add("F3", System.Type.GetType("System.String"))
    >>
    >> da2.Fill(DTGLConversion)
    >> DataSetObj.Tables.Add(DTGLConversion)
    >>
    >> 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- Hide quoted text -
    >>
    >> - Show quoted text -

    >
    > Try to use schema.ini file
    >
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcjetschema_ini_file.asp
    >
    > I think it should be similar to this
    >
    > [CorelandGLConversion.csv]
    > Format=Delimited(;)
    > ColNameHeader=True
    > Col1=F1 Char
    > Col2=F2 Char
    > Col3=F3 Char
    >
    > and place that file in the same folder as the CSV file


    It almost works. It does give me everything. But it doesn't split each
    line into 3 columns.

    It makes each line one columns and ignores the comma separators. If I
    change the name of the file in the schema file (so that it doesn't use it),
    it splits each line (row) into 3 columns.

    column 1 = FEDERAL TAX,1084,0000
    column 2 = Null
    column 3 = Null

    If I leave out the schema.ini file (or just change the file name in the
    file), I get:

    column 1 = FEDERAL TAX
    column 2 = 1084
    column 3 = 0

    Thanks,

    Tom
     
    tshad, Mar 28, 2007
    #4
  5. tshad

    tshad Guest

    Found it.

    I needed to have:

    Format=CSVDelimited

    in my file.

    Thanks,

    Tom
    "tshad" <> wrote in message
    news:...
    > "Alexey Smirnov" <> wrote in message
    > news:...
    >> On Mar 28, 5:11 am, "tshad" <> wrote:
    >>> "tshad" <> wrote in message
    >>>
    >>> news:...
    >>>
    >>>
    >>>
    >>>
    >>>
    >>> > 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,0000
    >>> > CLIENT P,1084,0000
    >>>
    >>> > The select is:
    >>>
    >>> > Dim da2 As New OleDb.OleDbDataAdapter("Select * from " &
    >>> > "CorelandGLConversion.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.GetType("System.String"))
    >>> DTGLConversion.Columns.Add("F2", System.Type.GetType("System.String"))
    >>> DTGLConversion.Columns.Add("F3", System.Type.GetType("System.String"))
    >>>
    >>> da2.Fill(DTGLConversion)
    >>> DataSetObj.Tables.Add(DTGLConversion)
    >>>
    >>> 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- Hide quoted text -
    >>>
    >>> - Show quoted text -

    >>
    >> Try to use schema.ini file
    >>
    >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcjetschema_ini_file.asp
    >>
    >> I think it should be similar to this
    >>
    >> [CorelandGLConversion.csv]
    >> Format=Delimited(;)
    >> ColNameHeader=True
    >> Col1=F1 Char
    >> Col2=F2 Char
    >> Col3=F3 Char
    >>
    >> and place that file in the same folder as the CSV file

    >
    > It almost works. It does give me everything. But it doesn't split each
    > line into 3 columns.
    >
    > It makes each line one columns and ignores the comma separators. If I
    > change the name of the file in the schema file (so that it doesn't use
    > it), it splits each line (row) into 3 columns.
    >
    > column 1 = FEDERAL TAX,1084,0000
    > column 2 = Null
    > column 3 = Null
    >
    > If I leave out the schema.ini file (or just change the file name in the
    > file), I get:
    >
    > column 1 = FEDERAL TAX
    > column 2 = 1084
    > column 3 = 0
    >
    > Thanks,
    >
    > Tom
    >
    >
     
    tshad, Mar 28, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles Krug
    Replies:
    7
    Views:
    366
    Harry George
    Jun 20, 2005
  2. smitdso

    undefined; assuming extern returning int

    smitdso, Oct 31, 2006, in forum: C Programming
    Replies:
    0
    Views:
    4,658
    smitdso
    Oct 31, 2006
  3. Gozirra

    Picking Up or Assuming Session???

    Gozirra, Oct 8, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    395
    Gozirra
    Oct 8, 2006
  4. Mikey C

    Assuming an existing session

    Mikey C, Feb 6, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    366
    Mikey C
    Feb 9, 2007
  5. =?Utf-8?B?TWlrZQ==?=

    Assuming a Session Timeout

    =?Utf-8?B?TWlrZQ==?=, Feb 13, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    333
    =?Utf-8?B?TWlrZQ==?=
    Feb 13, 2007
Loading...

Share This Page