Home All Groups Group Topic Archive Search About

importing data from excel sheet to datagridView

Author
20 May 2009 8:14 AM
friend
Hello all,
When I import the data from excel to datagridview in my project first
row is missing when displayed in the datagridivew

Excel data:

Field content    1234
10386524178    3434
31497645790    3434
61417861227    3434
21555680106    3434
66547895251    3434
7309310634    3434
6202733735    3434
50444214805    3434


after importing into datagridview:

Field content    F1
10386524178    3434
31497645790    3434
61417861227    3434
21555680106    3434
66547895251    3434
7309310634    3434
6202733735    3434
50444214805    3434

if i write any string the first row then it gets displayed but if i
write any integer then it gets replaced by F1

Here is my code:

                Dim MyConnection As System.Data.OleDb.OleDbConnection
                Dim DtSet As System.Data.DataSet
                Dim MyCommand As System.Data.OleDb.OleDbDataAdapter

                MyConnection = New System.Data.OleDb.OleDbConnection
("provider=Microsoft.Jet.OLEDB.4.0; data source= " & Table1.xls &
";Extended Properties=Excel 8.0;")
                MyCommand = New System.Data.OleDb.OleDbDataAdapter
("select * from [Tabelle1$]", MyConnection)
                MyCommand.TableMappings.Add("Table", "TestTable")
                DtSet = New System.Data.DataSet
                MyCommand.Fill(DtSet)
                DataGridView1.DataSource = DtSet.Tables(0)


How to resolve this...Thanks for any help

Author
20 May 2009 8:26 AM
Cor Ligthert[MVP]
Hi,

This sounds like the hdr option in the connection string,

http://www.connectionstrings.com/excel

Cor

Show quoteHide quote
"friend" <lavanyaredd***@gmail.com> wrote in message
news:2f269168-2770-41fe-93b9-9bb0669b0e33@s21g2000vbb.googlegroups.com...
> Hello all,
> When I import the data from excel to datagridview in my project first
> row is missing when displayed in the datagridivew
>
> Excel data:
>
> Field content 1234
> 10386524178 3434
> 31497645790 3434
> 61417861227 3434
> 21555680106 3434
> 66547895251 3434
> 7309310634 3434
> 6202733735 3434
> 50444214805 3434
>
>
> after importing into datagridview:
>
> Field content F1
> 10386524178 3434
> 31497645790 3434
> 61417861227 3434
> 21555680106 3434
> 66547895251 3434
> 7309310634 3434
> 6202733735 3434
> 50444214805 3434
>
> if i write any string the first row then it gets displayed but if i
> write any integer then it gets replaced by F1
>
> Here is my code:
>
>                Dim MyConnection As System.Data.OleDb.OleDbConnection
>                Dim DtSet As System.Data.DataSet
>                Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
>
>                MyConnection = New System.Data.OleDb.OleDbConnection
> ("provider=Microsoft.Jet.OLEDB.4.0; data source= " & Table1.xls &
> ";Extended Properties=Excel 8.0;")
>                MyCommand = New System.Data.OleDb.OleDbDataAdapter
> ("select * from [Tabelle1$]", MyConnection)
>                MyCommand.TableMappings.Add("Table", "TestTable")
>                DtSet = New System.Data.DataSet
>                MyCommand.Fill(DtSet)
>                DataGridView1.DataSource = DtSet.Tables(0)
>
>
> How to resolve this...Thanks for any help
>
Author
20 May 2009 9:22 AM
friend
Show quote Hide quote
On May 20, 10:26 am, "Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl>
wrote:
> Hi,
>
> This sounds like the hdr option in the connection string,
>
> http://www.connectionstrings.com/excel
>
> Cor
>
> "friend" <lavanyaredd***@gmail.com> wrote in message
>
> news:2f269168-2770-41fe-93b9-9bb0669b0e33@s21g2000vbb.googlegroups.com...
>
> > Hello all,
> > When I import the data from excel to datagridview in my project first
> > row is missing when displayed in the datagridivew
>
> > Excel data:
>
> > Field content 1234
> > 10386524178 3434
> > 31497645790 3434
> > 61417861227 3434
> > 21555680106 3434
> > 66547895251 3434
> > 7309310634 3434
> > 6202733735 3434
> > 50444214805 3434
>
> > after importing into datagridview:
>
> > Field content F1
> > 10386524178 3434
> > 31497645790 3434
> > 61417861227 3434
> > 21555680106 3434
> > 66547895251 3434
> > 7309310634 3434
> > 6202733735 3434
> > 50444214805 3434
>
> > if i write any string the first row then it gets displayed but if i
> > write any integer then it gets replaced by F1
>
> > Here is my code:
>
> >                Dim MyConnection As System.Data.OleDb.OleDbConnection
> >                Dim DtSet As System.Data.DataSet
> >                Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
>
> >                MyConnection = New System.Data.OleDb.OleDbConnection
> > ("provider=Microsoft.Jet.OLEDB.4.0; data source= " & Table1.xls &
> > ";Extended Properties=Excel 8.0;")
> >                MyCommand = New System.Data.OleDb.OleDbDataAdapter
> > ("select * from [Tabelle1$]", MyConnection)
> >                MyCommand.TableMappings.Add("Table", "TestTable")
> >                DtSet = New System.Data.DataSet
> >                MyCommand.Fill(DtSet)
> >                DataGridView1.DataSource = DtSet.Tables(0)
>
> > How to resolve this...Thanks for any help
>
>

It doesnt work with HDR option in the connection string
Author
20 May 2009 4:20 PM
sloan
You need to be super super anal with Excel connection strings.

Are there spaces in the filename?

99 times out of 100, its because there is something off with your excel
connection string.

Every single quote , semi colon ...anything and everything has to be
correct.

Post your full (not variable driven) connection string...........




Show quoteHide quote
"friend" <lavanyaredd***@gmail.com> wrote in message
news:6c62c95a-12ec-4b13-990d-6208e0785c74@n8g2000vbb.googlegroups.com...
On May 20, 10:26 am, "Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl>
wrote:
> Hi,
>
> This sounds like the hdr option in the connection string,
>
> http://www.connectionstrings.com/excel
>
> Cor
>
> "friend" <lavanyaredd***@gmail.com> wrote in message
>
> news:2f269168-2770-41fe-93b9-9bb0669b0e33@s21g2000vbb.googlegroups.com...
>
> > Hello all,
> > When I import the data from excel to datagridview in my project first
> > row is missing when displayed in the datagridivew
>
> > Excel data:
>
> > Field content 1234
> > 10386524178 3434
> > 31497645790 3434
> > 61417861227 3434
> > 21555680106 3434
> > 66547895251 3434
> > 7309310634 3434
> > 6202733735 3434
> > 50444214805 3434
>
> > after importing into datagridview:
>
> > Field content F1
> > 10386524178 3434
> > 31497645790 3434
> > 61417861227 3434
> > 21555680106 3434
> > 66547895251 3434
> > 7309310634 3434
> > 6202733735 3434
> > 50444214805 3434
>
> > if i write any string the first row then it gets displayed but if i
> > write any integer then it gets replaced by F1
>
> > Here is my code:
>
> > Dim MyConnection As System.Data.OleDb.OleDbConnection
> > Dim DtSet As System.Data.DataSet
> > Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
>
> > MyConnection = New System.Data.OleDb.OleDbConnection
> > ("provider=Microsoft.Jet.OLEDB.4.0; data source= " & Table1.xls &
> > ";Extended Properties=Excel 8.0;")
> > MyCommand = New System.Data.OleDb.OleDbDataAdapter
> > ("select * from [Tabelle1$]", MyConnection)
> > MyCommand.TableMappings.Add("Table", "TestTable")
> > DtSet = New System.Data.DataSet
> > MyCommand.Fill(DtSet)
> > DataGridView1.DataSource = DtSet.Tables(0)
>
> > How to resolve this...Thanks for any help
>
>

It doesnt work with HDR option in the connection string
Author
25 May 2009 7:56 PM
friend
Show quote Hide quote
On May 20, 6:20 pm, "sloan" <sl***@ipass.net> wrote:
> You need to be super super anal with Excel connection strings.
>
> Are there spaces in the filename?
>
> 99 times out of 100, its because there is something off with your excel
> connection string.
>
> Every single quote , semi colon ...anything and everything has to be
> correct.
>
> Post your full (not variable driven) connection string...........
>
> "friend" <lavanyaredd***@gmail.com> wrote in message
>
> news:6c62c95a-12ec-4b13-990d-6208e0785c74@n8g2000vbb.googlegroups.com...
> On May 20, 10:26 am, "Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl>
> wrote:
>
>
>
>
>
> > Hi,
>
> > This sounds like the hdr option in the connection string,
>
> >http://www.connectionstrings.com/excel
>
> > Cor
>
> > "friend" <lavanyaredd***@gmail.com> wrote in message
>
> >news:2f269168-2770-41fe-93b9-9bb0669b0e33@s21g2000vbb.googlegroups.com....
>
> > > Hello all,
> > > When I import the data from excel to datagridview in my project first
> > > row is missing when displayed in the datagridivew
>
> > > Excel data:
>
> > > Field content 1234
> > > 10386524178 3434
> > > 31497645790 3434
> > > 61417861227 3434
> > > 21555680106 3434
> > > 66547895251 3434
> > > 7309310634 3434
> > > 6202733735 3434
> > > 50444214805 3434
>
> > > after importing into datagridview:
>
> > > Field content F1
> > > 10386524178 3434
> > > 31497645790 3434
> > > 61417861227 3434
> > > 21555680106 3434
> > > 66547895251 3434
> > > 7309310634 3434
> > > 6202733735 3434
> > > 50444214805 3434
>
> > > if i write any string the first row then it gets displayed but if i
> > > write any integer then it gets replaced by F1
>
> > > Here is my code:
>
> > > Dim MyConnection As System.Data.OleDb.OleDbConnection
> > > Dim DtSet As System.Data.DataSet
> > > Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
>
> > > MyConnection = New System.Data.OleDb.OleDbConnection
> > > ("provider=Microsoft.Jet.OLEDB.4.0; data source= " & Table1.xls &
> > > ";Extended Properties=Excel 8.0;")
> > > MyCommand = New System.Data.OleDb.OleDbDataAdapter
> > > ("select * from [Tabelle1$]", MyConnection)
> > > MyCommand.TableMappings.Add("Table", "TestTable")
> > > DtSet = New System.Data.DataSet
> > > MyCommand.Fill(DtSet)
> > > DataGridView1.DataSource = DtSet.Tables(0)
>
> > > How to resolve this...Thanks for any help
>
> It doesnt work with HDR option in the connection string- Hide quoted text -
>
> - Show quoted text -

solved..thanks