First Record in DataSet corrupted

R

Roger Twomey

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 (e-mail address removed)

789789789 789789789 Frank Doe 7057431006 (e-mail address removed)
123123123 123123123 Albert Doe 7057431006 (e-mail address removed)
963963963 963963963 Johannus Doe 7057431006 (e-mail address removed)
852852852 852852852 Jack Doe 7057431006 (e-mail address removed)
741741741 741741741 Andrew Doe 7057431006 (e-mail address removed)


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>
 
C

CT

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.
 
R

Roger Twomey

That was it.

Thank you.

I have added another site to my bookmarks.

CT said:
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 said:
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 (e-mail address removed)

789789789 789789789 Frank Doe 7057431006 (e-mail address removed)
123123123 123123123 Albert Doe 7057431006 (e-mail address removed)
963963963 963963963 Johannus Doe 7057431006 (e-mail address removed)
852852852 852852852 Jack Doe 7057431006 (e-mail address removed)
741741741 741741741 Andrew Doe 7057431006 (e-mail address removed)


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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top