Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 October 10th, 2007, 04:28 AM
Authorized User
 
Join Date: Oct 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Related to DataSet

Hi Guys,

I want to know if there is any way to fetch a specific ROW from a DataSet(the DataSet has only one table).I am coding in c#.

Thanks and Regards,
Jhansi
__________________
Thanks and Regards,
Jhansi
 
Old October 10th, 2007, 07:29 AM
Registered User
 
Join Date: Oct 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to techdotnet
Default

Hi Jhansi,

You can use this perticular code

string var_Name = DS.Tables["DATASET_NAME"].Rows[0]["COLUMN_NAME"].ToString()

I hope this will work out for you

 
Old October 10th, 2007, 09:37 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well how do you know which row you need? If it's the sixth row for example then:
Code:
DataRow row = dataset.Tables[<tableIndexOrName>].Rows[6];
--

Joe (Microsoft MVP - XML)
 
Old October 10th, 2007, 09:40 AM
Authorized User
 
Join Date: Oct 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank u for ur immediate response...

But I want to fetch an entire row basing on a unique id...

Thanks and Regards,
Jhansi
 
Old October 10th, 2007, 09:55 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You have a few options if you intend to locate the row outside of SQL.

//This will return an array of rows
RowArray myRowArray = dataset.Select("some_value = " + uniqueValue);

You could also use a dataview:
DataView view = new DataView(dataset.Tables[<table>]);
view.RowFilter = "some_value = " + uniqueValue;

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Beginning Visual C# 2008
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
 
Old October 12th, 2007, 01:05 AM
Authorized User
 
Join Date: Oct 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Ya...I used the RowFilter...I get only one row as the result...but then I am not able to move this Filtered Row into a DataRow....
Pls help..........


Thanks and Regards,
Jhansi
 
Old October 12th, 2007, 01:51 AM
Authorized User
 
Join Date: Oct 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I found the way out....

I could get the filtered row with

                view[0].row["ColumnName"]



Thanks and Regards,
Jhansi





Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill(dataset) or dataset.load() salemkoten SQL Server 2005 1 November 2nd, 2006 11:04 PM
Converting a untyped dataset to a typed dataset daphnean Visual Studio 2005 0 July 13th, 2006 01:16 AM
Dataset related performance ..... vije VB.NET 2002/2003 Basics 1 February 23rd, 2005 06:28 AM
Functions Related!! NitinJoshi General .NET 3 February 11th, 2005 10:59 AM
Re: SQL Server dataset to ACCESS dataset dazzer ADO.NET 0 March 22nd, 2004 05:28 AM





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