Question
December 5, 2007 at 02:07 AM
archana.renu

Excel Loading Problem

by archana.renu . Updated 18 years, 11 months ago

Hi All….
I am working on Windows Application(VB.NET)
I ahve a problem loading Excel…I have 14 columns in Excel,one of the column has the Amount column which has “NUMBERS” as well “TEXT” values.i am able to retrieve the numbers but i am not able to retrieve the text values from that column…I have even set the “IMEX=1” property in the connection string…

Here is the code can anyone tell me where i am going wrong…

Dim Con_Str As String = “provider=Microsoft.Jet.OLEDB.4.0;data source= C:\Documents and Settings\administrator\Desktop\INVOICE.xls;Extended Properties=””Excel 8.0;HDR=YES;IMEX=1″””

Dim con As New OleDbConnection(Con_Str)
If con.State = ConnectionState.Open Then
con.Close()
End If
con.Open()
Dim StrQry As String = “Select * from [1047$]”
Dim cmd As New OleDbCommand(StrQry, con)
Dim da As New OleDbDataAdapter(cmd)
Dim Ds As New DataSet
da.Fill(Ds, “Excel”)
dgrExcelContents.DataSource = Ds.Tables(“Excel”).DefaultView
dgrExcelContents.AlternatingRowsDefaultCellStyle.BackColor = Color.LightCyan
con.Close()

This discussion is locked

All Comments