PC Review


Reply
Thread Tools Rate Thread

Converting a Dataview into a Dataset

 
 
=?Utf-8?B?UmFtYWtyaXNobmFuIE5hZ2FyYWphbg==?=
Guest
Posts: n/a
 
      8th Aug 2005
Hi can any one help me in converting a DataView into a DataSet or a DataTable
into a DataSet,
I tried the following ways

dSet= ((DataSet)_gridRegStudDetails.DataSource);
dSet = ((DataSet)_gridRegStudDetails.DataSource).Tables[0].DataSet;
studData = ((DataSet)dView).Tables[0].DataSet;

But not working
can you pls help me out
Thanks in advance,
N.Ramakrishnan

 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      8th Aug 2005
Ramakrishnan.

A dataview holds no data.

However it holds (in Net 1.x) a reference to its datatable and in 2.0 it
will holds a reference to get its selected/sorted datarowviews.

Therefore what you want you can do in version 2.0. For 1.x you can use this
sample (what is not so much more work).

http://www.windowsformsdatagridhelp....7-d6ad9bebf57f

I hope this helps,

Cor





 
Reply With Quote
 
Marina
Guest
Posts: n/a
 
      8th Aug 2005
Let's say your dataview's name is myDataView.

myDataView.Table will return to you the underlying DataTable.


"Ramakrishnan Nagarajan" <(E-Mail Removed)> wrote in
message news:87BB4484-4367-4F2E-B48E-(E-Mail Removed)...
> Hi can any one help me in converting a DataView into a DataSet or a
> DataTable
> into a DataSet,
> I tried the following ways
>
> dSet= ((DataSet)_gridRegStudDetails.DataSource);
> dSet = ((DataSet)_gridRegStudDetails.DataSource).Tables[0].DataSet;
> studData = ((DataSet)dView).Tables[0].DataSet;
>
> But not working
> can you pls help me out
> Thanks in advance,
> N.Ramakrishnan
>



 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      8th Aug 2005
Ramakrishnan Nagarajan wrote:
> Hi can any one help me in converting a DataView into a DataSet or a DataTable
> into a DataSet,
> I tried the following ways
>
> dSet= ((DataSet)_gridRegStudDetails.DataSource);
> dSet = ((DataSet)_gridRegStudDetails.DataSource).Tables[0].DataSet;
> studData = ((DataSet)dView).Tables[0].DataSet;
>
> But not working
> can you pls help me out
> Thanks in advance,
> N.Ramakrishnan
>


You don't convert a datatable to a dataset. You add a table to a dataset.

From the help file under: DataSet Class, adding DataTable

Dim custDS As DataSet = New DataSet("CustomerOrders")

Dim ordersTable As DataTable = custDS.Tables.Add("Orders")

Dim pkCol As DataColumn = ordersTable.Columns.Add("OrderID",
Type.GetType("System.Int32"))
ordersTable.Columns.Add("OrderQuantity", Type.GetType("System.Int32"))
ordersTable.Columns.Add("CompanyName", Type.GetType("System.String"))

ordersTable.PrimaryKey = New DataColumn() {pkCol}


Chris
 
Reply With Quote
 
=?Utf-8?B?UmFtYWtyaXNobmFuIE5hZ2FyYWphbg==?=
Guest
Posts: n/a
 
      9th Aug 2005
Hi,
Thanks to every one who have dropped their help for my post.
I have no problem at all in sorting the data in the grid.
At first the DataSet will contain the data from the DataBase. Am fetching
all the data from the DataSet and create a new DataTable along with the new
values entered by the user in the DataGrid. Then Inorder to sort the data am
casting it to a DataView and sorted. Then I am binding the DataView to the
Grid. At this point I want all the data in the DataView to be in the DataSet
for future reference by the same event. So to have all those data in the
DataView to be in the DataSet what can I do. Can you please help me out.
Thanks,
N.Ramakrishnan

"Cor Ligthert [MVP]" wrote:

> Ramakrishnan.
>
> A dataview holds no data.
>
> However it holds (in Net 1.x) a reference to its datatable and in 2.0 it
> will holds a reference to get its selected/sorted datarowviews.
>
> Therefore what you want you can do in version 2.0. For 1.x you can use this
> sample (what is not so much more work).
>
> http://www.windowsformsdatagridhelp....7-d6ad9bebf57f
>
> I hope this helps,
>
> Cor
>
>
>
>
>
>

 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      9th Aug 2005
RamaKrishnan,

Did you see the sample the only thing you need at the end of that is somehow

ds.Add.Tables(dt)
or instead of that
dt = dtnew.copy
ds.Add.Tables(dtnew)

I hope this helps,

Cor


 
Reply With Quote
 
=?Utf-8?B?UmFtYWtyaXNobmFuIE5hZ2FyYWphbg==?=
Guest
Posts: n/a
 
      9th Aug 2005
Thanks Cor,
You are right and I did that using ds.Tables.Add(dt);
And now dataset is having the values of the datatable.
Thanks a lot again Cor.

N.Ramakrishnan

"Cor Ligthert [MVP]" wrote:

> RamaKrishnan,
>
> Did you see the sample the only thing you need at the end of that is somehow
>
> ds.Add.Tables(dt)
> or instead of that
> dt = dtnew.copy
> ds.Add.Tables(dtnew)
>
> I hope this helps,
>
> Cor
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strongly typed dataset, sorted by dataview, how to get dataset's row index from dataview? Thomas H Microsoft ADO .NET 2 9th Mar 2006 03:04 PM
SQL Table to DataSet to Dataview, to DataSet to XML! matteo Microsoft ADO .NET 4 30th Jan 2006 04:18 PM
Converting dataset to dataview and sorting? Brett Romero Microsoft C# .NET 7 17th Jan 2006 02:41 PM
DataView / DataSet / ADO.NET HELP A_PK Microsoft ADO .NET 6 13th Apr 2005 06:43 PM
DataSet OR Dataview =?Utf-8?B?UHJhc2FkIFBhdGls?= Microsoft Dot NET 2 8th Nov 2004 05:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:34 AM.