473,465 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A way to extend the Enterprise Library to work with other DB providers

Hi all.

I'm trying to extend the Microsoft Enterprise Library Data Access
Application Block
(http://msdn.microsoft.com/library/en...asp?frame=true)
to work with a Borland Interbase database.

To do this, I copied and renamed the source files for working with a SQL
Server database (SqlCommandWrapper.cs/SqlDatabase.cs to
InterbaseCommandWrapper.cs/InterbaseDatabase.cs). I then changed all
the type names to their corresponding Borland types. I then
successfully recompiled the assembly.

Next I used the Enterprise Library Configuration tool to produce the
app.config and dataConfiguration.config files with the correct
parameters to connect to my Interbase database (both files at the end of
this message).

I now try and connect to my database from a test application. The
problem is, before it even tries to connect, it gives the error:

An unhandled exception of type
'System.Configuration.ConfigurationException' occurred in
microsoft.practices.enterpriselibrary.configuratio n.dll

Additional information: The type
'Microsoft.Practices.EnterpriseLibrary.Data.Interb aseDatabase,
Microsoft.Practices.EnterpriseLibrary.Data' could not be loaded for the
'Database'.

In other words, it seems to be saying that the type
Microsoft.Practices.EnterpriseLibrary.Data.Interba seDatabase is not
defined in the assembly Microsoft.Practices.EnterpriseLibrary.Data. To
test this, I opened the dll with ildasm.exe. This shows that the type
DOES indeed exist. I'm at a loss at how to go any further with this and
would very appreciative of anyone who could tell me what's wrong. The
InterbaseDatabase.cs file is also at the end of this message if anyone
is interested.

By the way, if anyone else already has already tried to extend the
Enterprise Library to work with Interbase, then please let me know.

Thanks,

Mike


App.config
----------

<configuration>
<configSections>
<section name="enterpriselibrary.configurationSettings"
type="Microsoft.Practices.EnterpriseLibrary.Config uration.ConfigurationManagerSectionHandler,
Microsoft.Practices.EnterpriseLibrary.Configuratio n, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null" />
</configSections>
<enterpriselibrary.configurationSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
applicationName="TestProject"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration">
<configurationSections>
<configurationSection xsi:type="ReadOnlyConfigurationSectionData"
name="dataConfiguration" encrypt="false">
<storageProvider xsi:type="XmlFileStorageProviderData" name="XML
File Storage Provider" path="dataConfiguration.config" />
<dataTransformer xsi:type="XmlSerializerTransformerData"
name="Xml Serializer Transformer">
<includeTypes />
</dataTransformer>
</configurationSection>
</configurationSections>
<keyAlgorithmStorageProvider xsi:nil="true" />
<includeTypes />
</enterpriselibrary.configurationSettings>
</configuration>

DataConfiguration.config
------------------------

<?xml version="1.0" encoding="utf-8"?>
<dataConfiguration>
<xmlSerializerSection
type="Microsoft.Practices.EnterpriseLibrary.Data.C onfiguration.DatabaseSettings,
Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null">
<enterpriseLibrary.databaseSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
defaultInstance="UWC"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">
<databaseTypes>
<databaseType name="Interbase"
type="Microsoft.Practices.EnterpriseLibrary.Data.I nterbaseDatabase,
Microsoft.Practices.EnterpriseLibrary.Data" />
</databaseTypes>
<instances>
<instance name="UWC" type="Interbase"
connectionString="Interbase Connection String" />
</instances>
<connectionStrings>
<connectionString name="Interbase Connection String">
<parameters>
<parameter name="Provider" value="interbase"
isSensitive="false" />
<parameter name="Assembly" value="Borland.Data.Interbase"
isSensitive="false" />
<parameter name="Culture" value="neutral"
isSensitive="false" />
<parameter name="Database"
value="dbserver:/opt/interbase/data/uwc.gdb" isSensitive="false" />
<parameter name="Password" value="cfwrip"
isSensitive="false" />
<parameter name="UserName" value="app" isSensitive="false" />
</parameters>
</connectionString>
</connectionStrings>
</enterpriseLibrary.databaseSettings>
</xmlSerializerSection>
</dataConfiguration>

InterbaseDatabase.cs
--------------------

//================================================== =============================
// Microsoft patterns & practices Enterprise Library
// Data Access Application Block
//================================================== =============================
// Copyright © Microsoft Corporation. All rights reserved.
// Adapted from ACA.NET with permission from Avanade Inc.
// ACA.NET copyright © Avanade Inc. All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//================================================== =============================

using System;
using System.Data;
using System.Data.Common;
using Borland.Data.Interbase;
using Borland.Data.Common;
using Borland.Data.Provider;

namespace Microsoft.Practices.EnterpriseLibrary.Data.Interba se
{
/// <summary>
/// <para>Represents an Interbase Database.</para>
/// </summary>
/// <remarks>
/// <para>
/// Internally uses the BDP Managed Provider from Borland to connect
to the database.
/// </para>
/// </remarks>
public class InterbaseDatabase : Database
{
/// <summary>
/// Default constructor
/// </summary>
public InterbaseDatabase() : base()
{
}

/// <summary>
/// <para>Gets the parameter token used to delimit parameters
for the Sql Database.</para>
/// </summary>
/// <value>
/// <para>The '' symbol.</para>
/// </value>
protected override char ParameterToken
{
get { return '@'; }
}

/// <summary>
/// <para>Get the connection for this database.</para>
/// <seealso cref="IDbConnection"/>
/// <seealso cref="BdpConnection"/>
/// </summary>
/// <returns>
/// <para>The <see cref="BdpConnection"/> for this database.</para>
/// </returns>
public override IDbConnection GetConnection()
{
return new BdpConnection(ConnectionString);
}

/// <summary>
/// <para>Create a <see cref="InterbaseCommandWrapper"/> for a
stored procedure.</para>
/// </summary>
/// <param name="storedProcedureName"><para>The name of the
stored procedure.</para></param>
/// <returns><para>The <see cref="InterbaseCommandWrapper"/>
for the stored procedure.</para></returns>
/// <exception cref="ArgumentNullException">
/// <para><paramref name="storedProcedureName"/> can not be
<see langword="null"/> (Nothing in Visual Basic).</para>
/// </exception>
public override DBCommandWrapper
GetStoredProcCommandWrapper(string storedProcedureName)
{
if (storedProcedureName == null)
{
throw new ArgumentNullException("storedProcedureName");
}
if (storedProcedureName.Length == 0)
{
throw new ArgumentException("SQL command string not
supplied", "storedProcedureName");
}
return new InterbaseCommandWrapper(storedProcedureName,
CommandType.StoredProcedure, ParameterToken);
}

/// <summary>
/// <para>Create an <see cref="InterbaseCommandWrapper"/> for a
stored procedure.</para>
/// </summary>
/// <param name="storedProcedureName"><para>The name of the
stored procedure.</para></param>
/// <param name="parameterValues"><para>The list of parameters
for the procedure.</para></param>
/// <returns><para>The <see cref="InterbaseCommandWrapper"/>
for the stored procedure.</para></returns>
/// <remarks>
/// <para>The parameters for the stored procedure will be
discovered and the values are assigned in positional order.</para>
/// </remarks>
/// <exception cref="ArgumentNullException">
/// <para><paramref name="storedProcedureName"/> can not be
<see langword="null"/> (Nothing in Visual Basic).</para>
/// <para>- or -</para>
/// <para><paramref name="parameterValues"/> can not be <see
langword="null"/> (Nothing in Visual Basic).</para>
/// </exception>
/// <exception cref="ArgumentException">
/// <para><paramref name="storedProcedureName"/> hast not been
initialized.</para>
/// </exception>
public override DBCommandWrapper
GetStoredProcCommandWrapper(string storedProcedureName, params object[]
parameterValues)
{
if (storedProcedureName == null)
{
throw new ArgumentNullException("storedProcedureName");
}
if (storedProcedureName.Length == 0)
{
throw new ArgumentException("SQL command string not
supplied", "storedProcedureName");
}
if (parameterValues == null)
{
throw new ArgumentNullException("parameterValues");
}
return new InterbaseCommandWrapper(storedProcedureName,
CommandType.StoredProcedure, ParameterToken, parameterValues);
}

/// <summary>
/// <para>Create an <see cref="InterbaseCommandWrapper"/> for a
SQL query.</para>
/// </summary>
/// <param name="query"><para>The text of the
query.</para></param>
/// <returns><para>The <see cref="InterbaseCommandWrapper"/>
for the SQL query.</para></returns>
/// <exception cref="ArgumentNullException">
/// <para><paramref name="query"/> can not be <see
langword="null"/> (Nothing in Visual Basic).</para>
/// </exception>
/// <exception cref="ArgumentException">
/// <para><paramref name="query"/> hast not been
initialized.</para>
/// </exception>
public override DBCommandWrapper
GetSqlStringCommandWrapper(string query)
{
if (query == null)
{
throw new ArgumentNullException("query");
}
if (query.Length == 0)
{
throw new ArgumentException("SQL command string not
supplied", "query");
}
return new InterbaseCommandWrapper(query, CommandType.Text,
ParameterToken);
}

/// <summary>
/// <para>Create a <see cref="BdpDataAdapter"/> with the given
update behavior and connection.</para>
/// </summary>
/// <param name="updateBehavior">
/// <para>One of the <see cref="UpdateBehavior"/> values.</para>
/// </param>
/// <param name="connection">
/// <para>The open connection to the database.</para>
/// </param>
/// <returns>An <see cref="BdpDataAdapter"/>.</returns>
/// <exception cref="ArgumentNullException">
/// <para><paramref name="connection"/> can not be <see
langword="null"/> (Nothing in Visual Basic).</para>
/// </exception>
protected override DbDataAdapter GetDataAdapter(UpdateBehavior
updateBehavior, IDbConnection connection)
{
string queryStringToBeFilledInLater = String.Empty;
BdpDataAdapter adapter = new
BdpDataAdapter(queryStringToBeFilledInLater, (BdpConnection)connection);

if (updateBehavior == UpdateBehavior.Continue)
{
adapter.RowUpdated += new
BdpRowUpdatedEventHandler(OnInterbaseRowUpdated);
}
return adapter;
}

/// <devdoc>
/// Listens for the RowUpdate event on a data adapter to
support UpdateBehavior.Continue
/// </devdoc>
private void OnInterbaseRowUpdated(object sender,
BdpRowUpdatedEventArgs rowThatCouldNotBeWritten)
{
// doesn't seem to be supported by the BDP
/*
if (rowThatCouldNotBeWritten.RecordsAffected == 0)
{
if (rowThatCouldNotBeWritten.Errors != null)
{
rowThatCouldNotBeWritten.Row.RowError =
SR.ErrorMessageUpdateDataSetRowFailure;
rowThatCouldNotBeWritten.Status =
UpdateStatus.SkipCurrentRow;
}
}*/
}
}
}
Jul 21 '05 #1
1 4321
Mike Chamberlain wrote:
Hi all.

I'm trying to extend the Microsoft Enterprise Library Data Access
Application Block
(http://msdn.microsoft.com/library/en...asp?frame=true)
to work with a Borland Interbase database.


No one have any thoughts on this?

Mike
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ViperDK \(Daniel K.\) | last post by:
Could someone give me a hint where to find *good* information, samples, tutorials, hints, whatever on design of multi/three-tiered applications, business layers etc (mainly winforms but web...
3
by: veera sekhar kota | last post by:
hi, im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked...
7
by: John | last post by:
Do you guys have any idea if web hosting companies usually give access to SQL Server databases through Enterprise Manager? I used to have have access to my DB through EE with my previous provider...
2
by: bjhogan | last post by:
Hi, I have built an c# asp.net application on my laptop, it uses the Enterprise Library blocks - Data Access Application Block, Configuration Application Block. I now want to deploy my...
1
by: Mike Chamberlain | last post by:
Hi all. I'm trying to extend the Microsoft Enterprise Library Data Access Application Block (http://msdn.microsoft.com/library/en-us/dnpag2/html/daab.asp?frame=true) to work with a Borland...
0
by: Roel | last post by:
Hi all, I'm using the new profile system which is introduced in ASP.NET 2.0. In the WEB.CONFIG the profile is configured like this: <profile enabled="true" defaultProvider="SqlProvider">...
7
by: galico | last post by:
Hi All, We are having a very strange problem with the above. We have designed an application in ASP.NET 2.0 that uses the enterprise library data application blocks amongst others. We seem to be...
7
by: Bruce One | last post by:
I am coupling an object for logging in our app... Ive seen Log4Next is indeed a good choice, besides being free... On the other hand, there seems to be a proven platform for log avaliable in...
0
by: zeenets | last post by:
I am using Enterprise library v3.1 for developing a windows application. its working well. but there is a security issue, when i deploy this application on client machine the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.