2

So I'm making a website on localhost and I have a database in C:\inetpub\wwwroot\Lollipops\App_Data\lollipopDB.mdb that I need to use on my website but when I try to do a SELECT statement on it, it keeps giving me the error: "System.ArgumentException: Keyword not supported: 'provider'."

This is in my web.config file -

< connectionStrings>
  < add name="lollipopDB" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\inetpub\wwwroot\Lollipops\App_Data\lollipopDB.mdb;" providerName="System.Data.OleDb" />
< /connectionStrings>

and the website calls the function PerformSQL which takes the name of a connection string and the sql string to run.

public void PerformSQL(string conn, string sqlStr)
{
    sqlConn.ConnectionString = ConfigurationManager.ConnectionStrings[conn].ConnectionString;
    sql.CommandText = sqlStr;
    sql.Connection = sqlConn; //specify connection string for the command instance
    sqlConn.Open();
    sql.ExecuteNonQuery();
    sqlConn.Close();
}
rene
  • 41,474
  • 78
  • 114
  • 152
Danni
  • 315
  • 5
  • 13

1 Answers1

2

What's the type of sqlConn?

It needs to be OleDbConnection. Similarly the command needs to be an OleDbCommand.

Murph
  • 9,985
  • 2
  • 26
  • 41
  • sorry, this was the first time I posted. I didn't see the little check marks. Thanks again! – Danni Dec 03 '09 at 10:22
  • Danni, not a problem - as a resource StackOverflow is a bit different to conventional forums but with the intent that it will be more useful. – Murph Dec 03 '09 at 10:29
  • @Danni, just curious, what was the type of sqlConn before you made the correction? – Force444 Jan 23 '16 at 21:36