Hi,

How can I make my application work with SQL Server, Oracle, MySql,
etc?

_dino_

Re: Working with different kinds of databases by Darren

Darren
Tue Sep 27 14:58:47 CDT 2005

Use the provider independant interfaces. example, rather than using
System.Data.SqlConnection use System.Data.IDbConnection. SqlConnection
inherits from the IDbConnection interface. You could also use this to
create your own Connection class that could be provider independant.

Hope that helps,
Darren Kopp


Re: Working with different kinds of databases by AMDRIT

AMDRIT
Tue Sep 27 16:16:35 CDT 2005

Something that I have found when working with IDConnection is that SQLClient
behaves a little differently than OLEDB and ODBCDB. When using and
IDCommand object, you have to dispose it if each use, while SQLCommand is a
bit more forgiving and seems to clean itself up. It took me forever to
figure out was was going on, and I believe there is a post in here about it.

Bottom line is, when using generic objects, clean up as much as you can when
you can. It is good practice to do with all of your objects, yes. I just
was unaware of when to use Dispose.

HTH.


"Darren Kopp" <darrenkopp@gmail.com> wrote in message
news:1127851127.436191.123770@g43g2000cwa.googlegroups.com...
> Use the provider independant interfaces. example, rather than using
> System.Data.SqlConnection use System.Data.IDbConnection. SqlConnection
> inherits from the IDbConnection interface. You could also use this to
> create your own Connection class that could be provider independant.
>
> Hope that helps,
> Darren Kopp
>



Re: Working with different kinds of databases by Sahil

Sahil
Wed Oct 05 23:26:20 CDT 2005

Thats a hard goal to acheive.

You can try using something similar to the Dbproviderfactory model in .NET
2.0 - but even then you are stuck with 70% of database specific code - i.e.
PLSQL vs. TSQL.

You have to segregate everything into an as thin data layer as possible and
then write different datalayers for different .NEt data providers - thats
about the only way.

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
----------------------------------------------------------------------------



"Dino Buljubasic" <dino@noplacelikehome.com> wrote in message
news:vt6jj1prrfmc25b4unq38nt93pc8lh5ioo@4ax.com...
> Hi,
>
> How can I make my application work with SQL Server, Oracle, MySql,
> etc?
>
> _dino_



Re: Working with different kinds of databases by Sahil

Sahil
Wed Oct 05 23:27:20 CDT 2005

WHOAAA !! Here's a better rule "If you see Dispose, call it !!".

Not calling Dispose just bcause you are using SqlClient is not a recommended
practise.


--

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
----------------------------------------------------------------------------




"AMDRIT" <amdrit@hotmail.com> wrote in message
news:OVuz0i6wFHA.1168@TK2MSFTNGP15.phx.gbl...
> Something that I have found when working with IDConnection is that
> SQLClient behaves a little differently than OLEDB and ODBCDB. When using
> and IDCommand object, you have to dispose it if each use, while SQLCommand
> is a bit more forgiving and seems to clean itself up. It took me forever
> to figure out was was going on, and I believe there is a post in here
> about it.
>
> Bottom line is, when using generic objects, clean up as much as you can
> when you can. It is good practice to do with all of your objects, yes. I
> just was unaware of when to use Dispose.
>
> HTH.
>
>
> "Darren Kopp" <darrenkopp@gmail.com> wrote in message
> news:1127851127.436191.123770@g43g2000cwa.googlegroups.com...
>> Use the provider independant interfaces. example, rather than using
>> System.Data.SqlConnection use System.Data.IDbConnection. SqlConnection
>> inherits from the IDbConnection interface. You could also use this to
>> create your own Connection class that could be provider independant.
>>
>> Hope that helps,
>> Darren Kopp
>>
>
>



Re: Working with different kinds of databases by Frans

Frans
Thu Oct 06 03:56:26 CDT 2005

Sahil Malik [MVP] wrote:

> Thats a hard goal to acheive.
>
> You can try using something similar to the Dbproviderfactory model in
> .NET 2.0 - but even then you are stuck with 70% of database specific
> code - i.e. PLSQL vs. TSQL.
>
> You have to segregate everything into an as thin data layer as
> possible and then write different datalayers for different .NEt data
> providers - thats about the only way.

naa. You can also use a tool which provides a database generic layer
for you which is usable with a lot of different databases ;) (like an
O/R mapper)

FB

>
>
>
> "Dino Buljubasic" <dino@noplacelikehome.com> wrote in message
> news:vt6jj1prrfmc25b4unq38nt93pc8lh5ioo@4ax.com...
> > Hi,
> >
> > How can I make my application work with SQL Server, Oracle, MySql,
> > etc?
> >
> > dino



--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

Re: Working with different kinds of databases by Cor

Cor
Thu Oct 06 04:10:49 CDT 2005

Dino,

Although you will have less performance.

The one you showed support all OleDb, than only your connectionstring will
be different.

http://www.connectionstrings.com/

I hope this helps,

Cor



Re: Working with different kinds of databases by Sahil

Sahil
Thu Oct 06 06:18:46 CDT 2005

> naa. You can also use a tool which provides a database generic layer
> for you which is usable with a lot of different databases ;) (like an
> O/R mapper)

Does your O/R Mapper generate db specific queries without having to do any
special treatment for different databases? If so "WOW". It is quite a hard
goal to acheive though - just that you've done all the hardwork.

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
----------------------------------------------------------------------------



"Frans Bouma [C# MVP]" <perseus.usenetNOSPAM@xs4all.nl> wrote in message
news:xn0e863et4yhpm002@news.microsoft.com...
> Sahil Malik [MVP] wrote:
>
>> Thats a hard goal to acheive.
>>
>> You can try using something similar to the Dbproviderfactory model in
>> .NET 2.0 - but even then you are stuck with 70% of database specific
>> code - i.e. PLSQL vs. TSQL.
>>
>> You have to segregate everything into an as thin data layer as
>> possible and then write different datalayers for different .NEt data
>> providers - thats about the only way.
>
> naa. You can also use a tool which provides a database generic layer
> for you which is usable with a lot of different databases ;) (like an
> O/R mapper)
>
> FB
>
>>
>>
>>
>> "Dino Buljubasic" <dino@noplacelikehome.com> wrote in message
>> news:vt6jj1prrfmc25b4unq38nt93pc8lh5ioo@4ax.com...
>> > Hi,
>> >
>> > How can I make my application work with SQL Server, Oracle, MySql,
>> > etc?
>> >
>> > dino
>
>
>
> --
> ------------------------------------------------------------------------
> Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
> My .NET blog: http://weblogs.asp.net/fbouma
> Microsoft MVP (C#)
> ------------------------------------------------------------------------



Re: Working with different kinds of databases by Miha

Miha
Thu Oct 06 07:13:12 CDT 2005


"Sahil Malik [MVP]" <contactmethrumyblog@nospam.com> wrote in message
news:%23a2I4emyFHA.2072@TK2MSFTNGP14.phx.gbl...
>> naa. You can also use a tool which provides a database generic layer
>> for you which is usable with a lot of different databases ;) (like an
>> O/R mapper)
>
> Does your O/R Mapper generate db specific queries without having to do any
> special treatment for different databases?

Why not? Assuming it has enough information though.
--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/



Re: Working with different kinds of databases by Frans

Frans
Thu Oct 06 08:30:11 CDT 2005

Sahil Malik [MVP] wrote:

> > naa. You can also use a tool which provides a database generic layer
> > for you which is usable with a lot of different databases ;) (like
> > an O/R mapper)
>
> Does your O/R Mapper generate db specific queries without having to
> do any special treatment for different databases? If so "WOW". It is
> quite a hard goal to acheive though - just that you've done all the
> hardwork.

Yes. And in the upcoming 1.0.2005.1, you can even define type
converters, so Oracle NUMBER(1,0) (or any other type, just write a few
lines of code) for example can be mapped onto bool, transparently, so
you can have a single code base targeting a set of entities, which have
for example some boolean fields, and on Sqlserver they're mapped onto
bitfields, and on Oracle they're mapped onto NUMBER(1,0). (you can map
any.NET type onto any db type )

:P. This even works cross entity actions, so fetch an entity from
sqlserver, use it and save it into oracle or vice versa (or other db).

It's not that hard really: an O/R mapper knows the meta-data, and the
object state. So with a per-db SQL engine, you can generate any SQL
targeting any db, as long as you have an SQL engine for that database.
:)

Unless you want to use stored procedures of course ;) :P

FB

>
> - Sahil Malik [MVP]
> ADO.NET 2.0 book -
> http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
> ----------------------------------------------------------------------
> ------
>
>
>
> "Frans Bouma [C# MVP]" <perseus.usenetNOSPAM@xs4all.nl> wrote in
> message news:xn0e863et4yhpm002@news.microsoft.com...
> > Sahil Malik [MVP] wrote:
> >
> >> Thats a hard goal to acheive.
> > >
> >> You can try using something similar to the Dbproviderfactory model
> in >> .NET 2.0 - but even then you are stuck with 70% of database
> specific >> code - i.e. PLSQL vs. TSQL.
> > >
> >> You have to segregate everything into an as thin data layer as
> >> possible and then write different datalayers for different .NEt
> data >> providers - thats about the only way.
> >
> > naa. You can also use a tool which provides a database generic layer
> > for you which is usable with a lot of different databases ;) (like
> > an O/R mapper)
> >
> > FB
> >
> > >
> > >
> > >
> >> "Dino Buljubasic" <dino@noplacelikehome.com> wrote in message
> >> news:vt6jj1prrfmc25b4unq38nt93pc8lh5ioo@4ax.com...
> >> > Hi,
> >> >
> >> > How can I make my application work with SQL Server, Oracle,
> MySql, >> > etc?
> >> >
> >> > dino

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

Re: Working with different kinds of databases by Dino

Dino
Thu Oct 06 13:44:03 CDT 2005

Thank you Cor. I think this is quite helpful.

On Thu, 6 Oct 2005 11:10:49 +0200, "Cor Ligthert [MVP]"
<notmyfirstname@planet.nl> wrote:

>Dino,
>
>Although you will have less performance.
>
>The one you showed support all OleDb, than only your connectionstring will
>be different.
>
>http://www.connectionstrings.com/
>
>I hope this helps,
>
>Cor
>


Re: Working with different kinds of databases by Dino

Dino
Thu Oct 06 13:44:23 CDT 2005

Thanks Darren

On 27 Sep 2005 12:58:47 -0700, "Darren Kopp" <darrenkopp@gmail.com>
wrote:

>Use the provider independant interfaces. example, rather than using
>System.Data.SqlConnection use System.Data.IDbConnection. SqlConnection
>inherits from the IDbConnection interface. You could also use this to
>create your own Connection class that could be provider independant.
>
>Hope that helps,
>Darren Kopp


Re: Working with different kinds of databases by Dino

Dino
Thu Oct 06 13:45:15 CDT 2005

...
...
...

???

On Thu, 06 Oct 2005 06:30:11 -0700, "Frans Bouma [C# MVP]"
<perseus.usenetNOSPAM@xs4all.nl> wrote:

>Sahil Malik [MVP] wrote:
>
>> > naa. You can also use a tool which provides a database generic layer
>> > for you which is usable with a lot of different databases ;) (like
>> > an O/R mapper)
>>
>> Does your O/R Mapper generate db specific queries without having to
>> do any special treatment for different databases? If so "WOW". It is
>> quite a hard goal to acheive though - just that you've done all the
>> hardwork.
>
> Yes. And in the upcoming 1.0.2005.1, you can even define type
>converters, so Oracle NUMBER(1,0) (or any other type, just write a few
>lines of code) for example can be mapped onto bool, transparently, so
>you can have a single code base targeting a set of entities, which have
>for example some boolean fields, and on Sqlserver they're mapped onto
>bitfields, and on Oracle they're mapped onto NUMBER(1,0). (you can map
>any.NET type onto any db type )
>
> :P. This even works cross entity actions, so fetch an entity from
>sqlserver, use it and save it into oracle or vice versa (or other db).
>
> It's not that hard really: an O/R mapper knows the meta-data, and the
>object state. So with a per-db SQL engine, you can generate any SQL
>targeting any db, as long as you have an SQL engine for that database.
>:)
>
> Unless you want to use stored procedures of course ;) :P
>
> FB
>
>>
>> - Sahil Malik [MVP]
>> ADO.NET 2.0 book -
>> http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
>> ----------------------------------------------------------------------
>> ------
>>
>>
>>
>> "Frans Bouma [C# MVP]" <perseus.usenetNOSPAM@xs4all.nl> wrote in
>> message news:xn0e863et4yhpm002@news.microsoft.com...
>> > Sahil Malik [MVP] wrote:
>> >
>> >> Thats a hard goal to acheive.
>> > >
>> >> You can try using something similar to the Dbproviderfactory model
>> in >> .NET 2.0 - but even then you are stuck with 70% of database
>> specific >> code - i.e. PLSQL vs. TSQL.
>> > >
>> >> You have to segregate everything into an as thin data layer as
>> >> possible and then write different datalayers for different .NEt
>> data >> providers - thats about the only way.
>> >
>> > naa. You can also use a tool which provides a database generic layer
>> > for you which is usable with a lot of different databases ;) (like
>> > an O/R mapper)
>> >
>> > FB
>> >
>> > >
>> > >
>> > >
>> >> "Dino Buljubasic" <dino@noplacelikehome.com> wrote in message
>> >> news:vt6jj1prrfmc25b4unq38nt93pc8lh5ioo@4ax.com...
>> >> > Hi,
>> >> >
>> >> > How can I make my application work with SQL Server, Oracle,
>> MySql, >> > etc?
>> >> >
>> >> > dino


Re: Working with different kinds of databases by Darren

Darren
Sun Oct 09 15:14:17 CDT 2005

No problem. Best of luck with your app and all future apps.

-Daren Kopp