First Record in DataSet corrupted

Discussion in 'ASP .Net Datagrid Control' started by Roger Twomey, Apr 28, 2004.

  1. Roger Twomey

    Roger Twomey Guest

    I have a web app that allows a user to upload an excel spread sheet and then
    view it on the web (okay it does more than that but this is the part with a
    problem).

    The spread sheet uploads correctly, it even displays well in the data grid.
    There is one problem however.

    The first record always seems to be corrupt.

    In my spreadsheet I have the following records:


    456456456 456456456 John Doe 7057431006

    789789789 789789789 Frank Doe 7057431006
    123123123 123123123 Albert Doe 7057431006
    963963963 963963963 Johannus Doe 7057431006
    852852852 852852852 Jack Doe 7057431006
    741741741 741741741 Andrew Doe 7057431006


    Output from the data grid shows the exact same data EXCEPT the first row
    is:'

    F1 F2 John Doe F5 fred@abc#com

    Does anyone have any idea what might be happening here?

    here is the code:

    <code>
    Dim myds As New DataSet
    Dim MyExcelConnectStr As String = "Provider=Microsoft.Jet.OLEDb.4.0;data
    source=" & strFileName & ";Extended Properties=""Excel 8.0;"""

    Dim MyOleADapter As New OleDb.OleDbDataAdapter("SELECT * FROM
    [Sheet1$]", MyExcelConnectStr)

    MyOleADapter.Fill(myds, "xlsdata")

    DataGrid1.DataSource = myds.Tables(0)

    DataGrid1.DataBind()

    </code>
    Roger Twomey, Apr 28, 2004
    #1
    1. Advertising

  2. Roger Twomey

    CT Guest

    It looks as if the first row is treated as the field/column names, and where
    a number is specified, it's replaced with F1, F2, and so on. Haven't worked
    with Excel data, but I assume there's a setting to be specified to take care
    of this. According to http://www.connectionstrings.com, you can specify the
    HDR=No NVP as part of the Extended Properties attribute.

    --
    Carsten Thomsen
    Enterprise Development with VS .NET, UML, and MSF
    http://www.apress.com/book/bookDisplay.html?bID=105
    "Roger Twomey" <> wrote in message
    news:...
    >I have a web app that allows a user to upload an excel spread sheet and
    >then
    > view it on the web (okay it does more than that but this is the part with
    > a
    > problem).
    >
    > The spread sheet uploads correctly, it even displays well in the data
    > grid.
    > There is one problem however.
    >
    > The first record always seems to be corrupt.
    >
    > In my spreadsheet I have the following records:
    >
    >
    > 456456456 456456456 John Doe 7057431006
    >
    > 789789789 789789789 Frank Doe 7057431006
    > 123123123 123123123 Albert Doe 7057431006
    > 963963963 963963963 Johannus Doe 7057431006
    > 852852852 852852852 Jack Doe 7057431006
    > 741741741 741741741 Andrew Doe 7057431006
    >
    >
    > Output from the data grid shows the exact same data EXCEPT the first row
    > is:'
    >
    > F1 F2 John Doe F5 fred@abc#com
    >
    > Does anyone have any idea what might be happening here?
    >
    > here is the code:
    >
    > <code>
    > Dim myds As New DataSet
    > Dim MyExcelConnectStr As String =
    > "Provider=Microsoft.Jet.OLEDb.4.0;data
    > source=" & strFileName & ";Extended Properties=""Excel 8.0;"""
    >
    > Dim MyOleADapter As New OleDb.OleDbDataAdapter("SELECT * FROM
    > [Sheet1$]", MyExcelConnectStr)
    >
    > MyOleADapter.Fill(myds, "xlsdata")
    >
    > DataGrid1.DataSource = myds.Tables(0)
    >
    > DataGrid1.DataBind()
    >
    > </code>
    >
    >
    CT, Apr 28, 2004
    #2
    1. Advertising

  3. Roger Twomey

    Roger Twomey Guest

    That was it.

    Thank you.

    I have added another site to my bookmarks.

    "CT" <> wrote in message
    news:...
    > It looks as if the first row is treated as the field/column names, and

    where
    > a number is specified, it's replaced with F1, F2, and so on. Haven't

    worked
    > with Excel data, but I assume there's a setting to be specified to take

    care
    > of this. According to http://www.connectionstrings.com, you can specify

    the
    > HDR=No NVP as part of the Extended Properties attribute.
    >
    > --
    > Carsten Thomsen
    > Enterprise Development with VS .NET, UML, and MSF
    > http://www.apress.com/book/bookDisplay.html?bID=105
    > "Roger Twomey" <> wrote in message
    > news:...
    > >I have a web app that allows a user to upload an excel spread sheet and
    > >then
    > > view it on the web (okay it does more than that but this is the part

    with
    > > a
    > > problem).
    > >
    > > The spread sheet uploads correctly, it even displays well in the data
    > > grid.
    > > There is one problem however.
    > >
    > > The first record always seems to be corrupt.
    > >
    > > In my spreadsheet I have the following records:
    > >
    > >
    > > 456456456 456456456 John Doe 7057431006
    > >
    > > 789789789 789789789 Frank Doe 7057431006
    > > 123123123 123123123 Albert Doe 7057431006
    > > 963963963 963963963 Johannus Doe 7057431006
    > > 852852852 852852852 Jack Doe 7057431006
    > > 741741741 741741741 Andrew Doe 7057431006
    > >
    > >
    > > Output from the data grid shows the exact same data EXCEPT the first row
    > > is:'
    > >
    > > F1 F2 John Doe F5 fred@abc#com
    > >
    > > Does anyone have any idea what might be happening here?
    > >
    > > here is the code:
    > >
    > > <code>
    > > Dim myds As New DataSet
    > > Dim MyExcelConnectStr As String =
    > > "Provider=Microsoft.Jet.OLEDb.4.0;data
    > > source=" & strFileName & ";Extended Properties=""Excel 8.0;"""
    > >
    > > Dim MyOleADapter As New OleDb.OleDbDataAdapter("SELECT * FROM
    > > [Sheet1$]", MyExcelConnectStr)
    > >
    > > MyOleADapter.Fill(myds, "xlsdata")
    > >
    > > DataGrid1.DataSource = myds.Tables(0)
    > >
    > > DataGrid1.DataBind()
    > >
    > > </code>
    > >
    > >

    >
    >
    Roger Twomey, Apr 28, 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. Roger Twomey

    First Record in DataSet corrupted

    Roger Twomey, Apr 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    438
    Roger Twomey
    Apr 28, 2004
  2. =?Utf-8?B?SnVzdGlu?=

    Retrieving Record Key while creating the record.

    =?Utf-8?B?SnVzdGlu?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    621
    =?Utf-8?B?SnVzdGlu?=
    Oct 5, 2004
  3. Guest
    Replies:
    7
    Views:
    664
    Walter Wang [MSFT]
    Jun 28, 2006
  4. André
    Replies:
    0
    Views:
    3,730
    André
    Jun 25, 2006
  5. Eyal
    Replies:
    9
    Views:
    163
    Erwin Moller
    Sep 10, 2007
Loading...

Share This Page