PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Datagrid help needed

Reply

Datagrid help needed

 
Thread Tools Rate Thread
Old 20-06-2006, 10:01 PM   #1
=?Utf-8?B?S2VpdGg=?=
Guest
 
Posts: n/a
Default Datagrid help needed


Can someone try and explain detail to me of how they would begin to tackle
the following scenario:

I would like to display two EDITABLE datagrids:

1. The "master grid" - contains people's information - name, title, job
description, etc. Some of these columns will be IDs to other lookup-type
tables (such as Title) and I will want to display the text of and allow
editing via drop-down.

2. The "detail grid" - contains the email address information for the
person selected in the current row above. This, too has columns containing
IDs to other lookup-type tables (such as what report gets sent to this e-mail
address).

Before I brainwash anyone by explaining the ways I've attempted to do this
(to no avail), I was hoping someone has done something similar and would shed
some light on how they'd done it in the past. My recurring problems seem to
be dealing with the "autonumber" (ID) columns in the database and retrieving
the SQL Server-generated Identifier used during an Insert/Update of the
"Master" and having that cascade through to the "Detail" children.

Note that many different people could be running this application and adding
records, so we cannot (solely) rely on any autonumbering system that we set
up in the various DataTable columns.
  Reply With Quote
Old 21-06-2006, 05:54 AM   #2
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: Datagrid help needed

Keith,

Why don't you than use the uniqueidentifier, the autonumber will give you
problems now or in future using datasets and datatables. Be aware that there
can be more rows in a datatable, which are updated in a serial way while
getting there identifieers and more people are concurently busy.

With SQLClient it is probably possible, with OleDb I believe that while
using the autonumber you have to do a lot to keep it stable in a multiuser
environement using Datatables.

The uniqueidentifier with the New Guid as that identifier solves all those
problems.

Just my thought,

Cor


"Keith" <Keith@discussions.microsoft.com> schreef in bericht
news:ACAC11EA-618A-42BD-88F4-7D2BC4ACA4D1@microsoft.com...
> Can someone try and explain detail to me of how they would begin to tackle
> the following scenario:
>
> I would like to display two EDITABLE datagrids:
>
> 1. The "master grid" - contains people's information - name, title, job
> description, etc. Some of these columns will be IDs to other lookup-type
> tables (such as Title) and I will want to display the text of and allow
> editing via drop-down.
>
> 2. The "detail grid" - contains the email address information for the
> person selected in the current row above. This, too has columns
> containing
> IDs to other lookup-type tables (such as what report gets sent to this
> e-mail
> address).
>
> Before I brainwash anyone by explaining the ways I've attempted to do this
> (to no avail), I was hoping someone has done something similar and would
> shed
> some light on how they'd done it in the past. My recurring problems seem
> to
> be dealing with the "autonumber" (ID) columns in the database and
> retrieving
> the SQL Server-generated Identifier used during an Insert/Update of the
> "Master" and having that cascade through to the "Detail" children.
>
> Note that many different people could be running this application and
> adding
> records, so we cannot (solely) rely on any autonumbering system that we
> set
> up in the various DataTable columns.



  Reply With Quote
Old 21-06-2006, 01:55 PM   #3
=?Utf-8?B?S2VpdGg=?=
Guest
 
Posts: n/a
Default Re: Datagrid help needed

Hmm, I was hoping it would be something simple I'm missing. If there was a
way to easily get the SQLServer-generated autoincremented number after an
insert; and then a simple way to cascade these into the new child rows of
this new parent row, then my problem would be solved.

I always figured that the dataadapter would be powerful enough to handle
this. I can't believe how much trouble it has when dealing with a simple
one-to-many relationship. I also can't believe that nobody else has had
problems like mine. While I do like the idea of creating a new GUID for each
new row, all the tables are already used in a multitude of other systems -
this isn't a new set of data, unfortunately.

"Cor Ligthert [MVP]" wrote:

> Keith,
>
> Why don't you than use the uniqueidentifier, the autonumber will give you
> problems now or in future using datasets and datatables. Be aware that there
> can be more rows in a datatable, which are updated in a serial way while
> getting there identifieers and more people are concurently busy.
>
> With SQLClient it is probably possible, with OleDb I believe that while
> using the autonumber you have to do a lot to keep it stable in a multiuser
> environement using Datatables.
>
> The uniqueidentifier with the New Guid as that identifier solves all those
> problems.
>
> Just my thought,
>
> Cor
>
>
> "Keith" <Keith@discussions.microsoft.com> schreef in bericht
> news:ACAC11EA-618A-42BD-88F4-7D2BC4ACA4D1@microsoft.com...
> > Can someone try and explain detail to me of how they would begin to tackle
> > the following scenario:
> >
> > I would like to display two EDITABLE datagrids:
> >
> > 1. The "master grid" - contains people's information - name, title, job
> > description, etc. Some of these columns will be IDs to other lookup-type
> > tables (such as Title) and I will want to display the text of and allow
> > editing via drop-down.
> >
> > 2. The "detail grid" - contains the email address information for the
> > person selected in the current row above. This, too has columns
> > containing
> > IDs to other lookup-type tables (such as what report gets sent to this
> > e-mail
> > address).
> >
> > Before I brainwash anyone by explaining the ways I've attempted to do this
> > (to no avail), I was hoping someone has done something similar and would
> > shed
> > some light on how they'd done it in the past. My recurring problems seem
> > to
> > be dealing with the "autonumber" (ID) columns in the database and
> > retrieving
> > the SQL Server-generated Identifier used during an Insert/Update of the
> > "Master" and having that cascade through to the "Detail" children.
> >
> > Note that many different people could be running this application and
> > adding
> > records, so we cannot (solely) rely on any autonumbering system that we
> > set
> > up in the various DataTable columns.

>
>
>

  Reply With Quote
Old 21-06-2006, 02:16 PM   #4
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: Datagrid help needed

Keith,

Maybe did I understand you wrong, you can do it using the autonumber.

If you do a cascade update than you have to do

First an update of the deleted child rows (If you have not in your database
on cascade delete)
Than the update of the master
Than the update of the added and changed child rows.
The most important things which you thanb have than to know is on this page.

http://msdn.microsoft.com/library/d...angestopic2.asp

Because that you are doing updates with the copy getchanges, do you have to
do an acceptchanges at the end.

I hope this helps,

Cor


"Keith" <Keith@discussions.microsoft.com> schreef in bericht
news:B42FA375-122C-4FB0-97C3-F2133D377D0F@microsoft.com...
> Hmm, I was hoping it would be something simple I'm missing. If there was
> a
> way to easily get the SQLServer-generated autoincremented number after an
> insert; and then a simple way to cascade these into the new child rows of
> this new parent row, then my problem would be solved.
>
> I always figured that the dataadapter would be powerful enough to handle
> this. I can't believe how much trouble it has when dealing with a simple
> one-to-many relationship. I also can't believe that nobody else has had
> problems like mine. While I do like the idea of creating a new GUID for
> each
> new row, all the tables are already used in a multitude of other systems -
> this isn't a new set of data, unfortunately.
>
> "Cor Ligthert [MVP]" wrote:
>
>> Keith,
>>
>> Why don't you than use the uniqueidentifier, the autonumber will give you
>> problems now or in future using datasets and datatables. Be aware that
>> there
>> can be more rows in a datatable, which are updated in a serial way while
>> getting there identifieers and more people are concurently busy.
>>
>> With SQLClient it is probably possible, with OleDb I believe that while
>> using the autonumber you have to do a lot to keep it stable in a
>> multiuser
>> environement using Datatables.
>>
>> The uniqueidentifier with the New Guid as that identifier solves all
>> those
>> problems.
>>
>> Just my thought,
>>
>> Cor
>>
>>
>> "Keith" <Keith@discussions.microsoft.com> schreef in bericht
>> news:ACAC11EA-618A-42BD-88F4-7D2BC4ACA4D1@microsoft.com...
>> > Can someone try and explain detail to me of how they would begin to
>> > tackle
>> > the following scenario:
>> >
>> > I would like to display two EDITABLE datagrids:
>> >
>> > 1. The "master grid" - contains people's information - name, title,
>> > job
>> > description, etc. Some of these columns will be IDs to other
>> > lookup-type
>> > tables (such as Title) and I will want to display the text of and allow
>> > editing via drop-down.
>> >
>> > 2. The "detail grid" - contains the email address information for the
>> > person selected in the current row above. This, too has columns
>> > containing
>> > IDs to other lookup-type tables (such as what report gets sent to this
>> > e-mail
>> > address).
>> >
>> > Before I brainwash anyone by explaining the ways I've attempted to do
>> > this
>> > (to no avail), I was hoping someone has done something similar and
>> > would
>> > shed
>> > some light on how they'd done it in the past. My recurring problems
>> > seem
>> > to
>> > be dealing with the "autonumber" (ID) columns in the database and
>> > retrieving
>> > the SQL Server-generated Identifier used during an Insert/Update of the
>> > "Master" and having that cascade through to the "Detail" children.
>> >
>> > Note that many different people could be running this application and
>> > adding
>> > records, so we cannot (solely) rely on any autonumbering system that we
>> > set
>> > up in the various DataTable columns.

>>
>>
>>



  Reply With Quote
Old 21-06-2006, 05:41 PM   #5
Carl Prothman
Guest
 
Posts: n/a
Default Re: Datagrid help needed

"Keith" <Keith@discussions.microsoft.com> wrote

> Can someone try and explain detail to me of how they would begin to tackle
> the following scenario:
> I would like to display two EDITABLE datagrids:
>


Keith,
Check out this sample code
VB.NET
http://support.microsoft.com/kb/310350
C#
http://support.microsoft.com/kb/320301

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.CarlProthman.NET


  Reply With Quote
Old 21-06-2006, 07:34 PM   #6
=?Utf-8?B?S2VpdGg=?=
Guest
 
Posts: n/a
Default Re: Datagrid help needed

Thank you. This link explains exactly what I'm looking for (even though I
don't really understand some of the code). The only difference will be that
I will have to generate my own SQLCommands for Delete/Update/Insert, since
both my master datatable and child datatable will be created using inner
joins on outside lookup tables (and the SQLCommandBuilder doesn't support
DataTables that were created using multiple database tables).

Here's to hoping it works!

"Carl Prothman" wrote:

> "Keith" <Keith@discussions.microsoft.com> wrote
> > Can someone try and explain detail to me of how they would begin to tackle
> > the following scenario:
> > I would like to display two EDITABLE datagrids:
> >

>
> Keith,
> Check out this sample code
> VB.NET
> http://support.microsoft.com/kb/310350
> C#
> http://support.microsoft.com/kb/320301
>
> --
>
> Thanks,
> Carl Prothman
> Microsoft ASP.NET MVP
> http://www.CarlProthman

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off