Hello everyone!
I have lots different queries with different criteria.
my goal is to create a table where I can select different columns from different queries I have got.
Which is the easiest way to make it?
I have been using google lots how people make it with databinding source and datacontext also connection string.
Could someone help me?
Thank you in advance.
SQL-queries program
Page 1 of 18 Replies - 500 Views - Last Post: 01 December 2015 - 09:21 AM
Replies To: SQL-queries program
#2
Re: SQL-queries program
Posted 30 November 2015 - 09:24 AM
I am not sure if I follow. You want a table full of queries, or just a table from your existing queries?
#3
Re: SQL-queries program
Posted 30 November 2015 - 09:25 AM
I am not sure what is smartest and most flexible?
is it to create one table for each query?
is it to create one table for each query?
#4
Re: SQL-queries program
Posted 30 November 2015 - 09:27 AM
Again - I am not sure what you are looking for. Typically my applications have specific, repeatable, queries. I have done some dynamic query building, but I am not sure if that is what you want.
#5
Re: SQL-queries program
Posted 30 November 2015 - 09:30 AM
I believe its dynamic query building I am up for.
#6
Re: SQL-queries program
Posted 30 November 2015 - 09:34 AM
A query string is just that - a string you can feed into a SQL command object. You can make them as difficult, or as simple, as needed as long as the table names are right, the column names are right, etc.
#7
Re: SQL-queries program
Posted 01 December 2015 - 12:31 AM
have someone a tutorials/examples of a solution etc?
I am still very new to c#.
I am still very new to c#.
#8
Re: SQL-queries program
Posted 01 December 2015 - 12:38 AM
There is no specific solutions to your issue as it is relative to more specific requirements. If you can join strings together you can add column strings to each other and a table name to make a dynamic query.
Example:
http://www.sqlteam.c...amic-sql-part-1
Example:
http://www.sqlteam.c...amic-sql-part-1
#9
Re: SQL-queries program
Posted 01 December 2015 - 09:21 AM
modi123_1 is asking you to clarify what you are attempting to do. So far we think you want dynamic querying, but that's not much to go on, and might not actually be what you want.
Are you asking how to include columns from many tables in a single result set? Rather than trying to do this on the client side, with the results of multiple queries, you should use the SQL JOIN operator to write a single query that brings in all the data you need at once.
Remember: your database is better than you (or me) at collating data. That's its entire job: interpreting queries and quickly generating results.
If, on the other hand, you want to allow the user to change what columns are retrieved from a particular table, you would have to create a "query builder". This could be as simple as a single textbox; allow the user to enter the SQL they want executed. Of course, this has the obvious downsides of your user having to know your schema, and allowing them to have unfettered access means they could run DROP <DBNAME> and really break your project. You could limit it to SELECT and give them checkboxes for the names of the columns if you wanted, but how do you handle ordering or grouping?
Point being, we really need you to explain exactly what it is you're trying to achieve with this, so we can give you better advice.
Are you asking how to include columns from many tables in a single result set? Rather than trying to do this on the client side, with the results of multiple queries, you should use the SQL JOIN operator to write a single query that brings in all the data you need at once.
Remember: your database is better than you (or me) at collating data. That's its entire job: interpreting queries and quickly generating results.
If, on the other hand, you want to allow the user to change what columns are retrieved from a particular table, you would have to create a "query builder". This could be as simple as a single textbox; allow the user to enter the SQL they want executed. Of course, this has the obvious downsides of your user having to know your schema, and allowing them to have unfettered access means they could run DROP <DBNAME> and really break your project. You could limit it to SELECT and give them checkboxes for the names of the columns if you wanted, but how do you handle ordering or grouping?
Point being, we really need you to explain exactly what it is you're trying to achieve with this, so we can give you better advice.
Page 1 of 1