ADO.NET Provider for Reckon Accounts Hosted

Build 24.0.9060

Creating DbConnections

You can use DbProviderFactory and DbConnection objects to connect to Reckon Accounts Hosted with generic code. This section describes how to connect from your project.

Adding Provider Information to the Configuration Context

To create a strongly typed DbProviderFactory, you must first register the CData ADO.NET Provider for Reckon Accounts Hosted in the configuration context (machine.config, app.config, or web.config). Note that the provider installer registers the provider in machine.config.

If you are not using the installer -- for example, if you are using the NuGet package instead -- you need to manually register the provider. You can do so by adding an entry to the System.Data section of the configuration context. You can modify the System.Data section in your machine.config or app.config (the System.Data in the app config is merged with machine.config at run time). Below is the syntax and format of the configuration entry:

<system.data>
  <DbProviderFactories>
    <add name="CData ADO.NET Provider for Reckon Accounts Hosted" invariant="System.Data.CData.ReckonAccountsHosted" description="CData ADO.NET Provider for Reckon Accounts Hosted" type="System.Data.CData.ReckonAccountsHosted.ReckonAccountsHostedProviderFactory, System.Data.CData.ReckonAccountsHosted, Version=24.0.0.40, Culture=neutral, PublicKeyToken=f57f3fbecba6b076" />
</DbProviderFactories>
</system.data> 
  

The following configuration file fragment defines a typical Reckon Accounts Hosted connection string in the context:

<configuration>  
  <connectionStrings>  
    <add name="Reckon Accounts Hosted"   
      providerName="System.Data.CData.ReckonAccountsHosted"   
      connectionString="SubscriptionKey=test;CountryVersion=2021.R2.AU;CompanyFile=Q:/CData Software.QBW;User=test;Password=test;InitiateOAuth=GETANDREFRESH;CallbackURL=http://localhost:33333;OAuthClientId=MyOAuthClientID;OAuthClientSecret=MyOAuthClientSecret;"  
    />  
  </connectionStrings>  
</configuration>    

Creating the DbProviderFactory

Call DbProviderFactories.GetFactory to create the DbProviderFactory:

    DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.CData.ReckonAccountsHosted");
  

DbProviderFactories looks up the invariant name in the configuration context to find the assembly and the ReckonAccountsHostedProviderFactory class.

Creating the DbProviderFactory and DbConnection

The following code shows how to create a strongly typed DbProviderFactory object and use it to instantiate a DbConnection object and connect to Reckon Accounts Hosted.

DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.CData.ReckonAccountsHosted");

using(DbConnection connection = factory.CreateConnection()) {
  connection.ConnectionString = "SubscriptionKey=test;CountryVersion=2021.R2.AU;CompanyFile=Q:/CData Software.QBW;User=test;Password=test;InitiateOAuth=GETANDREFRESH;CallbackURL=http://localhost:33333;OAuthClientId=MyOAuthClientID;OAuthClientSecret=MyOAuthClientSecret;";
  connection.Open();
}

You can also read the connection string from the application configuration file. Note that the ConnectionStringSettingsCollection class requires a reference to System.Configuration.dll.

The following code retrieves the first Reckon Accounts Hosted connection string defined in the application configuration file.

 
ConnectionStringSettingsCollection settings = ConfigurationManager.ConnectionStrings;

if (settings != null) {
  foreach (ConnectionStringSettings cs in settings) {
    if (cs.ProviderName == "System.Data.CData.ReckonAccountsHosted")
      connection = cs.ConnectionString;
    break;
  }
}

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060