Home Keyword Not Supported: Provider
Reply: 1

Keyword Not Supported: Provider

gattoun Published in 2018-01-12 16:29:00Z

I realize there's similarly titled posts here, I've searched through all of them without finding my solution.

I'm uploading an Excel file to SQL Server in ASP.net MVC. Here's my connection string:

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplication12-20180107114522.mdf;Initial Catalog=aspnet-WebApplication12-20180107114522;Integrated Security=True;" providerName="System.Data.SqlClient" />

And here's my Excel file connection string:

string constr = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";", filepath);

The rest of my code uses SqlConnection / SqlCommand etc, rather than oleDB commands.

Amy Reply to 2018-01-12 16:48:04Z

You use SqlConnection to connect to SQL Server databases. That connection type doesn't understand "Provider" in the connection string.

You need to use the appropriate connection type for Jet databases, e.g. OleDbConnection.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.324466 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO