Re: Enterprise Library



Thanks Jeff.
Now I decided to use Enterprise library 4.0 to support all databases and for
xml support i will add extar coding to my data access layer. And as you have
suggetsed will use only IDataadapter ...etc.,,I have seen enterprise library
by itself for my requirement reads Database connections from confg file.. I
ahve requirement to override that and the connection string can be passed as
one of teh argumnet in code.. How can i achieve it from enterprise library
existing functions... I tried hard in google..NO luck.. can u help me out to
pass connection informations as part of the code itself and use the common DB
Interfaces(IDataReader...) e;lse it should take it from config..
Thanks in advance
Nithiya

"Jeff Winn" wrote:

Well, here's problem with using database specific adapters like
SqlDataAdapter and OracleDataAdapter in your application.. what happens when
the user changes the database? If you have any database specific adapters
being used inside your code, as soon as your application hits it and it's
the wrong type of database it's going to break and you probably won't get an
error while compiling. It'll just blow up when you run it.

You want to stick with base classes or interfaces only that are common
between the providers you'll be using. That's why I suggested the
IDataReader interface. If you plan on using data adapters you'll probably
want to stick with using the IDataAdapter interface.

Microsoft.Practices.EnterpriseLibrary.Data.Database is just an abstract type
that is used to handles the execution of commands against the connected
database. The type of provider defined in your app.config or web.config file
determines which type of database the factory will create.

<connectionStrings>
<add name="MyDbConnString" connectionString="....."
providerName="System.Data.SqlClient" />
</connectionStrings>

.I don't know any links off hand, but i'm sure google will give you plenty

"Nicol" <Nicol@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:EBAD8176-9FE1-42B8-A5B2-A074FBBE7984@xxxxxxxxxxxxxxxx
Thanks Jeff for your good expalnation with eg... This gave me an idea what
i
need..
One more question, so u r saying we should nt use any objects like
oracleadapter/sqldataadapter class to access the Database. we should
select
independednt classes to access Database. Kindly confirm me. and also will
it
eb possible to do all operations by using independent classes of DB as u
have
mentioned in below eg.. If possible plz send me some links to view the
example of such kind...
Thanks for your reply.

"Jeff Winn" wrote:

The Enterprise Library will allow you to use different databases as long
as
you stick with the common objects in your code. I have never used .NET to
query an XML file so that I'm a little unsure about.

As for using it with different databases here are some tips:

Don't use SqlDataReader or other similar objects in your data layer when
querying the databases. Also, I would suggest using stored procedures
when
querying data out of your database since SQL syntax may differ from
server
to server.

Here's a very simple example how to ensure querying data out of the
database
will keep the type of database transparent:

using Microsoft.Practices.EnterpriseLibrary.Data;
using System;
using System.Data;
using System.Data.Common;

Database db = DatabaseFactory.Create(); // You may need to specify the
name
of a connection string here if you're using multiples.
using (DbCommand cmd = db.GetStoredProcedure("MyProcedureName")) {
cmd.Parameters.Add("@myparam", DbType.Int32, 123);

using (IDataReader reader = db.ExecuteReader(cmd)) {
while (reader.Read()) {
// Do what you want with the data retrieved.
}
}
}

Also, if you're looking for a simpler data layer and do not need access
to
the rest of the functionality provided by the Enterprise Library you may
want to research LINQ to SQL or NHibernate though again, I'm not sure if
either of those can query XML files either.

"Nicol" <Nicol@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:36A88786-83B6-4B5B-9763-8C5700CEE828@xxxxxxxxxxxxxxxx
Hi,
My application needs to be configurable for sql server, oracle or
anyother
DB and also xml file. Will enterprise library suitabel for me? or do i
need
to create custom solution. PLz suggets me.
Thanks


.



Relevant Pages

  • Re: XML parser and writer
    ... them on a calendar. ... Therefore I will need to both easily parse and write new XML files. ... why not some database technology? ... an advanced user can edit the XML file directly at ...
    (comp.lang.java.programmer)
  • Re: Special Characters not resolving
    ... starting data at the origin in an ORacle database is 2000 characters. ... When the XML isdelivered to me on disk and I load an ... Obviously I need to find either a way to have the XML file provider strip ...
    (microsoft.public.dotnet.xml)
  • Re: dynamic class instantiation
    ... I think mixing XML, ... LDF to python parser is a LOT ... This xml file is then fed into the database at the ...
    (comp.lang.python)
  • Re: XML and the Datagrid
    ... I find it, when it is in memory, exactly as good as the database, because it ... I wished that the complexity from an XML file was in a real database system. ... It is in my opinion the best thing to describe and hold data until now and I ...
    (microsoft.public.dotnet.languages.vb)
  • Re: another delete prob.
    ... it is a drag & drop. ... didn't show the connection for the dataadapter in the code. ... XML file. ... > adapter actually gets connected to the database. ...
    (microsoft.public.dotnet.framework.adonet)