William
Fri Jul 09 11:43:47 CDT 2004
This is a multi-part message in MIME format.
------=_NextPart_000_0054_01C46599.3BAE5920
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: quoted-printable
The problem with your scenario (as simple as it is), is that the =
DataAdapter etal. are designed to work with a single table. Your SELECT =
joins two tables so you need to create a separate DataAdapter for each =
table so they can be updated individually--and (possibly) a third =
DataAdapter to return the JOIN rowset. If you don't plan to change both =
tables, you can get away with a single DataAdapter--but you'll have to =
fill in the SqlCommands by hand. This seems like a lot of trouble and =
some choose not to take this approach. What some folks do (and I =
illustrate in the book) is create a single SELECT (as you have done) and =
use it to populate the DataGrid. I then create stored procedures that do =
the Update, Insert and Delete operations. Remember the Update method =
simply walks the DataTable and executes the appropriate SqlCommand for =
each operation that's needed--while it maps the current table columns to =
the command parameters, it does not care what these commands do as long =
as they command returns rows affected =3D 1.=20
hth
--=20
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.=20
This posting is provided "AS IS" with no warranties, and confers no =
rights.
__________________________________
"billyb" <billyb@discussions.microsoft.com> wrote in message =
news:98705407-0B1F-48BB-97E7-D69779F51072@microsoft.com...
> I've ordered Bill Vaughn's book, which I hope will help me with this, =
but in the meantime, can someone point me to an RTFM or give me some =
outline of how to attack this problem? I've read the docs and even a =
book on ADO .NET, so I'm familiar in general with all the components =
(DataAdapters, DataReaders, DataSets, DataTables, etc.)
>=20
> I'd simply like to display all athletes in a specific grade joined to =
a table that shows their sport (table defs and query below). I'd like =
this to be in a grid that the user can edit to change athlete =
information, then update the database. I don't care if the solution is =
manual or disconnected, or whatever... I just need to get started with =
this stuff to better understand it.
>=20
> CREATE TABLE ATHLETE (ATHLETE_ID INT NOT NULL, SPORT_ID INT NOT NULL, =
LNAME VARCHAR(100), FNAME VARCHAR(50))
>=20
> CREATE TABLE SPORT (SPORT_ID INT NOT NULL, SPORT_NAME VARCHAR(100), =
MAX_PARTICIPANTS INT)
>=20
> SELECT LNAME, FNAME, SPORT_NAME=20
> FROM ATHLETE, SPORT
> WHERE ATHLETE.SPORT_ID =3D SPORT.SPORT_ID
>=20
> Simple example, but it will get me moving.=20
>=20
> Thanks,
>=20
> billy
------=_NextPart_000_0054_01C46599.3BAE5920
Content-Type: text/html;
charset="Utf-8"
Content-Transfer-Encoding: quoted-printable
=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3D"Comic Sans MS" size=3D2>The problem with your =
scenario (as simple=20
as it is), is that the DataAdapter etal. are designed to work with a =
single=20
table. Your SELECT joins two tables so you need to create a separate =
DataAdapter=20
for each table so they can be updated individually--and (possibly) a =
third=20
DataAdapter to return the JOIN rowset. If you don't plan to change both =
tables,=20
you can get away with a single DataAdapter--but you'll have to fill in =
the=20
SqlCommands by hand. </FONT><FONT face=3D"Comic Sans MS" size=3D2>This =
seems like a=20
lot of trouble and some choose not to take this approach. What some =
folks do (and I illustrate in the book) is create a single SELECT =
(as you=20
have done) and use it to populate the DataGrid. I then create stored =
procedures=20
that do the Update, Insert and Delete operations. Remember the Update =
method=20
simply walks the DataTable and executes the appropriate SqlCommand for =
each=20
operation that's needed--while it maps the current table columns to the =
command=20
parameters, it does not care what these commands do as long as they =
command=20
returns rows affected =3D 1. </FONT></DIV>
<DIV><FONT face=3D"Comic Sans MS" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Comic Sans MS" size=3D2>hth</FONT></DIV>
<DIV><FONT face=3D"Comic Sans MS" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Comic Sans MS" size=3D2></FONT> </DIV>
<DIV><BR><FONT face=3D"Comic Sans MS" size=3D2>--=20
<BR>____________________________________<BR>William (Bill) =
Vaughn<BR>Author,=20
Mentor, Consultant<BR>Microsoft MVP<BR></FONT><A=20
href=3D"
http://www.betav.com"><FONT face=3D"Comic Sans MS"=20
size=3D2>www.betav.com</FONT></A><BR><FONT face=3D"Comic Sans MS" =
size=3D2>Please=20
reply only to the newsgroup so that others can benefit. <BR>This posting =
is=20
provided "AS IS" with no warranties, and confers no=20
rights.<BR>__________________________________<BR></FONT></DIV>
<DIV><FONT face=3D"Comic Sans MS" size=3D2>"billyb" <</FONT><A=20
href=3D"mailto:billyb@discussions.microsoft.com"><FONT face=3D"Comic =
Sans MS"=20
size=3D2>billyb@discussions.microsoft.com</FONT></A><FONT face=3D"Comic =
Sans MS"=20
size=3D2>> wrote in message </FONT><A=20
href=3D"news:98705407-0B1F-48BB-97E7-D69779F51072@microsoft.com"><FONT=20
face=3D"Comic Sans MS"=20
size=3D2>news:98705407-0B1F-48BB-97E7-D69779F51072@microsoft.com</FONT></=
A><FONT=20
face=3D"Comic Sans MS" size=3D2>...</FONT></DIV><FONT face=3D"Comic Sans =
MS"=20
size=3D2>> I've ordered Bill Vaughn's book, which I hope will help me =
with=20
this, but in the meantime, can someone point me to an RTFM or give me =
some=20
outline of how to attack this problem? I've read the docs and even =
a book=20
on ADO .NET, so I'm familiar in general with all the components =
(DataAdapters,=20
DataReaders, DataSets, DataTables, etc.)<BR>> <BR>> I'd simply =
like to=20
display all athletes in a specific grade joined to a table that shows =
their=20
sport (table defs and query below). I'd like this to be in a grid =
that the=20
user can edit to change athlete information, then update the =
database. I=20
don't care if the solution is manual or disconnected, or whatever... I =
just need=20
to get started with this stuff to better understand it.<BR>> <BR>> =
CREATE=20
TABLE ATHLETE (ATHLETE_ID INT NOT NULL, SPORT_ID INT NOT NULL, LNAME=20
VARCHAR(100), FNAME VARCHAR(50))<BR>> <BR>> CREATE TABLE SPORT =
(SPORT_ID=20
INT NOT NULL, SPORT_NAME VARCHAR(100), MAX_PARTICIPANTS INT)<BR>> =
<BR>>=20
SELECT LNAME, FNAME, SPORT_NAME <BR>> FROM ATHLETE, SPORT<BR>> =
WHERE=20
ATHLETE.SPORT_ID =3D SPORT.SPORT_ID<BR>> <BR>> Simple example, but =
it will=20
get me moving. <BR>> <BR>> Thanks,<BR>> <BR>>=20
billy</FONT></BODY></HTML>
------=_NextPart_000_0054_01C46599.3BAE5920--