0

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;

    }
Jay Zee
  • 263
  • 2
  • 7
  • 18
  • Which line throws the exception? It seems a bit suspect that this is an "unhandled exception" at the request level when the code you show handles exceptions... – David Apr 27 '14 at 13:47
  • This line throw exception newtable = Class1.GetLastRec(ConnectionString, "LastAlbum"); – Jay Zee Apr 27 '14 at 13:52
  • And which line inside of the `GetLastRec()` function throws the exception? My *guess* is: `OleDbConnection con = new OleDbConnection(conStr);` Can you confirm the runtime value of `conStr` while debugging? – David Apr 27 '14 at 13:56
  • problem is that i made dll for my class so right now i cant debug that what if i debug that newtable = Class1.GetLastRec(ConnectionString, "LastAlbum") – Jay Zee Apr 27 '14 at 14:01
  • You most certainly can debug into that method. The debugger has a "step into" button to enter a method, or you can put a breakpoint directly in the method's code. The fact that it's a separate project makes no difference. Ideally that separate project is still in the same overall solution and is referenced as a Project Reference. If it *needs* to be a separate DLL reference (and I suspect it really doesn't) then you need to include that code in your debugging context, see: http://stackoverflow.com/q/654696/328193 – David Apr 27 '14 at 14:08

0 Answers0