Reputation: 21
please help me to solve the problem.
i am getting the following problem
OleDbException was unhandled by user code
Invalid authorization specification
my code:
string connectionString = ConfigurationManager.ConnectionStrings["OLEDbConnection"].ToString();
OleDbConnection con = new OleDbConnection(connectionString);
SqlConnection(ConfigurationManager.ConnectionStrings["App_Data\\DavidsFlowershop.mdb"].ToString());
string a = "select ProductName, Price from Products_tbl where ID=" + Request.QueryString["ID"].ToString();
try
{
con.Open(); <-- i got my problem here
OleDbCommand cmd = new OleDbCommand(a, con);
OleDbDataReader reader = cmd.ExecuteReader();
reader.Read();
web.config:
<connectionStrings>
<add name="OLEDbConnection" connectionString="data source=App_Data\DavidsFloweShop.mdb; Provider=SQLOLEDB" providerName="System.Data.OleDb.OleDbConnection"/>
Upvotes: 2
Views: 16787
Reputation: 123819
The connection string in your web.config is
data source=App_Data\DavidsFloweShop.mdb; Provider=SQLOLEDB
but
Provider=SQLOLEDB
won't work. If your code will be running as 32-bit you'll need to use
Provider=Microsoft.Jet.OLEDB.4.0
If that doesn't work then your code may be running as 64-bit, in which case you'll need to use
Provider=Microsoft.ACE.OLEDB.12.0
and ensure that you have the 64-bit version of the Access Database Engine installed.
Upvotes: 1
Reputation: 7934
There is something wrong with your connection string.
Have a look at http://www.connectionstrings.com and see whether there is an example which applies to your specific case/DB technology.
Upvotes: 0