Article View: borland.public.delphi.aspdotnet.components.using
Article #252Re: Inserting record in Detail dbwebgrid.
From: Vagelis
Date: Mon, 21 Mar 2005 10:37
Date: Mon, 21 Mar 2005 10:37
66 lines
3148 bytes
3148 bytes
"John Moshakis" <john@moshakis.com> wrote in message
news:423b32b6$2@newsgroups.borland.com...
> Vagelis wrote:
>
> > Hello everybody.
> >
> > Is there any way I can insert a record in a detail table without
> > getting an "Invalid CurrentPageIndex value. It must be >= 0 and < the
> > PageCount" error?
> >
> > I have only found examples for master-detail tables, using
> > dbwebgrids, where the detail tables are always read only.
> >
> > Thanks in advance.
>
> Hi,
>
> What does your code look like?
>
> Cheers,
> John
Hi John.Thanks for the reply.
The Update and Delete rules in my relation have the "Cascade" value and the
Accept/Reject rule has "None".
After I set the relation properties from the relation editor of the dataset,
the code produced is:
Self.dataSet1.Relations.AddRange(TArrayOfSystem_Data_DataRelation.Create(Sys
tem.Data.DataRelation.Create('Relation1', 'Swmata', 'Swmata_Description',
TArrayOfString.Create('ID'), TArrayOfString.Create('SID'), False)));
Self.dataSet1.Tables.AddRange(TArrayOfSystem_Data_DataTable.Create(Self.Data
Table1,
Self.DataTable2));
'ID' is the primary key of my master table 'Swmata' and 'SID' is the foreign
key used by the child table 'Swmata_Description.
The following steps are never executed but I include them so as you can
understand the strategy I try to follow.
In the ApplyChanges event of my dbWebDatasource my code is:
procedure TWebForm1.ApplyChanges(sender: System.Object; e:
Borland.Data.Web.WebControlEventArgs);
begin
BdpDataAdapter1.AutoUpdate;
BdpDataAdapter2.AutoUpdate;
end;
where BdpDataAdapter1 is used for the master table and BdpDataAdapter2 for
the detail.
The idea is that in the next step I would try to change the update command
in the rowupdating event, so as I can give the apropriate foreign key value
to the new record.But obviously there is something wrong with the way I
follow.
The problem is I'm new to .NET and I don't even know if what I want to do
can be done, using AutoUpdate commands. A general example of master detail
tables with both of the tables being editable would be very helpful.
kalimera and thanks in advance,
Vagelis.
Technical Details
Message-ID:
<423ea01f@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<423ab985@newsgroups.borland.com> <423b32b6$2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 21665a,6c294b2d21e85c9b X-Google-Attributes: gid21665a,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Vagelis" <vagelis@4m.gr> From: "Vagelis" <vagelis@4m.gr> Newsgroups: borland.public.delphi.aspdotnet.components.using References: <423ab985@newsgroups.borland.com> <423b32b6$2@newsgroups.borland.com> Subject: Re: Inserting record in Detail dbwebgrid. Date: Mon, 21 Mar 2005 12:37:05 +0200 Lines: 68 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 195.97.18.91 Message-ID: <423ea01f@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1111400479 195.97.18.91 (21 Mar 2005 02:21:19 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail