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 January 11th, 2006, 12:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using SQL together with DataSet?

Can it be true that it is not possible to use SQL queries together with a DataSet? I find it hard to believe.

If it is not possible, is there a way around it? E.g. transforming the data to another type and then perform SQL joins on the transformed data?

Thanks, Jacob.
__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).
 
Old January 11th, 2006, 01:01 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can populate a dataset from a SQL query. You could populate several related tables in a dataset. Then you can establish relationships between the tables that represent foreign key relationships in the database. Then you can use SQL style elements to define a table's filter and sort. Also, you can use the relationships between the tables to retrieve child rows. But I don't think it's possible to perform pure SQL style queries as a dataset as if it were a database.

-Peter
 
Old January 11th, 2006, 01:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Alright, thanks.

I have two sources for constructing the DataSet; i.e. a database and possibly altered data in a UI, and therefore I cannot use the SQL approach on the database directly (defining the SQL directly). I have to do join queries on the DataSet, and hoped for work-around, but I see that no shortcuts.

What about XPath? It must be possible to get an XML representation of the DataSet, and then do XPath queries. Can XPath define constructions such as join?

Jacob.
 
Old January 11th, 2006, 01:35 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The dataset has a GetXml() method which will return the internal XML representation of the whole dataset. You could suck that into an XmlDocument object and do any XPath queries against it.

I don't often work with complex DataSets but I suspect there must be a way of doing what you need.

-Peter
 
Old January 11th, 2006, 04:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Peter, I think I will try that approach. BR, Jacob.
 
Old August 12th, 2008, 02:25 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

WTF? Why bring this thread up from the ashes with such a lame line?
Mods BURNINATE! :D

Rob
http://cantgrokwontgrok.blogspot.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
dataset and sql query notification p2pMember ASP.NET 2.0 Professional 1 September 26th, 2007 07:22 PM
SQL Against DataSet? jim.stanley C# 2 October 10th, 2004 12:16 AM
Re: SQL Server dataset to ACCESS dataset dazzer ADO.NET 0 March 22nd, 2004 05:28 AM
update table (SQL & DataSet) melvik ADO.NET 1 July 24th, 2003 04:40 PM





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