473,395 Members | 1,937 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,395 software developers and data experts.

Navigating a dataset

I am having no problems connecting to a DB, creating a DataAdapter,
and creating a dataset...and connecting to the data. Using the
builtin data objects to do all this.

My only problem now is navigating through the data. I can get the
data into a datagrid without any problems, but I want the data to show
up in textboxes and use some sort of move next, move previous, move
last, etc (like in VB6) command to navigate the data (using
buttonX_click). I have been using the learnvisualstudio.net videos
and they are great but anyone have a link or tutorial to get me going
on this specific task?

(Learning to crawl again)

Roy Lawson
ro*@xeon.tv
Nov 20 '05 #1
5 7380
Roy,

you might try "ADO.NET for the ADO Programmer"
http://msdn.microsoft.com/library/de...us/dndotnet/ht
ml/adonetprogmsdn.asp

HTHs

Daniel
"Roy Lawson" <ro*@xeon.tv> schrieb im Newsbeitrag
news:c4**************************@posting.google.c om...
I am having no problems connecting to a DB, creating a DataAdapter,
and creating a dataset...and connecting to the data. Using the
builtin data objects to do all this.

My only problem now is navigating through the data. I can get the
data into a datagrid without any problems, but I want the data to show
up in textboxes and use some sort of move next, move previous, move
last, etc (like in VB6) command to navigate the data (using
buttonX_click). I have been using the learnvisualstudio.net videos
and they are great but anyone have a link or tutorial to get me going
on this specific task?

(Learning to crawl again)

Roy Lawson
ro*@xeon.tv


Nov 20 '05 #2
Roy,

maybe it helps you if you imagine the following:

The DataSet object contains a collection of zero or more DataTable objects, each of which is an in-memory representation of a single table. The structure of a particular DataTable is defined by the DataColumns collection, which enumerates the columns in a particular table, and the Constraint collection, which enumerates any constraints on the table. Together, these two collections make up the table schema. A DataTable also contains a DataRows collection, which contains the actual data in the DataSet.

The DataSet contains a DataRelations collection. A DataRelation object allows you to create associations between rows in one table and rows in another table. The DataRelations collection enumerates a set of DataRelation objects that define the relationships between tables in the DataSet. For example, consider a DataSet that contains two related tables: an Employees table and a Projects table. In the Employees table, each employee is represented only once and is identified by a unique EmployeeID field. In the Projects table, an employee in charge of a project is identified by the EmployeeID field, but can appear more than once if that employee is in charge of multiple projects. This is an example of a one-to-many relationship; you would use a DataRelation object to define this relationship.

Excerpt from the book "MCAD/MCSD Training Kit-Developing Windows-Based Applications with Microsoft Visual Basic .NET and Microsoft Visual C# ..NET" which I can truly recommend.



If you for example have a table "myTable" in a DataSet "myDataSet" and you want to bind the field "ID" of the first row of the table to a TextBox named TextBox1 do the following:



TextBox1.Text = myDataSet.Tables("myTable").Rows(0).Item("ID").ToS tring



I hope this gives you the general idea. Always visualize the collections in the ADO.NET model.



Best regards

Daniel Walzenbach

"Roy Lawson" <ro*@xeon.tv> schrieb im Newsbeitrag news:c4**************************@posting.google.c om...
I am having no problems connecting to a DB, creating a DataAdapter,
and creating a dataset...and connecting to the data. Using the
builtin data objects to do all this.

My only problem now is navigating through the data. I can get the
data into a datagrid without any problems, but I want the data to show
up in textboxes and use some sort of move next, move previous, move
last, etc (like in VB6) command to navigate the data (using
buttonX_click). I have been using the learnvisualstudio.net videos
and they are great but anyone have a link or tutorial to get me going
on this specific task?

(Learning to crawl again)

Roy Lawson
ro*@xeon.tv

Nov 20 '05 #3
For what I am doing, there are no constraints on the table
(single table only) so there is only 1 DataTable object in
my DataSet. I set it up this way (1 table w/o relations)
just so I could get it going (crawl before walking).

But, your explanation was very helpful and I think with
that I can figure out programaticly how to proceed. I
suspect I need to focus on the DataColumns collection when
it comes to navigating the DataTable within my DataSet.

My code is on my laptop ... I will submit an update to
this post after I figure it out so that others can learn
to walk with me :-)

Thanks!

-Roy

-----Original Message-----
Roy,

maybe it helps you if you imagine the following:

The DataSet object contains a collection of zero or more DataTable objects, each of which is an in-memory
representation of a single table. The structure of a
particular DataTable is defined by the DataColumns
collection, which enumerates the columns in a particular
table, and the Constraint collection, which enumerates any
constraints on the table. Together, these two collections
make up the table schema. A DataTable also contains a
DataRows collection, which contains the actual data in the
DataSet.
The DataSet contains a DataRelations collection. A DataRelation object allows you to create associations
between rows in one table and rows in another table. The
DataRelations collection enumerates a set of DataRelation
objects that define the relationships between tables in
the DataSet. For example, consider a DataSet that contains
two related tables: an Employees table and a Projects
table. In the Employees table, each employee is
represented only once and is identified by a unique
EmployeeID field. In the Projects table, an employee in
charge of a project is identified by the EmployeeID field,
but can appear more than once if that employee is in
charge of multiple projects. This is an example of a one-
to-many relationship; you would use a DataRelation object
to define this relationship.
Excerpt from the book "MCAD/MCSD Training Kit-Developing Windows-Based Applications with Microsoft Visual
Basic .NET and Microsoft Visual C# ..NET" which I can
truly recommend.
If you for example have a table "myTable" in a DataSet "myDataSet" and you want to bind the field "ID" of
the first row of the table to a TextBox named TextBox1 do
the following:
TextBox1.Text = myDataSet.Tables("myTable").Rows(0).Item ("ID").ToString
I hope this gives you the general idea. Always visualize the collections in the ADO.NET model.
Best regards

Daniel Walzenbach

"Roy Lawson" <ro*@xeon.tv> schrieb im Newsbeitrag

news:c4**************************@posting.google.c om...
I am having no problems connecting to a DB, creating a DataAdapter, and creating a dataset...and connecting to the data. Using the builtin data objects to do all this.

My only problem now is navigating through the data. I can get the data into a datagrid without any problems, but I want the data to show up in textboxes and use some sort of move next, move previous, move last, etc (like in VB6) command to navigate the data (using buttonX_click). I have been using the learnvisualstudio.net videos and they are great but anyone have a link or tutorial to get me going on this specific task?

(Learning to crawl again)

Roy Lawson
ro*@xeon.tv

Nov 20 '05 #4
Roy,



what you have to do is to focus on the DataRow collection, as a (single) DataColumn represents the Type of Data which is stored in your Table. I'm sure you won't be surprised when I tell you that a DataRow itself consists of a collection of DataItems which represent the actual values in a table.



Imagine the following:



ID | Name | Comment

----------------------------------

1 | Smith | Nice guy!

2 | Wilson | Not so nice.

3 | Lawson | Learns ADO.NET.

4 | Miller | Somebody else.



Here is the code to create this table by your own and print it to the console. To execute the code create a new Console Project, delete all the code in it and copy all the code below into it.



' BEGIN OF CODE ************************************************** ***



Public Class ADODotNETExample



Public Shared Sub main()



' Create a Table

Dim myTable As New System.Data.DataTable

' Create a Column

Dim myColumn As System.Data.DataColumn



' set values for a column

myColumn = New System.Data.DataColumn

myColumn.ColumnName = "ID"

myColumn.DataType = System.Type.GetType("System.Int32")

' add Column to Table

myTable.Columns.Add(myColumn)



myColumn = New System.Data.DataColumn

myColumn.ColumnName = "Name"

myColumn.DataType = System.Type.GetType("System.String")

' add Column to Table

myTable.Columns.Add(myColumn)



myColumn = New System.Data.DataColumn

myColumn.ColumnName = "Description"

myColumn.DataType = System.Type.GetType("System.String")

' add Column to Table

myTable.Columns.Add(myColumn)



' Now you have a empty Table (or to be more exactly

' the definition of a table without any rows)



' Create a DataRow. Remember that you don't instanciate

' a DataRow Object (by using the new() operator)

Dim myDataRow As System.Data.DataRow



' get a DataRow from the Table(description) you just created

myDataRow = myTable.NewRow

' and fill it with Life

myDataRow.Item(0) = 1

myDataRow.Item(1) = "Smith"

myDataRow.Item(2) = "Nice guy!"

' now add the DataRow to the DataTable

myTable.Rows.Add(myDataRow)



' and again for the next row

' you can also address the items by name as the

' item property is overloaded

' get a DataRow from the Table(description) you just created

myDataRow = myTable.NewRow

myDataRow.Item("ID") = 2

myDataRow.Item("Name") = "Wilson"

myDataRow.Item("Description") = "Not so nice."

' now add the DataRow to the DataTable

myTable.Rows.Add(myDataRow)



' and again and again...

' get a DataRow from the Table(description) you just created

myDataRow = myTable.NewRow

myDataRow.Item("ID") = 3

myDataRow.Item("Name") = "Lawson"

myDataRow.Item("Description") = "Learns ADO.NET."

' now add the DataRow to the DataTable

myTable.Rows.Add(myDataRow)



' get a DataRow from the Table(description) you just created

myDataRow = myTable.NewRow

myDataRow.Item("ID") = 4

myDataRow.Item("Name") = "Miller"

myDataRow.Item("Description") = "Somebody else."

' now add the DataRow to the DataTable

myTable.Rows.Add(myDataRow)





Console.WriteLine("Content of myTable")

Console.WriteLine()

Console.WriteLine()



' write content of myTable to console



' first goes the Header

For j As System.Int32 = 0 To myTable.Columns.Count - 1

Console.Write(myTable.Columns(j).ColumnName & ControlChars.Tab)

Next



' new line

Console.WriteLine()



' draw horizontal line

For j As System.Int32 = 0 To 50

Console.Write("-")

Next



Console.WriteLine()



' now print the content of the table

For i As System.Int32 = 0 To myTable.Rows.Count - 1

For j As System.Int32 = 0 To myTable.Columns.Count - 1

Console.Write(myTable.Rows(i).Item(j).ToString & ControlChars.Tab)

Next

Console.WriteLine(ControlChars.Tab & " -> Row : " & i.ToString)

Next



' wait for user to press return

Console.ReadLine()



End Sub



End Class



' END OF CODE ************************************************** *****



Hope this gives you the general idea.

Greetings from Germany.



Daniel Walzenbach

"Roy Lawson" <ro*@xeon.tv> schrieb im Newsbeitrag news:06****************************@phx.gbl...
For what I am doing, there are no constraints on the table
(single table only) so there is only 1 DataTable object in
my DataSet. I set it up this way (1 table w/o relations)
just so I could get it going (crawl before walking).

But, your explanation was very helpful and I think with
that I can figure out programaticly how to proceed. I
suspect I need to focus on the DataColumns collection when
it comes to navigating the DataTable within my DataSet.

My code is on my laptop ... I will submit an update to
this post after I figure it out so that others can learn
to walk with me :-)

Thanks!

-Roy

-----Original Message-----
Roy,

maybe it helps you if you imagine the following:

The DataSet object contains a collection of zero or more

DataTable objects, each of which is an in-memory
representation of a single table. The structure of a
particular DataTable is defined by the DataColumns
collection, which enumerates the columns in a particular
table, and the Constraint collection, which enumerates any
constraints on the table. Together, these two collections
make up the table schema. A DataTable also contains a
DataRows collection, which contains the actual data in the
DataSet.

The DataSet contains a DataRelations collection. A

DataRelation object allows you to create associations
between rows in one table and rows in another table. The
DataRelations collection enumerates a set of DataRelation
objects that define the relationships between tables in
the DataSet. For example, consider a DataSet that contains
two related tables: an Employees table and a Projects
table. In the Employees table, each employee is
represented only once and is identified by a unique
EmployeeID field. In the Projects table, an employee in
charge of a project is identified by the EmployeeID field,
but can appear more than once if that employee is in
charge of multiple projects. This is an example of a one-
to-many relationship; you would use a DataRelation object
to define this relationship.

Excerpt from the book "MCAD/MCSD Training Kit-Developing

Windows-Based Applications with Microsoft Visual
Basic .NET and Microsoft Visual C# ..NET" which I can
truly recommend.



If you for example have a table "myTable" in a

DataSet "myDataSet" and you want to bind the field "ID" of
the first row of the table to a TextBox named TextBox1 do
the following:



TextBox1.Text = myDataSet.Tables("myTable").Rows(0).Item

("ID").ToString



I hope this gives you the general idea. Always visualize

the collections in the ADO.NET model.



Best regards

Daniel Walzenbach

"Roy Lawson" <ro*@xeon.tv> schrieb im Newsbeitrag

news:c4**************************@posting.google.c om...
I am having no problems connecting to a DB, creating a DataAdapter, and creating a dataset...and connecting to the data. Using the builtin data objects to do all this.

My only problem now is navigating through the data. I can get the data into a datagrid without any problems, but I want the data to show up in textboxes and use some sort of move next, move previous, move last, etc (like in VB6) command to navigate the data (using buttonX_click). I have been using the learnvisualstudio.net videos and they are great but anyone have a link or tutorial to get me going on this specific task?

(Learning to crawl again)

Roy Lawson
ro*@xeon.tv

Nov 20 '05 #5
Keep on walking ;-)
"Roy Lawson" <ro*@xeon.tv> schrieb im Newsbeitrag news:06****************************@phx.gbl...
For what I am doing, there are no constraints on the table
(single table only) so there is only 1 DataTable object in
my DataSet. I set it up this way (1 table w/o relations)
just so I could get it going (crawl before walking).

But, your explanation was very helpful and I think with
that I can figure out programaticly how to proceed. I
suspect I need to focus on the DataColumns collection when
it comes to navigating the DataTable within my DataSet.

My code is on my laptop ... I will submit an update to
this post after I figure it out so that others can learn
to walk with me :-)

Thanks!

-Roy

-----Original Message-----
Roy,

maybe it helps you if you imagine the following:

The DataSet object contains a collection of zero or more

DataTable objects, each of which is an in-memory
representation of a single table. The structure of a
particular DataTable is defined by the DataColumns
collection, which enumerates the columns in a particular
table, and the Constraint collection, which enumerates any
constraints on the table. Together, these two collections
make up the table schema. A DataTable also contains a
DataRows collection, which contains the actual data in the
DataSet.

The DataSet contains a DataRelations collection. A

DataRelation object allows you to create associations
between rows in one table and rows in another table. The
DataRelations collection enumerates a set of DataRelation
objects that define the relationships between tables in
the DataSet. For example, consider a DataSet that contains
two related tables: an Employees table and a Projects
table. In the Employees table, each employee is
represented only once and is identified by a unique
EmployeeID field. In the Projects table, an employee in
charge of a project is identified by the EmployeeID field,
but can appear more than once if that employee is in
charge of multiple projects. This is an example of a one-
to-many relationship; you would use a DataRelation object
to define this relationship.

Excerpt from the book "MCAD/MCSD Training Kit-Developing

Windows-Based Applications with Microsoft Visual
Basic .NET and Microsoft Visual C# ..NET" which I can
truly recommend.



If you for example have a table "myTable" in a

DataSet "myDataSet" and you want to bind the field "ID" of
the first row of the table to a TextBox named TextBox1 do
the following:



TextBox1.Text = myDataSet.Tables("myTable").Rows(0).Item

("ID").ToString



I hope this gives you the general idea. Always visualize

the collections in the ADO.NET model.



Best regards

Daniel Walzenbach

"Roy Lawson" <ro*@xeon.tv> schrieb im Newsbeitrag

news:c4**************************@posting.google.c om...
I am having no problems connecting to a DB, creating a DataAdapter, and creating a dataset...and connecting to the data. Using the builtin data objects to do all this.

My only problem now is navigating through the data. I can get the data into a datagrid without any problems, but I want the data to show up in textboxes and use some sort of move next, move previous, move last, etc (like in VB6) command to navigate the data (using buttonX_click). I have been using the learnvisualstudio.net videos and they are great but anyone have a link or tutorial to get me going on this specific task?

(Learning to crawl again)

Roy Lawson
ro*@xeon.tv

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Darren Clark | last post by:
I am trying to understand typed datasets more.... and i am stuck on a little problem I have created a type dataset called "News" this consists of 2 tables. NewsTable and NewsTypes. the news...
2
by: Hassan Cheraghali | last post by:
Dear Sir I biging in asp.net and i want desine a data entry form with single record at time. i need navigate records but i dont now. Plese help me , how can i do this. Thanks for your time. ...
1
by: Lerp | last post by:
Hi all, I have a dataset made up of 3 tables that is bound to a datalist. On the itemdataBound event I call a sub that grabs a value (an id value) from the current row being outputted, queries...
1
by: pmcguire | last post by:
I want to navigate to a specific record within a dataset.datatable. Some of my controls are bound to this datatable, and it would be nice to do something like ...
1
by: VictorT | last post by:
Hi All, I am trying to create a simple Windows form that lists a users' data one user at a time with the usual "Next" & "Previous" buttons. Upon loading the form, I am able to populate all...
1
by: madhu | last post by:
Hello all, I am a bignner to vb.net I am not able to move the dataset and bind the textbox to dataset. My objective is 1) when the form loads it should display the first record. and the...
1
by: Hexman | last post by:
Hello All, What I'm trying to do is update a child record using a parent-child relation. I want to find out if it is faster than than doing multiple selects. Anyways, I've created a dataset...
0
by: Ohad Weiss | last post by:
Hi all, I've once asked about that topic. but didn't get an answer. I have a dataset based on 4 tables, which have relation between them. The main table presented to the user on textboxes...
0
by: Ohad Weiss | last post by:
Hi I have a problem with two textboxes binded to a dataset, based on paren table, and table for the child records. I can navigate between the master records (and of course the child records...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.