8 Replies - 519 Views - Last Post: 01 December 2015 - 09:21 AM Rate Topic: -----

#1 elmnas   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 20-July 09

SQL-queries program

Posted 30 November 2015 - 09:22 AM

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.

Is This A Good Question/Topic? 0
  • +

Replies To: SQL-queries program

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14176
  • View blog
  • Posts: 56,801
  • Joined: 12-June 08

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?
Was This Post Helpful? 0
  • +
  • -

#3 elmnas   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 20-July 09

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?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14176
  • View blog
  • Posts: 56,801
  • Joined: 12-June 08

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.
Was This Post Helpful? 0
  • +
  • -

#5 elmnas   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 20-July 09

Re: SQL-queries program

Posted 30 November 2015 - 09:30 AM

I believe its dynamic query building I am up for.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14176
  • View blog
  • Posts: 56,801
  • Joined: 12-June 08

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.
Was This Post Helpful? 0
  • +
  • -

#7 elmnas   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 20-July 09

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#.
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14176
  • View blog
  • Posts: 56,801
  • Joined: 12-June 08

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
Was This Post Helpful? 0
  • +
  • -

#9 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5104
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1