473,396 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Finding A Record in a Dataset by index

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
3 4717
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

"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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Devesh Aggarwal | last post by:
Hi, I have a backup and restore module in my project. The backup uses a typed dataset object (XSD) to get the data from database and creates a xml file as the backup file (using the WriteXml...
3
by: Wilson Wu | last post by:
Hi, How can I find the field value in the dataset and then assign one of the field value to a variable ? Thanks Wilson
0
by: Doug | last post by:
I've got a strongly-typed dataset with 2 related tables in it ("Staff" and "Roles"). I want to make a change to the parent Staff row and also to its child Role row. I'm having difficulty figuring...
3
by: Mark Vergara | last post by:
Hi to all, I want to know if there is a way of getting the position of the particular record in the dataset aside from CurrencyManger.position let say for example we have a record.. cntID ...
0
by: Lisa Jones | last post by:
Hi Has anyone see this problem in ADO.Net when deleting a record (assuming that the table has identity increment Index) result in getting wrong index key if right after adding the record the table...
2
by: Mark Vergara | last post by:
Hi! Is there any way of finding of what position in a particular record ? For example I have 3 records 1 Record 1.. 2 Record 2.. 3 Record 3..
3
by: Newbie | last post by:
Could someone please tell me how or if the following is possible. I have created a small test database and have opened one connection, one DataAdapter, and one Dataset for it in my vb.net...
0
by: DavidB | last post by:
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...
7
by: Dale Sampson | last post by:
As you can tell, I am new to VS.net. I have a VB project with a defined data source pointing to a table in a ..mdb file.-- The associated fields are displayed in textboxes using the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.