views:

53

answers:

2

i generated my dataaccess dll using subsonic 3.0. i have a new proj referenced to this dll and am tryign to insert data to my mysql database. i get the following configuration error. however when i look at my App.config, i have a connectionstring that defines my database connection.

  <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>

    <add name="dbTorontoTrader"
       connectionString="server=localhost;database=dbtorontotrader;user id=root; password=password"
       providerName="MySql.Data.MySqlClient"/>
    <!-- For MySQL -->
  </connectionStrings>
  <system.data>
    <DbProviderFactories>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=5.1.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>
</configuration>

System.Configuration.ConfigurationErrorsException was unhandled
  Message="Failed to find or load the registered .Net Framework Data Provider."
  Source="System.Data"
  BareMessage="Failed to find or load the registered .Net Framework Data Provider."
  Line=0
  StackTrace:
       at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
       at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
       at SubSonic.DataProviders.DbDataProvider..ctor(String connectionString, String providerName)
       at SubSonic.DataProviders.ProviderFactory.LoadProvider(String connectionString, String providerName)
       at SubSonic.DataProviders.ProviderFactory.GetProvider(String connectionStringName)
       at TorontoTrader.Data.Ver2.dbTorontoTraderDB..ctor() in E:\TradingTools\CODE\TorontoTraderDataVer2\TorontoTraderDataVer2\Context.cs:line 37
       at TorontoTrader.Data.Ver2.scans_log.GetRepo(String connectionString, String providerName) in E:\TradingTools\CODE\TorontoTraderDataVer2\TorontoTraderDataVer2\ActiveRecord.cs:line 10338
       at TorontoTrader.Data.Ver2.scans_log.GetRepo() in E:\TradingTools\CODE\TorontoTraderDataVer2\TorontoTraderDataVer2\ActiveRecord.cs:line 10354
       at TorontoTrader.Data.Ver2.scans_log.SingleOrDefault(Expression`1 expression) in E:\TradingTools\CODE\TorontoTraderDataVer2\TorontoTraderDataVer2\ActiveRecord.cs:line 10359
       at ConsoleApplication1.Program.Main(String[] args) in E:\TradingTools\CODE\TorontoTraderDataVer2\ConsoleApplication1\Program.cs:line 13
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:
+1  A: 

your app config should look like this:

<configuration>
    <connectionStrings>
        <add name="dbTorontoTrader" connectionString="server=localhost;database=dbtorontotrader;user id=root; password=password" providerName="MySql.Data.MySqlClient"/>
     </connectionStrings>
</configuration>

Make note of the element that is missing

Dusty Roberts
thanks, i got that fixed and now have a new error as updated in the thread.
junkone
this seems like a missing assembly reference, however, i can be totally off here, as i have never used "MySql" in conjunction with Subsonic.you can also try and add <clear/> ..... right before: <add name="MySQL Data Provider", this will ensure the application only uses the db provider you specified,
Dusty Roberts
also note.. that i had a simular pronlem with SQL, and i had to add the following section in<DbProvidorFactories>:<remove invariant="System.Data.SQLite"/>
Dusty Roberts
where do you add this. is it to the app.config?
junkone
it works now. i had to change the version # on the app.config to match my mysql version.Version=6.2.2.0
junkone
+1  A: 

You need to add connectionstrings element.

Your app.config should look like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="dbTorontoTrader"
         connectionString="server=localhost;database=dbtorontotrader;user id=root; password=password"
         providerName="MySql.Data.MySqlClient"/>
  </connectionStrings>
</configuration>
Krunal
thanks, i got that fixed and now have a new error as updated in the thread.
junkone
@junkone - do u have any inner exception?
Krunal
@junkone - Do you have mysql connector installed on your machine?? http://www.mysql.com/downloads/connector/net/
Krunal
yes. i do have it installed. the inner exception is null. the rest of the exception is printed above.
junkone
@junkone - it is have the same version that what you have in your config?
Krunal
it works now. i had to change the version # on the app.config to match my mysql version.Version=6.2.2.0
junkone
@junkone - if it works for you, you should upvote and accept is as answer :)
Krunal