CSV file to datagrid, data missing & funny character

Discussion in 'ASP .Net Datagrid Control' started by Jullietta, Oct 25, 2004.

  1. Jullietta

    Jullietta Guest

    Hi,

    I'm trying to import data from a CSV file to a dataset, then trying to
    add this to a datagrid.

    Problem is the datagrid is only displaying the first element in the
    CSV file with a funny 'yp' character in the first cell.

    The header is being created from the schema.ini

    The totally confused Jules



    Dim strConnectionString As String
    Dim strPathToTextFile As String

    Dim tempString As String

    strPathToTextFile = Server.MapPath("")

    strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & strPathToTextFile & ";" & _
    "Extended Properties=""text;HDR=NO;FMT=Delimited"""

    Dim objConnection As New
    System.Data.OleDb.OleDbConnection(strConnectionString)
    Dim objDS As New DataSet

    objConnection.Open()
    Dim objDA As New OleDbDataAdapter("SELECT * FROM CSV.txt",
    objConnection)

    objDA.Fill(objDS)

    If ((objDS.ToString <> "") And (objDS.Tables(0).Rows.Count >
    0)) Then
    'MyDataGrid.DataSource = objDS.Tables(0).DefaultView
    MyDataGrid.DataSource = objDS
    MyDataGrid.DataBind()

    End If
    objConnection.Close()
    End Sub
     
    Jullietta, Oct 25, 2004
    #1
    1. Advertising

  2. I suspect what you describe as a funny character is a Unicode identifier -
    so problems converting from one character set into another, I suspect. You
    may need to set your LCID and/or charsets to handle unicode data (if indeed
    this is the problem)


    --
    Jason Brown
    Microsoft GTSC, IIS

    This posting is provided "AS IS" with no warranties, and confers no
    rights.


    "Jullietta" <> wrote in message
    news:...
    > Hi,
    >
    > I'm trying to import data from a CSV file to a dataset, then trying to
    > add this to a datagrid.
    >
    > Problem is the datagrid is only displaying the first element in the
    > CSV file with a funny 'yp' character in the first cell.
    >
    > The header is being created from the schema.ini
    >
    > The totally confused Jules
    >
    >
    >
    > Dim strConnectionString As String
    > Dim strPathToTextFile As String
    >
    > Dim tempString As String
    >
    > strPathToTextFile = Server.MapPath("")
    >
    > strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    > "Data Source=" & strPathToTextFile & ";" & _
    > "Extended Properties=""text;HDR=NO;FMT=Delimited"""
    >
    > Dim objConnection As New
    > System.Data.OleDb.OleDbConnection(strConnectionString)
    > Dim objDS As New DataSet
    >
    > objConnection.Open()
    > Dim objDA As New OleDbDataAdapter("SELECT * FROM CSV.txt",
    > objConnection)
    >
    > objDA.Fill(objDS)
    >
    > If ((objDS.ToString <> "") And (objDS.Tables(0).Rows.Count >
    > 0)) Then
    > 'MyDataGrid.DataSource = objDS.Tables(0).DefaultView
    > MyDataGrid.DataSource = objDS
    > MyDataGrid.DataBind()
    >
    > End If
    > objConnection.Close()
    > End Sub
     
    Jason Brown [MSFT], Oct 25, 2004
    #2
    1. Advertising

  3. Jullietta

    Jullietta Guest

    Thanx Jason, all I had to do was change a line in the schema file to
    handle unicode characters!!

    If anyone else has this problem here is the schema.ini file that
    solved my problem.


    Cheers
    Jules


    [CSV.txt]
    ColNameHeader=False
    Format=CSVDelimited
    MaxScanRows=0
    CharacterSet=UNICODE
    Col1=RecordType Char Width 200
    Col2=DateAndTime Char Width 200
    Col3=AO Char Width 200
    Col4=Object Char Width 200
    Col5=asd Char Width 200
    Col6=dfg Char Width 200
     
    Jullietta, Oct 26, 2004
    #3
    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. Jullietta
    Replies:
    1
    Views:
    387
    cbDevelopment
    Oct 28, 2004
  2. raavi
    Replies:
    2
    Views:
    917
    raavi
    Mar 2, 2006
  3. Tintin92
    Replies:
    1
    Views:
    1,753
    Andrew Thompson
    Feb 14, 2007
  4. jliu66
    Replies:
    0
    Views:
    531
    jliu66
    Oct 19, 2007
  5. Li Chen
    Replies:
    18
    Views:
    687
    Azmi Farih
    Mar 23, 2010
Loading...

Share This Page