Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / September 2005

Tip: Looking for answers? Try searching our database.

Displaying Select columns(windows forms app)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phuff - 27 Sep 2005 15:25 GMT
This is really stumping me.  I have a dataset where I compute certain
columns because I need to reorganize the data to a certain format, but
I need to take the new columns and put them into a new dataset.  I have
a custom control where a user performs some actions and it combines
certain columns or at least creates a new one with a name I can use.

What I need is to bind a dataset to a grid with only the computed
columns.  I thought I would create a new DS and merge it with the
doctored one, but no go, empty values with only the column headers.
How do I get a dataset to be created from only certain columns in
another dataset?

Thanks in advance!!

Paul Huff
paul@postnexusinc.com
rviray - 27 Sep 2005 17:23 GMT
what I would do is create a DataTable object with one column (th
derived info from the dataset)...assuming that you need to d
calculations after you already have the Dataset.

insert new rows in the new DataTable based on your calculations in th
dataset and bind the DataTable to the DataGrid....

If you need some code examples...post back or pm me.

Hope this helps...
Ralp

--
rvira
Phuff - 27 Sep 2005 18:05 GMT
the problem is that I need only certain columns.

Here it is:

Someone gives me an address list.  This could be in any format, but I
need it to be Name, Addr1, Addr2, City, State, Zip.  The list could
come from realtors so it might have home worth, etc.  I have a control
that allows them to use some check boxes and other various stuff to
describe their data(ie. this column is the Full Name column, or this is
the First Name and this is teh Last Name).  I then create based off
their selection.  If full name it just goes into a column called
OutputName.  If first and last names OutputName is created using First
Name column and last name so on and so forth.

This all works great, I now have a dataset that has the old information
with the new columns appended at the end.  I will need to loop through
this dataset and pull out the correctly structure data to fill a custom
Address object in another part of the program.  I also need to display
only the newly organized data in a datagrid so that the user may verify
they mapped their data correctly.  (This is a must as it could be a
200, 500, 5000 - who knows- person list and they will be printing to
this list.  If they mapped incorrectly they would still be charged even
though the mailings would have incorrect addressing formats, which
would probably mean a loss of a customer)  I figured the easiest way to
do this is to create a new dataset based off the original, to
accomplish both of my previously stated goals.  I have no idea how to
do this in Ado.net.  Is it even possible?  I wish I could do some SQL
statements against a dataset, lol.

So its not certain records, but certain fields(columns) that I need.
Let me know if I need to clarify further, thanks.
Phuff - 29 Sep 2005 17:24 GMT
Okay, I figured out how to filter out columns.  I can't use ADO to do
it as it doesn't support such procedures with columns.  What I do is
grab each value out of my dataset (of course skipping the ones I don't
want) and fill a 2-dimensional array.  For anyone who's interested here
is the code.

           Dim Ccount As Integer = dset1.Tables(0).Columns.Count
           Dim Rcount As Integer = dset1.Tables(0).Rows.Count

          'this is the number of columns I appened to end; its the
same every   time
           Const addr As Integer = 6

           Dim notneed As Integer = Ccount - addr
           Dim darray(Rcount, addr) As String

           For i As Integer = 0 To 5
               For x As Integer = 0 To (Rcount - 1)
                   For j As Integer = (notneed + 1) To (Ccount - 1)
                       darray(x, i) =
dset1.Tables(0).Rows.Item(x).Item(j)
                   Next
               Next
           Next

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.