472,964 Members | 2,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,964 software developers and data experts.

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 4270
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.