HERE IS A SIMPLIFIED VERSION OF THE CODE:
the real code imports it directly into SQL Server 2005, if that gives you anymore ideas
Code:Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 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='C:\test.xls'; Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";") '("provider=Microsoft.Jet.OLEDB.4.0; Data Source='C:\test.xls'; Extended Properties=""Excel 8.0;HDR=Yes;IMEX=0"";") '("provider=Microsoft.Jet.OLEDB.4.0; Data Source='C:\test.xls'; Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";") '("provider=Microsoft.Jet.OLEDB.4.0; Data Source='C:\test.xls'; Extended Properties=""Excel 8.0;HDR=Yes;IMEX=2"";") 'strConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";", strFile); MyCommand = New System.Data.OleDb.OleDbDataAdapter _ ("select * from [BIMOTO$]", MyConnection) MyCommand.TableMappings.Add("Table", "TestTable") DtSet = New System.Data.DataSet MyCommand.Fill(DtSet) DataGridView1.DataSource = DtSet.Tables(0) MyConnection.Close() End Sub End Class




Reply With Quote