SQLite works local but not on WinHost

Discussion in 'General troubleshooting' started by wcswanson, Oct 12, 2016.

Tags:
  1. Parser Error Message: Failed to generate code. Exception of type 'System.Data.Design.InternalException' was thrown.
    Code:
    Line 1:  <?xml version="1.0" encoding="utf-8"?>
    web.config file:
    connection string:
    Code:
    <connectionStrings>
            <remove name="LocalSqlServer" />
        <add name="cnSQLite" connectionString="Data Source=E:\web\wcswanso\deigsqlite\deig.sqlite3" providerName="Devart.Data.SQLite" />
    </connectionStrings>
    This works on local machine:
    Code:
    <connectionStrings>
            <remove name="LocalSqlServer" />
        <add name="cnSQLite" connectionString="Data Source=D:\aViS2012\MeetlingList\deig.sqlite3" providerName="Devart.Data.SQLite" />
    </connectionStrings>
    xsd file:
    Code:
     <Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="cnSQLite" ConnectionStringObject="" IsAppSettingsProperty="true"
              PropertyReference="AppConfig.System.Configuration.ConfigurationManager.0.ConnectionStrings.cnSQLite.ConnectionString"
              Modifier="Assembly" Name="cnSQLite (Web.config)"  Provider="Devart.Data.SQLite" />
    </Connections>
    Does anyone have any ideas for a solution?
     
  2. Elshadriel

    Elshadriel Winhost Staff

    I don't think it's a connection string problem. I would look at the exception:

    Is that assembly in the /bin folder and/or did you recompile your application with the updated connection string? This post on StackOverflow seems to think that you need to, and from my own experience, I know that the connection string from my own apps are often encoded in custom .dll's.
     
    Michael likes this.
  3. I updated the connection string and republished the site to a new folder. I still get the same error. I even commented out the <Connection /> section and still get the same error.
     
  4. Another work around:
    Created a new project with just a web page solution.
    Put a GridView on the page.
    After saving the solution open the NuGet Package Manager Consol:\
    PM> Install-Package System.Data.SQLite
    Created a folder App_Data and dropped the sqlite database into the folder.
    In the designer for the default.aspx page, create the SQLDataSource to the SQLite database. Then write the SQL for selection.
    Ran fine on local machine, but not on WinHost.

    There is no dataset in this page that was causing the above error so I did not get the parser error:
    Code:
    Parser Error Message: Failed to generate code. Exception of type 'System.Data.Design.InternalException' was thrown.
    
    Line 1:  <?xml version="1.0" encoding="utf-8"?>
    But I did get the .Net Framework Data Provider error:
    Code:
      [ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.]
       System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +959547
    Web. config file:
    After much trial and error and throwing dll's away, and a long bike ride, I found that in my connection string the provider listed was Devart not System.
    Error config:
    Code:
     <connectionStrings>
    <add name="cnDEIGsqlite" connectionString="Data Source=E:\web\wcswanso\deigsqlite\App_Data\deig.sqlite3"
          providerName="Devart.Data.SQLite" />
    Should be System:
    Code:
    <connectionStrings>
    <add name="cnDEIGsqlite" connectionString="Data Source=E:\web\wcswanso\deigsqlite\App_Data\deig.sqlite3"
          providerName="System.Data.SQLite" />   
      </connectionStrings>
    The DBProvidedFactories had been added from the readme file in the SQLite install.
    Code:
     <system.data>
    <DbProviderFactories>
     <remove invariant="System.Data.SQLite"/>
          <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
          type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
        </DbProviderFactories>
    The got the security error:
    Code:
    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
    Solution:
    Code:
     <system.web>
        <trust level="Full" />
     </system.web>
     
    Now the data will display from the SQLite file in a blink of an eye.
     

Share This Page