locked
Access error sqlhelper RRS feed

  • Question

  • User1325039169 posted

     Please can any one help me in this error

     

     'Microsoft.ApplicationBlocks.Data.SqlHelper.SqlHelper()' is inaccessible due to its protection level 

    code is

    public static void AddReview(Review r)

    {

    Microsoft.ApplicationBlocks.Data.
    SqlHelper objSqlHelper = new SqlHelper();

    SqlParameter[] objParams = new SqlParameter[5];

    objParams[0] = new SqlParameter("@productid", r.ProductId);

    objParams[1] = new SqlParameter("@username", r.UserName);

    objParams[2] = new SqlParameter("@email", r.Email);

    objParams[3] = new SqlParameter("@rating", r.Rating);

    objParams[4] = new SqlParameter("@comments", r.Comments);

    objSqlHelper.ExecuteNonQuery("AddReview", objParams);

    }

    Wednesday, March 26, 2008 2:46 PM

All replies

  • User1564875471 posted

    HI

    you don't need to create an instance of the SQLHelper, instead you can access its static(shared) function directliy by class name

     

    public static void AddReview(Review r) 
    {
    
    SqlParameter[] objParams = new SqlParameter[5];
    
    objParams[0] = new SqlParameter("@productid", r.ProductId); 
    objParams[1] = new SqlParameter("@username", r.UserName);
    
    objParams[2] = new SqlParameter("@email", r.Email); 
    objParams[3] = new SqlParameter("@rating", r.Rating);
    
    objParams[4] = new SqlParameter("@comments", r.Comments); 
    Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery("AddReview", objParams);
    
    }
    

     

    but maybe that is not the problem, it seems its a trust problem ,

    note that the SQLHelper Needs a medium trust application Level (which is the Default for asp.NET)

    Did you changed the Trust level from  your website web.config file ?

     

     

    Wednesday, March 26, 2008 7:54 PM