Navigating a dataset

Navigating a dataset

Post by roy » Mon, 22 Sep 2003 09:54:21


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
XXXX@XXXXX.COM
 
 
 

Navigating a dataset

Post by Daniel Wal » Mon, 22 Sep 2003 10:18:35

Roy,

you might try "ADO.NET for the ADO Programmer"
http://www.yqcomputer.com/
ml/adonetprogmsdn.asp

HTHs

Daniel


"Roy Lawson" < XXXX@XXXXX.COM > schrieb im Newsbeitrag

 
 
 

Navigating a dataset

Post by Daniel Wal » Mon, 22 Sep 2003 10:33:52

his is a multi-part message in MIME format.


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" < XXXX@XXXXX.COM > schrieb im Newsbeitrag news: XXXX@XXXXX.COM ...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:o = "urn:schemas-microsoft-com:office:office"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Verdana color=#000080 size=2>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000>Roy,</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000></FONT> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>maybe it
helps you if you imagine the following:</FONT></P>
<P class=normal style="MARGIN: auto 0cm"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"><FONT
color=#000000>The <SPAN class=programelement>DataSet</SPAN> object contains a
collection of zero or more <SPAN class=programelement>DataTable</SPAN> objects,
each of which is an in-memory representation of a single table. The structure of
a particular <SPAN class=programelement>DataTable</SPAN> is defined by the <SPAN
class=programelement>DataColumns</SPAN> collection, whi
 
 
 

Navigating a dataset

Post by Roy Lawso » Tue, 23 Sep 2003 12:19:39

or 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


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.
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.
Windows-Based Applications with Microsoft Visual
Basic .NET and Microsoft Visual C# ..NET" which I can
truly recommend.
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:
("ID").ToString
the collections in the ADO.NET model.
news: XXXX@XXXXX.COM ...
DataAdapter,
Using the
can get the
the data to show
previous, move
(using
learnvisualstudio.net videos
to get me going
 
 
 

Navigating a dataset

Post by Daniel Wal » Wed, 24 Sep 2003 05:09:47

his is a multi-part message in MIME format.


Keep on walking ;-)


"Roy Lawson" < XXXX@XXXXX.COM > schrieb im Newsbeitrag news:060901c380b8$5b8645d0$ XXXX@XXXXX.COM ...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Verdana color=#000080 size=2>Keep on walking ;-)</FONT></DIV>
<DIV><FONT face=Verdana color=#000080 size=2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=Verdana color=#000080 size=2>"Roy Lawson" <</FONT><A
href="mailto: XXXX@XXXXX.COM "><FONT face=Verdana color=#000080
size=2> XXXX@XXXXX.COM </FONT></A><FONT face=Verdana color=#000080 size=2>>
schrieb im Newsbeitrag </FONT><A
href="news:060901c380b8$5b8645d0$ XXXX@XXXXX.COM "><FONT face=Verdana
color=#000080 size=2>news:060901c380b8$5b8645d0$ XXXX@XXXXX.COM </FONT></A><FONT
face=Verdana color=#000080 size=2>...</FONT></DIV><FONT face=Verdana
color=#000080 size=2>> For what I am doing, there are no constraints on the
table <BR>> (single table only) so there is only 1 DataTable object in
<BR>> my DataSet.  I set it up this way (1 table w/o relations) <BR>>
just so I could get it going (crawl before walking).<BR>> <BR>> But, your
explanation was very helpful and I think with <BR>> that I can figure out
programaticly how to proceed.  I <BR>> suspect I need to focus on the
DataColumns collection when <BR>> it comes to navigating the DataTable within
my DataSet.  <BR>> <BR>> My code is on my laptop ... I will submit an
update to <BR>> this post after I figure it out so that others can learn
<BR>> to walk with me :-)<BR>> <BR>> Thanks!<BR>> <BR>>
-Roy<BR>> <BR>> <BR>> >-----Original Message-----<BR>>
if you imagine the following:<BR>> ><BR>> >The DataSet object
contains a collection of zero or more <BR>> DataTable objects, each of which
is an in-memory <BR>> representation of a single table. The structure of a
<BR>> particular DataTable is defined by the DataColumns <BR>> collection,
which enumerates the columns in a particular <BR>> table, and the Constraint
collection, which enumerates any <BR>> constraints on the table. Together,
these two collections <BR>> make up the table schema. A DataTable also
contains a <BR>> DataRows collection, which contains the actual data in the
<BR>> DataSet.<BR>> ><BR>> >The DataSet contains a DataRelations
collection. A <BR>> DataRelation object allows you to create associations
<BR>> between rows in one table and rows in another table. The <BR>>
DataRelations collection enumerates a set of DataRelation <BR>> objects that
define the relationships between tables in <BR>> the DataSet. For example,
consider a DataSet that contains <BR>> two related tables: an Employe