Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2006, 02:08 AM
Authorized User
 
Join Date: Jun 2006
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dataset Problem

HI Every1

I have created a DataSet object and loaded few tables into it (they come from different data sources). As there are relations between them, I also created appropriate Relations objects.
Now I would like to extract some data based on certain criteria. In other words, is it possible to run a SELECT statement against a DataSet object? (Or any other way how to extract desired data from this object?)

Thanx
monika

 
Old September 26th, 2006, 10:04 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes Monika

That is possible, but in case of DataView. But no need to worry, you can easily convert the DataSet to DataView and then use the RowFilter property of DataView, code example is below:

private void BindGrid()
        {
            SqlConnection sConn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
            string sQuery = "select * from TestTable";
            SqlDataAdapter da = new SqlDataAdapter(sQuery,sConn);
            DataSet ds = new DataSet();
            da.Fill(ds);

//HERE WE CONVERT DATASET TO DATAVIEW
            ds.Tables[0].DefaultView.RowFilter = "ProjectID = '1'";

//AND BIND THE GRID WITH TABLE[0]'S VIEW
            dg.DataSource = ds.Tables[0].DefaultView;
            dg.DataBind();
        }

Regards
Mike





Similar Threads
Thread Thread Starter Forum Replies Last Post
DataSet problem HelpWanted ASP.NET 1.0 and 1.1 Basics 3 November 15th, 2006 02:28 AM
DataSet Example Problem sfx BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 0 February 14th, 2006 01:16 AM
problem in updating in dataset vohra_vikas2004 ADO.NET 1 June 28th, 2005 05:26 AM
Problem with Dataset Update Aaron Edwards ADO.NET 1 April 29th, 2005 04:26 AM
DataSet.WriteXML Problem jim.stanley ADO.NET 0 September 21st, 2004 12:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.