I don't know why this error, I tried everything. I want to connect my webForm to the Database .accdb
and when I use using(){} I got this error "Keyword not supported: 'provider"
Here is the code:
web.config
<connectionStrings>
<add name="ConnectionString"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Manuel_2\Documents\Login.accdb"
providerName="System.Data.OleDb" />
</connectionStrings>
WebForm1
private static string conDB =
ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(connDB)) //here is the error
{
// .....
}
}
Best Answer
Aleksey Mynkov has it right. But here is more detail since you are needing more clarification.
Your web.config is fine. The auto-generated Visual Studios connection string is using the right setup. Instead, on your webform1 file you need to do 2 things.
Add
using System.Data.OleDb.OleDbConnection;
to the top of your file, and remove theusing System.Data.SqlConnection;
Change your webform1 code to be: