473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 4312
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.