PC Review


Reply
Thread Tools Rate Thread

Component that helps generating sql code

 
 
Peter Laan
Guest
Posts: n/a
 
      8th Jul 2005
I've been spending a few hours writing a component that helps generate
simple sql queries. But if I can come up with the idea, it's probably stupid
or someone has already done it. So does anyone know of a component that does
something like this (or is it a stupid idea)? It's no supposed to be able to
handle all queries, just make life a bit simpler 95% of the time. The code
would look something like this (SqlSelect is the helper class):

SqlSelect sql = new SqlSelect("Customers");
sql.AddSelectColumn("fname");
sql.AddSelectColumn("lname");
sql.AddWhereParameter("fname", "john");
sql.AddWhereParameter("lname", "smith");
SqlCommand cmd = sql.GetCommand(conn);

I then had another idea. Why not make a program that extracts all user table
data from the database and creates source code with constants for all table
and column names. Is this another stupid idea? The generated source code
would be something like this:

namespace Appname.DBNames
{
public class Customers
{
public const string a_TableName = "Customers";
public const string c_fname = "fname";
public const string c_id = "id";
public const string c_lname = "lname";
}
}

One class for each table. The 'c_' is there in case a column name collides
with a reserved name. 'a_' is used to get the table name first in
intellisense.

You would get great help from intellisense by typing
DBNames.Customers.c_lname. But if you don't use a component like above to
help generate the sql code, the code might get ugly. The sql string would
quickly get very long.

Any comments?


Peter








 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      8th Jul 2005
Peter,

The last month the two in this thread had long (in general friendly)
discussions in some dotnet newsgroups. Maybe can you look in it what you
find that fits you. They both have their own product by the way, however
they have done it very much besides those products, however more in a
theoretical approach.

There is much more than only this thread.

http://groups-beta.google.com/group/...5d2d117d4e5ea8

I hope this helps,

Cor


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating XML from Code =?Utf-8?B?Q2hhcmxlcyBUYW0=?= Microsoft Access Form Coding 1 21st Aug 2005 09:51 PM
Component for generating Word/PDF docs? Klaus Jensen Microsoft VB .NET 1 17th Mar 2005 04:33 PM
Generating unmanaged code from managed code José Pérez Hernández Microsoft Dot NET 2 26th Apr 2004 07:43 PM
generating Native Code rashid Microsoft Dot NET 3 6th Nov 2003 03:51 AM
code generation woes (need code at END of Initialize Component) Bill Foust Microsoft Dot NET Framework Forms 0 11th Aug 2003 05:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:23 PM.