Click here to Skip to main content
15,912,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,

Can someone tell me Oledb connectionstring to read excel file in VB.Net. If possible pls help with the coding.
Posted
Updated 17-Dec-11 4:00am
v2
Comments
Nikil S 17-Dec-11 10:00am    
Edited Spelling.
jus coding 17-Dec-11 10:39am    
ts getting connected but the error wat i am getting is " External table is not in the expected for

jus look at my code




Dim oledbCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\new2.xlsx;Extended Properties=""Excel 8.0;HDR=Yes;Format=xls;IMEX=1;""")


Dim oledbcommand As New OleDbCommand("select A from [{0}]")
oledbcommand.Connection = oledbCon

con.Close()
con.Open()
Dim da As New OleDbDataAdapter(oledbcommand)

Dim ds As New DataSet
da.Fill(ds)
Dim sa As String = ""

Excel 2007 - see http://connectionstrings.com/excel-2007[^].
Otherwise see here[^].
 
Share this answer
 
Comments
Amir Mahfoozi 19-Dec-11 6:59am    
+5
Abhinav S 19-Dec-11 8:24am    
Thanks.
www.connectionstrings.com[^] You shouold bookmark it
 
Share this answer
 
Use Microsoft Jet provider to connect to an Excel workbook.

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\MyExcel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""


source: http://msdn.microsoft.com/en-us/library/ms254500.aspx[^]
 
Share this answer
 
Comments
jus coding 17-Dec-11 10:36am    
its getting connected but the error wat i am getting is " External table is not in the expected for

jus look at my code




Dim oledbCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\new2.xlsx;Extended Properties=""Excel 8.0;HDR=Yes;Format=xls;IMEX=1;""")


Dim oledbcommand As New OleDbCommand("select A from [{0}]")
oledbcommand.Connection = oledbCon

con.Close()
con.Open()
Dim da As New OleDbDataAdapter(oledbcommand)

Dim ds As New DataSet
da.Fill(ds)
Dim sa As String = ""

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900