-
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.
-
Re: SQL Query Builder
And why not go through stored procedures? It is efficient, secure and more .. is made for this.:rofl_2:
-
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.
-
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.
-
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?
-
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.
Page generated in 1,750,920,485.58027 seconds with 10 queries