im building an excel upload feature on my web. it will read excel data using OLEDB. the problem is the excel file that user inputted can be either in 'real' excel file or excel in html import extended properties so the connection string is different. right now i handle it with try catch. if the first conn string generate exception then it will open connection with the other connection string in catch.
the problem is my lead says i can't use that kinda method. so is there any way so i can do that without try catch ( anything related throwing an exception ), or to see whether the excel file is in excel 8.0 extended properties or html import extended properties.
try
{
...
try
{
connection.ConnectionString = GetConnectionString(pathCopy);
connection.Open();
}
catch
{
connection.ConnectionString = GetConnectionStringHTMLEncoded(pathCopy);
connection.Open();
}
...
catch (Exception ex)
{
...
}
Thanks