Question Locked

Excel Loading Problem

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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()

1 reply

This discussion is closed to new replies.