Help sorting a cloned dataset

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2009
Posts: 38
Reputation: thacravedawg is an unknown quantity at this point 
Solved Threads: 0
thacravedawg thacravedawg is offline Offline
Light Poster

Help sorting a cloned dataset

 
0
  #1
Mar 16th, 2009
I am trying to make an application that sorts a database with user input and returns a form. This form then accepts some user input, and then needs to be sorted in another event. I am using ado.net, and am attempting to complete this task by cloning a dataset and using select commands on the cloned dataset. This is the basic outline of how I'm trying to do this currently

  1. public DataSet ds;
  2.  
  3. 1 st button click event
  4. {
  5. initialize variable, set to input values...
  6.  
  7. oledbcommand cmd = new oledbcommand("SELECT * FROM TBL, database");
  8. da.selectcommand = cmd;
  9. oledbcommandbuilder cb = new oledbcommandbuilder(da);
  10. ds = new dataset();
  11. da.fill(ds);
  12. datagridview.datasource = ds.tables[0];
  13. }

this part works fine.

  1. 2nd button click event
  2. {
  3. dataset form = new dataset();
  4. form = ds.Clone();
  5. datatable dt = form.tables[0];
  6. dt.select("FieldName > 0");
  7. datagridview.datasource = dt;
  8. }

This part returns a blank table in the same schema as the above table.

So in conclusion, I need to query a dataset from my database, and then I need to use the sort/compute commands on this data from another event.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 38
Reputation: thacravedawg is an unknown quantity at this point 
Solved Threads: 0
thacravedawg thacravedawg is offline Offline
Light Poster

Re: Help sorting a cloned dataset

 
0
  #2
Mar 16th, 2009
I hate myself, cloned datasets are only supposed to retain table structure. If anyone is interested in similar uses, simply swap the work Copy in the place of Clone and your data will also be available in addition to table structure.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC