By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,838 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,838 IT Pros & Developers. It's quick & easy.

Finding A Record in a Dataset by index

P: n/a
New to .net....sorry if this seems repetitive

I have a dataset ordered by date (SQLDataAdapter SelectCommand uses
Order By) and want to find a record by a UniqueID(Identity Column).
Then I want to change the position (BindingContext) in the dataset to
have all my bound controls reflect the data in the found record - and
the related records/tables.
Problem is, it appears it can't be done....
The Dataset has to be ordered by the date column, and the UniqeID (int)
is the primary key.

The solution of creating a Dataview and finding the record is not a
real-world solution as it requires the sort order to be changed (from
date to identity column). Hence the index of the found item is unlikely
to be correct.

I think many people have travelled this path before but I can't find
any useful info relating to this exact issue

If you can help, please do..
DB

Apr 20 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
David,

Reading your message I got the idea that you to solve our problem first have
to understand what the Dataset is.

A short try in advance.

A dataset is a kind of wrapper around datatables and datarelation.
A datatable holds datarows, datacolumns and a defaultview
A datarelation holds a relation to datarows in datatables
A defaultview holds sort, selections for rows you can use more and than the
name becomes DataView.
A datarow holds items which have a description in the datacolumns.
The last is the reason that a datarow can never belong to another table. It
has the reference to the table and its columns in it.

There are a lot of find methods.
DataView.Find
DataTable.Select
DataView.Rowfilter
DataTable.Collection.Find

If you study this a little bit by instance on MSDN, than your problem will
be in my idea be solvable.

I hope this helps,

Cor
Apr 20 '06 #2

P: n/a

"DavidB" <d9*******@cairns.qld.gov.au> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
New to .net....sorry if this seems repetitive

I have a dataset ordered by date (SQLDataAdapter SelectCommand uses
Order By) and want to find a record by a UniqueID(Identity Column).
Then I want to change the position (BindingContext) in the dataset to
have all my bound controls reflect the data in the found record - and
the related records/tables.
Problem is, it appears it can't be done....
The Dataset has to be ordered by the date column, and the UniqeID (int)
is the primary key.

The solution of creating a Dataview and finding the record is not a
real-world solution as it requires the sort order to be changed (from
date to identity column). Hence the index of the found item is unlikely
to be correct.

I think many people have travelled this path before but I can't find
any useful info relating to this exact issue

If you can help, please do..
DB

In your SQL statement, you can select only the row(s) that have the UniqueID
you are looking for pretty easy.
Something similar to this:

" Select * From <tablename goes here> Where [ColumnName goes here] = " &
UniqueIDvalue & " Order By [Date]"

<tablename goes here> is the name of the table you are searching in ( just
put the table name not the < >.
ColumnName goes here is the name of the Column that contains the
UniqueIDvale that you are looking for.( keep the brackets)
UniqueIDvalue can be a string that contains the value you are searching for.

I think you get the idea here. You select all of the table's columns and
search for only the row(s) that have the value you are looking for in a
particular column. Or if you only need a few of the table's columns, you
can modify the Select portion of the statement similar to :
"Select [column1], [column2], [column3], [column4] Where [Column3] =" &
UnidueIDvalue & " Order By [column1]"

Hope this is what you are looking for.
james

Apr 20 '06 #3

P: n/a

"james" <jj***************@earthlink.net> wrote in message
news:uY**************@TK2MSFTNGP03.phx.gbl...

"DavidB" <d9*******@cairns.qld.gov.au> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
New to .net....sorry if this seems repetitive

I have a dataset ordered by date (SQLDataAdapter SelectCommand uses
Order By) and want to find a record by a UniqueID(Identity Column).
Then I want to change the position (BindingContext) in the dataset to
have all my bound controls reflect the data in the found record - and
the related records/tables.
Problem is, it appears it can't be done....
The Dataset has to be ordered by the date column, and the UniqeID (int)
is the primary key.

The solution of creating a Dataview and finding the record is not a
real-world solution as it requires the sort order to be changed (from
date to identity column). Hence the index of the found item is unlikely
to be correct.

I think many people have travelled this path before but I can't find
any useful info relating to this exact issue

If you can help, please do..
DB

I need my 4th cup of coffee again!! You are wanting to do this from a
Dataset and not from a SQL Query Statement.
Sorry about that.
james
Apr 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.