473,386 Members | 1,748 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,386 software developers and data experts.

Question for the OO Gurus

flu
I recently had to modify an application that had originally been written for
SQL Server to work with MySQL. I found myself replacing all of the
declarations for the connection and command objects with their MySQL class
equivalents.

In hindsight it is clear my code should have been written originally for
some basic or super SQL class that SQLServer, MySQL, or ODBC, implements.
Ideally this could be determined even at run time.

This is a problem I'm sure others in this group have run into.

I am interested in how you have approached this problem.

TIA
Nov 16 '05 #1
8 1085
Well, you originally would have had:

SqlConnection conn = new SqlConnection();

Using a higher level class you would have had:

IDbConnection conn = new SqlConnection();

Which means that you would have had to change one spot instead of two --- or
click "Replace" in the "Find/Replace" dialog half as many times --- or click
"Replace All" exactly the same number of time.

The bottom line is that the Data Access Layer of your code & the Database
itself are intimately tied, and trying abstract it just shifts the problem
somewhere else.

If, for some reason, you absolutely need multiple database support, you
could do something like:

IDbConnection NewConnection()
{
string dbType = GetDbTypeForAppConfig();
switch (dbType)
{
case 'sqlserver':
return SqlConnection();
case 'mysql':
return MySqlConnection();
case 'oracle':
// etc
}
}
}

"flu" <fl***********@nospam.yahoo.com> wrote in message
news:7D*******************@newssvr13.news.prodigy. com...
I recently had to modify an application that had originally been written for SQL Server to work with MySQL. I found myself replacing all of the
declarations for the connection and command objects with their MySQL class
equivalents.

In hindsight it is clear my code should have been written originally for
some basic or super SQL class that SQLServer, MySQL, or ODBC, implements.
Ideally this could be determined even at run time.

This is a problem I'm sure others in this group have run into.

I am interested in how you have approached this problem.

TIA

Nov 16 '05 #2
Curiously, what is the reason for choosing mysql over sql?

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"James Curran" <ja*********@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Well, you originally would have had:

SqlConnection conn = new SqlConnection();

Using a higher level class you would have had:

IDbConnection conn = new SqlConnection();

Which means that you would have had to change one spot instead of two ---
or
click "Replace" in the "Find/Replace" dialog half as many times --- or
click
"Replace All" exactly the same number of time.

The bottom line is that the Data Access Layer of your code & the Database
itself are intimately tied, and trying abstract it just shifts the problem
somewhere else.

If, for some reason, you absolutely need multiple database support, you
could do something like:

IDbConnection NewConnection()
{
string dbType = GetDbTypeForAppConfig();
switch (dbType)
{
case 'sqlserver':
return SqlConnection();
case 'mysql':
return MySqlConnection();
case 'oracle':
// etc
}
}
}

"flu" <fl***********@nospam.yahoo.com> wrote in message
news:7D*******************@newssvr13.news.prodigy. com...
I recently had to modify an application that had originally been written

for
SQL Server to work with MySQL. I found myself replacing all of the
declarations for the connection and command objects with their MySQL
class
equivalents.

In hindsight it is clear my code should have been written originally for
some basic or super SQL class that SQLServer, MySQL, or ODBC, implements.
Ideally this could be determined even at run time.

This is a problem I'm sure others in this group have run into.

I am interested in how you have approached this problem.

TIA


Nov 16 '05 #3


If you want an abstraction layer for data access, encapsulate all your data
processing (not only Connection or Command creation) in a assembly
dynamicelly loaded by you application.

A really fun example of that sort of architecture is in DotNetNuke
(http://www.dotnetnuke.com). See
http://www.dotnetnuke.com/LinkClick....id=478&mid=857
for more.

Lionel.

"James Curran" <ja*********@mvps.org> a écrit dans le message de news:
%2******************@TK2MSFTNGP10.phx.gbl...
Well, you originally would have had:

SqlConnection conn = new SqlConnection();

Using a higher level class you would have had:

IDbConnection conn = new SqlConnection();

Which means that you would have had to change one spot instead of two ---
or
click "Replace" in the "Find/Replace" dialog half as many times --- or
click
"Replace All" exactly the same number of time.

The bottom line is that the Data Access Layer of your code & the Database
itself are intimately tied, and trying abstract it just shifts the problem
somewhere else.

If, for some reason, you absolutely need multiple database support, you
could do something like:

IDbConnection NewConnection()
{
string dbType = GetDbTypeForAppConfig();
switch (dbType)
{
case 'sqlserver':
return SqlConnection();
case 'mysql':
return MySqlConnection();
case 'oracle':
// etc
}
}
}

"flu" <fl***********@nospam.yahoo.com> wrote in message
news:7D*******************@newssvr13.news.prodigy. com...
I recently had to modify an application that had originally been written

for
SQL Server to work with MySQL. I found myself replacing all of the
declarations for the connection and command objects with their MySQL
class
equivalents.

In hindsight it is clear my code should have been written originally for
some basic or super SQL class that SQLServer, MySQL, or ODBC, implements.
Ideally this could be determined even at run time.

This is a problem I'm sure others in this group have run into.

I am interested in how you have approached this problem.

TIA


Nov 16 '05 #4
> Curiously, what is the reason for choosing mysql over sql?
runs on a unix box.

Nov 16 '05 #5
flu
Not my choice, but the client's. It is free and runs on unix as well as
windows.

flu
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:OK**************@tk2msftngp13.phx.gbl...
Curiously, what is the reason for choosing mysql over sql?

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"James Curran" <ja*********@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Well, you originally would have had:

SqlConnection conn = new SqlConnection();

Using a higher level class you would have had:

IDbConnection conn = new SqlConnection();

Which means that you would have had to change one spot instead of two ---
or
click "Replace" in the "Find/Replace" dialog half as many times --- or
click
"Replace All" exactly the same number of time.

The bottom line is that the Data Access Layer of your code & the Database
itself are intimately tied, and trying abstract it just shifts the
problem
somewhere else.

If, for some reason, you absolutely need multiple database support, you
could do something like:

IDbConnection NewConnection()
{
string dbType = GetDbTypeForAppConfig();
switch (dbType)
{
case 'sqlserver':
return SqlConnection();
case 'mysql':
return MySqlConnection();
case 'oracle':
// etc
}
}
}

"flu" <fl***********@nospam.yahoo.com> wrote in message
news:7D*******************@newssvr13.news.prodigy. com...
I recently had to modify an application that had originally been written

for
SQL Server to work with MySQL. I found myself replacing all of the
declarations for the connection and command objects with their MySQL
class
equivalents.

In hindsight it is clear my code should have been written originally for
some basic or super SQL class that SQLServer, MySQL, or ODBC,
implements.
Ideally this could be determined even at run time.

This is a problem I'm sure others in this group have run into.

I am interested in how you have approached this problem.

TIA



Nov 16 '05 #6
did you find a performance gain with mysql over sql?

we moved from informix to mysql for our data analysis solutions because
mysql showed at least a 65% performance gain for light to moderate
concurrent load. And it don't cost 20grand per processor. Some of the
advanced features are lacking, but all in all, i'd say it was a sound
investment.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"flu" <fl***********@nospam.yahoo.com> wrote in message
news:9U*******************@newssvr13.news.prodigy. com...
Not my choice, but the client's. It is free and runs on unix as well as
windows.

flu
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:OK**************@tk2msftngp13.phx.gbl...
Curiously, what is the reason for choosing mysql over sql?

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"James Curran" <ja*********@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Well, you originally would have had:

SqlConnection conn = new SqlConnection();

Using a higher level class you would have had:

IDbConnection conn = new SqlConnection();

Which means that you would have had to change one spot instead of
two --- or
click "Replace" in the "Find/Replace" dialog half as many times --- or
click
"Replace All" exactly the same number of time.

The bottom line is that the Data Access Layer of your code & the
Database
itself are intimately tied, and trying abstract it just shifts the
problem
somewhere else.

If, for some reason, you absolutely need multiple database support, you
could do something like:

IDbConnection NewConnection()
{
string dbType = GetDbTypeForAppConfig();
switch (dbType)
{
case 'sqlserver':
return SqlConnection();
case 'mysql':
return MySqlConnection();
case 'oracle':
// etc
}
}
}

"flu" <fl***********@nospam.yahoo.com> wrote in message
news:7D*******************@newssvr13.news.prodigy. com...
I recently had to modify an application that had originally been
written
for
SQL Server to work with MySQL. I found myself replacing all of the
declarations for the connection and command objects with their MySQL
class
equivalents.

In hindsight it is clear my code should have been written originally
for
some basic or super SQL class that SQLServer, MySQL, or ODBC,
implements.
Ideally this could be determined even at run time.

This is a problem I'm sure others in this group have run into.

I am interested in how you have approached this problem.

TIA



Nov 16 '05 #7
flu
I haven't had the opportunity to test it under load but it seems to perform
just fine under under light conditions. The tools are also adequate. The
..NET support works seamlessly.

I've got used to Enterprise Manager and was glad to see MySQL had a version.

I still prefer SQL Server but if price is a concern, you can't beat free.

flu

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:eS**************@TK2MSFTNGP09.phx.gbl...
did you find a performance gain with mysql over sql?

we moved from informix to mysql for our data analysis solutions because
mysql showed at least a 65% performance gain for light to moderate
concurrent load. And it don't cost 20grand per processor. Some of the
advanced features are lacking, but all in all, i'd say it was a sound
investment.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"flu" <fl***********@nospam.yahoo.com> wrote in message
news:9U*******************@newssvr13.news.prodigy. com...
Not my choice, but the client's. It is free and runs on unix as well as
windows.

flu
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:OK**************@tk2msftngp13.phx.gbl...
Curiously, what is the reason for choosing mysql over sql?

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"James Curran" <ja*********@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Well, you originally would have had:

SqlConnection conn = new SqlConnection();

Using a higher level class you would have had:

IDbConnection conn = new SqlConnection();

Which means that you would have had to change one spot instead of
two --- or
click "Replace" in the "Find/Replace" dialog half as many times --- or
click
"Replace All" exactly the same number of time.

The bottom line is that the Data Access Layer of your code & the
Database
itself are intimately tied, and trying abstract it just shifts the
problem
somewhere else.

If, for some reason, you absolutely need multiple database support, you
could do something like:

IDbConnection NewConnection()
{
string dbType = GetDbTypeForAppConfig();
switch (dbType)
{
case 'sqlserver':
return SqlConnection();
case 'mysql':
return MySqlConnection();
case 'oracle':
// etc
}
}
}

"flu" <fl***********@nospam.yahoo.com> wrote in message
news:7D*******************@newssvr13.news.prodigy. com...
> I recently had to modify an application that had originally been
> written
for
> SQL Server to work with MySQL. I found myself replacing all of the
> declarations for the connection and command objects with their MySQL
> class
> equivalents.
>
> In hindsight it is clear my code should have been written originally
> for
> some basic or super SQL class that SQLServer, MySQL, or ODBC,
> implements.
> Ideally this could be determined even at run time.
>
> This is a problem I'm sure others in this group have run into.
>
> I am interested in how you have approached this problem.
>
> TIA
>
>



Nov 16 '05 #8
was just curious, i've been using it for two years and i would definitely
recommend it for moderate concurrent loads

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"flu" <fl***********@nospam.yahoo.com> wrote in message
news:WO**************@newssvr24.news.prodigy.net.. .
I haven't had the opportunity to test it under load but it seems to perform
just fine under under light conditions. The tools are also adequate. The
.NET support works seamlessly.

I've got used to Enterprise Manager and was glad to see MySQL had a
version.

I still prefer SQL Server but if price is a concern, you can't beat free.

flu

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:eS**************@TK2MSFTNGP09.phx.gbl...
did you find a performance gain with mysql over sql?

we moved from informix to mysql for our data analysis solutions because
mysql showed at least a 65% performance gain for light to moderate
concurrent load. And it don't cost 20grand per processor. Some of the
advanced features are lacking, but all in all, i'd say it was a sound
investment.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"flu" <fl***********@nospam.yahoo.com> wrote in message
news:9U*******************@newssvr13.news.prodigy. com...
Not my choice, but the client's. It is free and runs on unix as well as
windows.

flu
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:OK**************@tk2msftngp13.phx.gbl...
Curiously, what is the reason for choosing mysql over sql?

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"James Curran" <ja*********@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
> Well, you originally would have had:
>
> SqlConnection conn = new SqlConnection();
>
> Using a higher level class you would have had:
>
> IDbConnection conn = new SqlConnection();
>
> Which means that you would have had to change one spot instead of
> two --- or
> click "Replace" in the "Find/Replace" dialog half as many times --- or
> click
> "Replace All" exactly the same number of time.
>
> The bottom line is that the Data Access Layer of your code & the
> Database
> itself are intimately tied, and trying abstract it just shifts the
> problem
> somewhere else.
>
> If, for some reason, you absolutely need multiple database support,
> you
> could do something like:
>
> IDbConnection NewConnection()
> {
> string dbType = GetDbTypeForAppConfig();
> switch (dbType)
> {
> case 'sqlserver':
> return SqlConnection();
> case 'mysql':
> return MySqlConnection();
> case 'oracle':
> // etc
> }
> }
> }
>
>
>
> "flu" <fl***********@nospam.yahoo.com> wrote in message
> news:7D*******************@newssvr13.news.prodigy. com...
>> I recently had to modify an application that had originally been
>> written
> for
>> SQL Server to work with MySQL. I found myself replacing all of the
>> declarations for the connection and command objects with their MySQL
>> class
>> equivalents.
>>
>> In hindsight it is clear my code should have been written originally
>> for
>> some basic or super SQL class that SQLServer, MySQL, or ODBC,
>> implements.
>> Ideally this could be determined even at run time.
>>
>> This is a problem I'm sure others in this group have run into.
>>
>> I am interested in how you have approached this problem.
>>
>> TIA
>>
>>
>
>



Nov 16 '05 #9

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

Similar topics

0
by: Gleep | last post by:
Hey PHP Gurus, I have some complex scripts that work fine. I have a system where sessions are validated on every page of my application to keep them secure. Everything runs fine when I test and...
4
by: WindAndWaves | last post by:
Hi Gurus I hope I am going to make sense with this question: I have an html page that I have turned into a php page with a bit of php code above the html (connect to database, massage data a...
4
by: Robert Ferrell | last post by:
I have a style question. I have a class with a method, m1, which needs a helper function, hf. I can put hf inside m1, or I can make it another method of the class. The only place hf should ever...
43
by: nospam | last post by:
I got three (3) files (1) Untitled.aspx (2) Untitled.aspx.1.cs (3) Untitled.aspx.2.cs These three files must be used together to make file #1, Untitled.aspx, page work via J.I.T. when the...
5
by: Dan | last post by:
Hi Gurus I got a very basic question to ask: When a .NET exe (MSIL) is first run, the JIT-compiler will converts the IL into native codes so that it can executes on the current machine. my...
21
by: John Welch | last post by:
Sometimes I post a question here and someone answers it quickly with an answer like "well, I don't know much about this, but maybe such and such." While I completely appreciate their effort, I...
2
by: Kalafiorczyk | last post by:
Good day ladies and gentlemen! I have a short proggie: ----------------------------------------------------------------------- #using <mscorlib.dll> using namespace...
22
by: mdh | last post by:
May I ask something that has often puzzled me in C. In K&R, for example (p106), in explaining their version of strcmp, pointers to the two strings are given as *s and *t. Does anyone know how...
5
by: Frank Millman | last post by:
Hi all This is not strictly a Python question, but as I am writing in Python, and as I know there are some XML gurus on this list, I hope it is appropriate here. XML-schemas are used to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.