Question Problem Importing data Excel (6.05708e+008)

bakesomecakes

New member
Joined
Oct 29, 2009
Messages
2
Location
London, England
Programming Experience
3-5
I am trying to import some data from excel.
i am using visual studio 2008 .net 3.5, on win xp sp3

the data that is being imported form excel is being edited somewhere in the import.

i am sure it is somthing todo with the olddb connection.

the data is coming out like this 6.05708e+008

the connection string goes somthing like this:
("provider=Microsoft.Jet.OLEDB.4.0; Data Source='C:\test.xls'; Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";")

i have tryed change the IMEX value to 0,1 and 2. nothing seems to work. each time the data is imported incorrectly.


Could anyone please help. i am been working on this non stop for 2days and i am getting now where quickly. and my client is going nuts, i depend on this job to pay the rent.


all comment welcome.
 
<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

</code>
 
Back
Top