Configuring the web.config/winApp.config file

In the following example you will configure the web.config/winApp.exe.config file to connect to an Access database using the OleDb database factory and using a XML file to store the SQL statements. The DemoDb.mdb file used for this example is located at [Program Files]/SqlNetFramework/SqlNetFramework 1.0/Demos/SqlNetFrameworkEvaluationCS/App_Data/DemoDb.mdb. Copy the DemoDb.mdb file to your project root path C:\DemoProject\DemoDb.mdb.

Configuring the web.config file for an ASP.NET web application

For .NET 2.0

Copy the code below to your web.config file.

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

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

  <configSections>

    <section name="connections" type="SqlNetFramework.Configuration.ConnectionSectionHandler, SqlNetFramework.Core, Version=1.0.50727.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9" requirePermission="false"/>

    <section name="dbFactories" type="SqlNetFramework.Configuration.DbFactorySectionHandler, SqlNetFramework.Core, Version=1.0.50727.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9" requirePermission="false"/>

    <section name="sqlDataStores" type="SqlNetFramework.Configuration.SqlDataStoreSectionHandler, SqlNetFramework.Core, Version=1.0.50727.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9" requirePermission="false"/>

    <section name="sqlDataStoreManagers" type="SqlNetFramework.Configuration.SqlDataStoreManagerSectionHandler, SqlNetFramework.Core, Version=1.0.50727.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9" requirePermission="false"/>

  </configSections

 

  <connections>

    <connection

        id="DemoDb"

        connectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE='C:\DemoProject\DemoDb.mdb';"

        dbFactoryId="OleDbFactory"

        sqlDataStoreId="DemoDbXmlSqlDataStore"/>

  </connections>                       

 

  <sqlDataStores>

    <sqlDataStore id="DemoDbXmlSqlDataStore" sqlDataStoreManagerId="XmlSqlDataStoreManager" connectionSettings="File=DemoDb.xml|ResourceLocation=File|ConfigurationMode=Debug" sqlDataCacheMode="None"/>

  </sqlDataStores>

 

</configuration>

For .NET 1.0

Copy the code below to your web.config file.

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

<configuration>

  <configSections>

    <section name="connections" type="SqlNetFramework.Configuration.ConnectionSectionHandler, SqlNetFramework.Core, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="dbFactories" type="SqlNetFramework.Configuration.DbFactorySectionHandler, SqlNetFramework.Core, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="sqlDataStores" type="SqlNetFramework.Configuration.SqlDataStoreSectionHandler, SqlNetFramework.Core, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="sqlDataStoreManagers" type="SqlNetFramework.Configuration.SqlDataStoreManagerSectionHandler, SqlNetFramework.Core, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

  </configSections>

 

  <connections>

    <connection

        id="DemoDb"

        connectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE='C:\DemoProject\DemoDb.mdb';"

        dbFactoryId="OleDbFactory"

        sqlDataStoreId="DemoDbXmlSqlDataStore"/>

  </connections>

 

  <sqlDataStores>

    <sqlDataStore id="DemoDbXmlSqlDataStore" sqlDataStoreManagerId="XmlSqlDataStoreManager" connectionSettings="File=DemoDb.xml|ResourceLocation=File|ConfigurationMode=Debug" sqlDataCacheMode="None"/>

  </sqlDataStores>

 

</configuration>

For .NET 1.1

Copy the code below to your web.config file.

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

<configuration>

  <configSections>

    <section name="connections" type="SqlNetFramework.Configuration.ConnectionSectionHandler, SqlNetFramework.Core, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="dbFactories" type="SqlNetFramework.Configuration.DbFactorySectionHandler, SqlNetFramework.Core, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="sqlDataStores" type="SqlNetFramework.Configuration.SqlDataStoreSectionHandler, SqlNetFramework.Core, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="sqlDataStoreManagers" type="SqlNetFramework.Configuration.SqlDataStoreManagerSectionHandler, SqlNetFramework.Core, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

  </configSections>

 

  <connections>

    <connection

        id="DemoDb"

        connectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE='C:\DemoProject\DemoDb.mdb';"

        dbFactoryId="OleDbFactory"

        sqlDataStoreId="DemoDbXmlSqlDataStore"/>

  </connections>

 

  <sqlDataStores>

    <sqlDataStore id="DemoDbXmlSqlDataStore" sqlDataStoreManagerId="XmlSqlDataStoreManager" connectionSettings="File=DemoDb.xml|ResourceLocation=File|ConfigurationMode=Debug" sqlDataCacheMode="None"/>

  </sqlDataStores>

 

</configuration>


Configuring the App.config file for a Windows Forms application

For .NET 2.0

Copy the code below to your App.config file.

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

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

  <configSections>

    <section name="connections" type="SqlNetFramework.Configuration.ConnectionSectionHandler, SqlNetFramework.Core, Version=1.0.50727.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9" requirePermission="false"/>

    <section name="dbFactories" type="SqlNetFramework.Configuration.DbFactorySectionHandler, SqlNetFramework.Core, Version=1.0.50727.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9" requirePermission="false"/>

    <section name="sqlDataStores" type="SqlNetFramework.Configuration.SqlDataStoreSectionHandler, SqlNetFramework.Core, Version=1.0.50727.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9" requirePermission="false"/>

    <section name="sqlDataStoreManagers" type="SqlNetFramework.Configuration.SqlDataStoreManagerSectionHandler, SqlNetFramework.Core, Version=1.0.50727.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9" requirePermission="false"/>

  </configSections>

 

  <connections>

    <connection

        id="DemoDb"

        connectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE='C:\DemoProject\DemoDb.mdb';"

        dbFactoryId="OleDbFactory"

        sqlDataStoreId="DemoDbXmlSqlDataStore"/>

  </connections>

 

  <sqlDataStores>

    <sqlDataStore id="DemoDbXmlSqlDataStore" sqlDataStoreManagerId="XmlSqlDataStoreManager" connectionSettings="File=C:\DemoProject\DemoDb.xml|ResourceLocation=File|ConfigurationMode=Debug" sqlDataCacheMode="None"/>

  </sqlDataStores>

 

</configuration>

For .NET 1.0

Copy the code below to your App.config file.

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

<configuration>

  <configSections>

    <section name="connections" type="SqlNetFramework.Configuration.ConnectionSectionHandler, SqlNetFramework.Core, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="dbFactories" type="SqlNetFramework.Configuration.DbFactorySectionHandler, SqlNetFramework.Core, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="sqlDataStores" type="SqlNetFramework.Configuration.SqlDataStoreSectionHandler, SqlNetFramework.Core, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="sqlDataStoreManagers" type="SqlNetFramework.Configuration.SqlDataStoreManagerSectionHandler, SqlNetFramework.Core, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

  </configSections>

 

  <connections>

    <connection

        id="DemoDb"

        connectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE='C:\DemoProject\DemoDb.mdb';"

        dbFactoryId="OleDbFactory"

        sqlDataStoreId="DemoDbXmlSqlDataStore"/>

  </connections>

 

  <sqlDataStores>

    <sqlDataStore id="DemoDbXmlSqlDataStore" sqlDataStoreManagerId="XmlSqlDataStoreManager" connectionSettings="File=C:\DemoProject\DemoDb.xml|ResourceLocation=File|ConfigurationMode=Debug" sqlDataCacheMode="None"/>

  </sqlDataStores>

 

</configuration>

For .NET 1.1

Copy the code below to your App.config file.

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

<configuration>

  <configSections>

    <section name="connections" type="SqlNetFramework.Configuration.ConnectionSectionHandler, SqlNetFramework.Core, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="dbFactories" type="SqlNetFramework.Configuration.DbFactorySectionHandler, SqlNetFramework.Core, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="sqlDataStores" type="SqlNetFramework.Configuration.SqlDataStoreSectionHandler, SqlNetFramework.Core, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

    <section name="sqlDataStoreManagers" type="SqlNetFramework.Configuration.SqlDataStoreManagerSectionHandler, SqlNetFramework.Core, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=70ec6c5ab94e56d9"/>

  </configSections>

 

  <connections>

    <connection

        id="DemoDb"

        connectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE='C:\DemoProject\DemoDb.mdb';"

        dbFactoryId="OleDbFactory"

        sqlDataStoreId="DemoDbXmlSqlDataStore"/>

  </connections>

 

  <sqlDataStores>

    <sqlDataStore id="DemoDbXmlSqlDataStore" sqlDataStoreManagerId="XmlSqlDataStoreManager" connectionSettings="File=C:\DemoProject\DemoDb.xml|ResourceLocation=File|ConfigurationMode=Debug" sqlDataCacheMode="None"/>

  </sqlDataStores>

 

</configuration>


Next: Create a SQL query