views:

45

answers:

1

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();
}

Can someone help me out and show me where I'm going wrong? Thank you!

A: 

What's the type of sqlConn?

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

Murph
Thank you, it worked!
Danni
In that case if you'd be so kind as to accept the answer?
Murph
sorry, this was the first time I posted. I didn't see the little check marks. Thanks again!
Danni
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

related questions