This is the error i am getting when i run my code and try to fetch record
Keyword not supported: 'provider'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Keyword not supported: 'provider'.
My code was working fine i am using Ms Access 2007 . Then i need to add some more column in table after that i getting this error
This is my web.cfg
<connectionStrings>
<add name="ConnectionStringName" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source='|DataDirectory|\mfaridalam1.accdb'; Persist Security Info=False" />
</connectionStrings>
This is how i am getting my connection string using Configuration Manager
ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString.ToString();
This is how i am calling my function
newtable = Class1.GetLastRec(ConnectionString, "LastAlbum");
This is my function
public static string GetLastRec(string Connectionstring, string ColumnName)
{
// string conStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\AGENTJ.AGENTJ-PC\Documents\Visual Studio 2010\WebSites\mfaridalam\App_Data\mfaridalam1.accdb; Persist Security Info=False;";
string newAlbum = "";
string conStr = Connectionstring;
string Column = ColumnName;
OleDbConnection con = new OleDbConnection(conStr);
try
{
con.Open();
OleDbCommand cmd = new OleDbCommand("Select * from LastInfo", con);
OleDbDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
string input = dr[Column].ToString();
newAlbum = input;
if (newAlbum.Substring(0, 1) == "c")
{
//input.Trim();
input = input.Substring(3);
int cont = Convert.ToInt32(input) + 1;
newAlbum = "c00" + cont.ToString();
}
else
{
input = input.Substring(3);
int cont = Convert.ToInt32(input) + 1;
newAlbum = "v00" + cont.ToString();
}
}
con.Close();
// Response.Write(newtable);
}
catch (Exception ex)
{
return ex.ToString();
}
return newAlbum;
}