473,289 Members | 1,810 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,289 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 7360
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.