Solved

c# query a .NET dataset

Posted on 2003-12-01
5
6,026 Views
Last Modified: 2007-12-19
I have a .NET dataset in c# and would like to write SQL to query it and get back another dataset. Is this possible and how can I do it?
0
Comment
Question by:newstandard
  • 3
5 Comments
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9850286
You can do something like this in a DataTable. Would this help you?
0
 
LVL 6

Expert Comment

by:DaniPro
ID: 9850302
I'm not sure that I understand very well wath you need, but you can try to use the Select method:

DataRow[] foundRows = YourDataTable.Select("Date > '1/1/00'");

0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9850319
I meant the same, but it's only for DataTable, Dani. So newstandard shall say if data table is enough or not
0
 
LVL 1

Accepted Solution

by:
mvannata earned 250 total points
ID: 9850326
hey newstatndard,
Give this a try,
you can uses the clone method of the dataset and then the select method to create a subset of the data.

private void GetClone(DataSet myDataSet)
{
   // Get a clone of the original DataSet.
   DataSet cloneSet;
   cloneSet = myDataSet.Clone();
   DataTable dt = cloneSet.Tables[0];
   string sWhere  = "column > 'a Value'";
   string sSort = "column DESC";
   ds.Select(sWhere, sSort);
}

That will give you a second dataaset based upon the first and allow you to generate a subset.
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9850370
Since when has DataSet a Select method?!?!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now