Results 1 to 6 of 6

Thread: SQL Query Builder

  1. #1
    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.

  2. #2
    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.

  3. #3
    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.

  4. #4
    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.

  5. #5
    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?

  6. #6
    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,711,850.32121 seconds with 17 queries