F
friend
Hello all,
I have the following code to fill the datagridview with excel sheet
data
MyConnection = New System.Data.OleDb.OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data source="
& filePath & ";Extended Properties='Excel
8.0;HDR=NO;'")
MyConnection.Open()
Dim schemaTable As DataTable = MyConnection.GetOleDbSchemaTable
(OleDbSchemaGuid.Tables, New object() {Nothing, Nothing, Nothing,
"TABLE"})
Dim dataRow As DataRow = schemaTable.Rows(0)
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * From [" +
DataRow("TABLE_NAME") + "]", MyConnection)
MyCommand.TableMappings.Add("Table", "TestTable")
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
DataGridView1.DataSource = DtSet.Tables(0)
This code can fill the datagridview, but sometimes the data is missing
in some of the rows. and sometimes I am able to get complete data.
thanks for any help.
I have the following code to fill the datagridview with excel sheet
data
MyConnection = New System.Data.OleDb.OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data source="
& filePath & ";Extended Properties='Excel
8.0;HDR=NO;'")
MyConnection.Open()
Dim schemaTable As DataTable = MyConnection.GetOleDbSchemaTable
(OleDbSchemaGuid.Tables, New object() {Nothing, Nothing, Nothing,
"TABLE"})
Dim dataRow As DataRow = schemaTable.Rows(0)
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * From [" +
DataRow("TABLE_NAME") + "]", MyConnection)
MyCommand.TableMappings.Add("Table", "TestTable")
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
DataGridView1.DataSource = DtSet.Tables(0)
This code can fill the datagridview, but sometimes the data is missing
in some of the rows. and sometimes I am able to get complete data.
thanks for any help.