Dynamically Building SQL Statment

  • Thread starter Thread starter Me, Myself, and I
  • Start date Start date
M

Me, Myself, and I

First off, i apologize if my terminology is off...

I am currently in a project that is basically a front-end to a
database. In coding this, I am taking into account that it has the
*potential* to be front-ended on multiple databases as well as
rendered in multiple browser types.

That being said, is there a pre-constructed class out there that I
can call from within my code to systematically "build" my SQL
statement and have it take into account the possibility to front
multiple databases? I am not looking to use stored procedures or
anything like that...it will be a simple CRUD-style SQL statment.

Simply put, I want to instantiate a query object and call methods
like AddSelect(), AddFrom(), AddWhere, AddOrder() to build the
statment that would be submitted to the database.


Thank You
Adam
 
----- Original Message -----
From: "Me, Myself, and I" <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Thursday, February 24, 2005 2:07 AM
Subject: Dynamically Building SQL Statment

First off, i apologize if my terminology is off...

I am currently in a project that is basically a front-end to a
database. In coding this, I am taking into account that it has the
*potential* to be front-ended on multiple databases as well as
rendered in multiple browser types.

That being said, is there a pre-constructed class out there that I
can call from within my code to systematically "build" my SQL
statement and have it take into account the possibility to front
multiple databases? I am not looking to use stored procedures or
anything like that...it will be a simple CRUD-style SQL statment.

Simply put, I want to instantiate a query object and call methods
like AddSelect(), AddFrom(), AddWhere, AddOrder() to build the
statment that would be submitted to the database.


Thank You
Adam

Hi Adam,

How complex are your SQL strings likely to be?

While there is a lot to be said for a generic class that handles a lot of
different types of queries, you have to think about how this generic class
will cause other areas of your program to become more complex.

If you have a query that is often used but only ever changes in how it
searches in certain columns, (ie SELECT [name], [age] FROM [Employees] WHERE
[name] = mySearchTerm1 AND [city] = mySearchTerm2) , then it would be better
for future reference if you simply held the entire string in a class and
changed the parts that you needed to change no?

Sorry if I've missed your point!
Rich.
 
Back
Top