Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have got a dataTable from database through query. Now I need to write a function to form another query using this dataTable. Every row of dataTable has all the information and condition about how my new query will be formed. How can I make a query string using this information and condition of datatable.

SampleDataTable:


ReportID DatasrceOrder DataSourceID GlobalClassID DataName AggregationValue
Test_Report 2 Balance_Agreement Test_Report_Class CustomerID
Test_Report 1 Balance_Agreement Test_Report_Class Agreement ID
Test_Report 1 Balance_Query Test_Report_Class LastUpdate
Test_Report 1 Balance_Query Test_Report_Class Balance sum

Example of Query:

Select Balance_Agreement.CustomerID,
Balance_Agreement Agreement ID,
Balance_Agreement.LastUpdate,
sum(Balance_Query.Balance)

FROM Balance_Agreement,Balance_Agreement
Posted
Updated 12-Feb-14 22:48pm
v5
Comments
Prasad Avunoori 13-Feb-14 0:46am    
Sachi, It's not clear.

Can you please post sample row from your datatable?
Thomas ktg 13-Feb-14 1:11am    
Do you mean to use like this? Please refer here.
http://msdn.microsoft.com/en-us/library/det4aw50%28v=vs.100%29.aspx.
soma naveen 13-Feb-14 1:15am    
datatable dt=new datatable();

DataRow[] foundRows = dt.Select("column_name='columndata'");
Dinesh.V.Kumar 13-Feb-14 1:53am    
Need more info Sachi!!Can you post what you have done so far and also the code if possible

Regards
sachi Dash 13-Feb-14 1:59am    
you know query has different part like
Select:
FROM:
WHERE:
GroupBy:

Every row tell me what is my select option, what table is used in from condition, Is there any where condition or not, is there any groupby condition or not.

1 solution

u can use DataTable.Select for selecting any data based on condition.(example)
or u can use linq.(example)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900