Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I importing xlsx file using OleDbConnection.
But getting error as:
XML
System.Data.OleDb.OleDbException (0x80004005): Unspecified error at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbConnection.Open()


Code as Below:

C#
string strPath = @"D:\inetpub\wwwroot\cfxTemp\BuildingScorecardTemplate2014321115842072920729.xlsx"


if (!File.Exists(strPath))
{
    file.SaveAs(strPath, true);
}

string strConn =  "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strPath + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1;FMT=Delimited\"";

string worksheetName = "";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataTable dtNew;
dtNew = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);


conn.Close();


PLEASE HELP ME.
Please help me.
Posted
Updated 20-Mar-14 20:38pm
v2

1 solution

 
Share this answer
 

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