Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 29-04-2009
Member
 
Join Date: Apr 2009
Posts: 37
SQL Query Builder

Hello,

I have PHP and I'm a fan of Drupal,
They did a super system for constructing queries like this:

Code:
 db_query ( "INSERT INTO Table1 (Name, AGE) VALUES (% s,% s,% d", $ name, $ name, $ age);
Is there a way to do something equivalent or menu in C # (or if it already exists in a native)?

There String.Format (), but the number of arguments is limited to a maximum of 3, there is always the possibility of going through a table, but it does not allow the addition of characters ( "% s", "% s ",% d).

At worst it is parameterized queries.
Reply With Quote
  #2  
Old 29-04-2009
Member
 
Join Date: Jan 2009
Posts: 143
Re: SQL Query Builder

And why not go through stored procedures? It is efficient, secure and more .. is made for this.
Reply With Quote
  #3  
Old 29-04-2009
Member
 
Join Date: Apr 2009
Posts: 37
Re: SQL Query Builder

what Stored procedures are you talking about, where should i get that and could I be able to see some example on it. I have never think about the stored procedure before.
Reply With Quote
  #4  
Old 29-04-2009
Member
 
Join Date: Mar 2008
Posts: 258
Re: SQL Query Builder

Stored procedure in SQL statements, like inserts, selects, and updates? Then you have already written most of a stored procedure. A stored procedure is an already written SQL statement that is saved in the database. If you find yourself using the same query over and over again, it would make sense to put it into a stored procedure. When you put this SQL statement in a stored procedure, you can then run the stored procedure from the database's command environment (I am a SQL Server kind of guy, and run stored procedures from the Query Analyzer), using the exec command.

An example is:

Code:
exec usp_displayallusers
The name of the stored procedure is "usp_displayallusers", and "exec" tells SQL Server to execute the code in the stored procedure.
Reply With Quote
  #5  
Old 29-04-2009
Member
 
Join Date: Apr 2009
Posts: 37
Re: SQL Query Builder

I thank you, I will put to parameterized queries.

Another question, just history ...

I'd like to create a query based on my Control Form,
for example, an INSERT, what is the best way to do?

Personally, I built a table for variable fields and another for VALUES.

I then built the query part by part.

I think that this is a very good way, would you also feels that?
Parameterized queries in this case? how to use them correctly?
Reply With Quote
  #6  
Old 29-04-2009
Member
 
Join Date: Mar 2008
Posts: 258
Re: SQL Query Builder

If you use a parameterized query, just to kind of stuff like field1 instead directly to the value of field1 and add parameters to the application as you build in the list of values.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "SQL Query Builder"
Thread Thread Starter Forum Replies Last Post
Query in SQL v/s Query in Oracle Satchel Software Development 4 29-12-2010 07:19 AM
Want to make query dependent on another query. MACE Software Development 4 01-02-2010 05:22 PM
MySQL query in a query Rail racer Software Development 3 21-07-2009 07:06 PM
Turn on MySQL query cache to speed up query performance DMA2Superman Software Development 3 07-07-2009 10:26 AM
C++ Builder Deskmukh Software Development 2 28-02-2009 01:00 PM


All times are GMT +5.5. The time now is 12:11 AM.