Click here to Skip to main content
15,922,533 members
Home / Discussions / C#
   

C#

 
GeneralRe: SerialPort acess using framework 2.0 Pin
Dave Kreskowiak15-Oct-05 6:34
mveDave Kreskowiak15-Oct-05 6:34 
QuestionGetting values for arraylist of arrays? Pin
parvinder sehrawat13-Oct-05 20:10
parvinder sehrawat13-Oct-05 20:10 
AnswerRe: Getting values for arraylist of arrays? Pin
Guffa13-Oct-05 20:29
Guffa13-Oct-05 20:29 
AnswerRe: Getting values for arraylist of arrays? Pin
Maqsood Ahmed14-Oct-05 1:18
Maqsood Ahmed14-Oct-05 1:18 
QuestionUrgent -How to convert Dataview to DataSet Pin
ksumputh13-Oct-05 19:46
ksumputh13-Oct-05 19:46 
AnswerRe: Dataview to DataSet Pin
turbochimp13-Oct-05 19:58
turbochimp13-Oct-05 19:58 
GeneralRe: Nope still not working for me :-( Pin
ksumputh13-Oct-05 20:13
ksumputh13-Oct-05 20:13 
GeneralRe: Dataview to DataSet Pin
turbochimp13-Oct-05 20:48
turbochimp13-Oct-05 20:48 
First off, you're initializing your DataView twice in the code above:

// Declaring and initializing to an empty dataview
DataView dv = new DataView(); 

// Chucking the DataView you just initialized and doing it again
dv = new DataView(ds.Tables["Query5"], "EVENT_DATE='14/10/2005'","",DataViewRowState.CurrentRows);


...and the answer to your question is no. The method I sent will return the DataSet containing the DataTable upon which the provided DataView is based.

DataSets do not implement filters or custom sorting - they are collections of DataTables, whereas a DataView is a customized view on a DataTable that allows sorted viewing and finer control over what DataRowStates the consumer can "see".

Is this a case where you are wanting to take the results as they appear in the DataView and feed them to this other component that only accepts DataSets? If so, then you could just create a table that matches the view (or original table) and copy the contents of the view's rows into the new table, then pass the table's DataSet into the component in question. I should mention at this point that doing something like that is bound to affect performance, but since you asked:

Example (crude but hopefully effective):

using System;
using System.Data;

class Class1
{
	/// <summary>
	/// The main entry point for the application.
	/// </summary>
	[STAThread]
	static void Main(string[] args)
	{
		
		DataTable t1 = new DataTable();
		t1.Columns.Add("Age", typeof(int));
		t1.Columns.Add("Name", typeof(string));
		t1.Columns.Add("SomeLetter", typeof(string));

                // Fills the first table with useless data
		for (int x=0; x<10; x++)
		{
			DataRow row = t1.NewRow();
			row[0] = 10-x;
			row[1] = "John " + x.ToString();
			row[2] = new string((char)(65 + x), x + 1);
			t1.Rows.Add(row);
		}

		// Surfaces a filtered, sorted view of table t1
		DataView view = new DataView(t1, "Age > 5", "Age DESC", DataViewRowState.CurrentRows);

		// Create a new table to receive copies.
		DataTable t2 = new DataTable();
		t2.Columns.Add("Age", typeof(int));
		t2.Columns.Add("Name", typeof(string));
		t2.Columns.Add("SomeLetter", typeof(string));

                // Copies the rows from the DataView to the new Table in 
                // sorted order.
		for(int p = 0, pc = view.Count; p<pc; p++)
		{
			DataRow newRow = t2.NewRow();

			DataRowView rowV = view[p];
			newRow.ItemArray = rowV.Row.ItemArray;
			t2.Rows.Add(newRow);
		}

		Console.ReadLine();
	}
}


The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’

GeneralRe: Dataview to DataSet Pin
ksumputh22-Oct-05 8:35
ksumputh22-Oct-05 8:35 
QuestionProblem with projects in project Pin
hg270513-Oct-05 19:14
hg270513-Oct-05 19:14 
AnswerRe: Problem with projects in project Pin
Guffa13-Oct-05 19:48
Guffa13-Oct-05 19:48 
GeneralRe: Problem with projects in project Pin
hg270513-Oct-05 20:10
hg270513-Oct-05 20:10 
QuestionControl for live video display on windows form Pin
varmag13-Oct-05 19:01
varmag13-Oct-05 19:01 
QuestionDrawing is Lost when Paint is called... Pin
maddy jiger13-Oct-05 17:21
maddy jiger13-Oct-05 17:21 
AnswerRe: Drawing is Lost when Paint is called... Pin
Guffa13-Oct-05 19:54
Guffa13-Oct-05 19:54 
QuestionDatabase Access Problem with C# Pin
TheMajorRager13-Oct-05 17:01
TheMajorRager13-Oct-05 17:01 
GeneralRe: Database Access Problem with C# Pin
Luis Alonso Ramos13-Oct-05 17:19
Luis Alonso Ramos13-Oct-05 17:19 
AnswerRe: Database Access Problem with C# Pin
Gulfraz Khan14-Oct-05 4:09
Gulfraz Khan14-Oct-05 4:09 
GeneralRe: Database Access Problem with C# Pin
TheMajorRager14-Oct-05 6:59
TheMajorRager14-Oct-05 6:59 
QuestionEndless MessageBox Mess..... Pin
Anonymous13-Oct-05 13:21
Anonymous13-Oct-05 13:21 
AnswerRe: Endless MessageBox Mess..... Pin
Guffa13-Oct-05 20:01
Guffa13-Oct-05 20:01 
Questiontopmost form to the application only? Pin
zhyluopro13-Oct-05 13:07
zhyluopro13-Oct-05 13:07 
AnswerRe: topmost form to the application only? Pin
Luis Alonso Ramos13-Oct-05 17:22
Luis Alonso Ramos13-Oct-05 17:22 
AnswerRe: topmost form to the application only? Pin
zhyluopro14-Oct-05 5:35
zhyluopro14-Oct-05 5:35 
QuestionCan you change the system volume? (as in sound) Pin
Anthony Mushrow13-Oct-05 12:49
professionalAnthony Mushrow13-Oct-05 12:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.