importing data from excel sheet to datagridView

F

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
 
F

friend

Hi,

This sounds like the hdr option in the connection string,

http://www.connectionstrings.com/excel

Cor


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
 
F

friend

Hi,

This sounds like the hdr option in the connection string,

http://www.connectionstrings.com/excel

Cor


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
 
S

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




Hi,

This sounds like the hdr option in the connection string,

http://www.connectionstrings.com/excel

Cor


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
 
S

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




Hi,

This sounds like the hdr option in the connection string,

http://www.connectionstrings.com/excel

Cor


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
 
F

friend

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


This sounds like the hdr option in the connection string,

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
 
F

friend

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


This sounds like the hdr option in the connection string,

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
 

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

Top