Displaying Select columns(windows forms app)

  • Thread starter Thread starter Phuff
  • Start date Start date
P

Phuff

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
(e-mail address removed)
 
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.
 
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
 
Back
Top