c# - Unable to Open an Excel file using System.Data.OleDb.OleDbConnection -


this question has answer here:

iam trying open xlsx file (so can create datatable ) iam using the below code.

system.data.oledb.oledbconnection oledbcon; system.data.oledb.oledbdataadapter oledbdataad; oledbcon = new system.data.oledb.oledbconnection("provider=microsoft.jet.oledb.4.0;data source='" + filepath + "';extended properties=excel 8.0;"); 

but when file path contains file extension xlsx , error "external table not in expected format."

above code works fine when file of extention xls.

do have change connection string ?

any ?thanks in advance.

changed connection string to

public static string connstr = "provider=microsoft.ace.oledb.12.0;data source="      + path + ";extended properties=excel 12.0;"; 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -