Article View: borland.public.delphi.database.dotnet
Article #568Can't compile TDS unit with Relation
From: John Mace
Date: Sat, 08 Jan 2005 13:43
Date: Sat, 08 Jan 2005 13:43
47 lines
2784 bytes
2784 bytes
Hi,
I'm having difficulty adding a Relation to a DataSet and using the resulting
typed dataset. The generated Delphi unit fails to compile and throws an
invalid typecast exception on a line referencing the newly added Relation.
I'm wondering if anyone has time to verify my results. I'm using D2005E,
Update 1 on Win2K.
Try this.
1. Create a new WinForms application and save it to a new folder (I'll use
C:\Test).
2. From the Data Explorer, drop the Customers and Orders tables from the
Northwind database onto the form.
3. With one of the Adapters selected, choose to Generate Typed Dataset at
the bottom of the Object Inspector.
4. In the dialog, include both tables in the dataset and uncheck the box to
add the dataset to the designer (this instantiation works).
5. If you want, make a backup copy of C:\Test\DataSet1.xsd for later
comparisons and testing.
6. Add a button to the form and make its Click event look like this:
procedure TWinForm.Button1_Click(sender: System.Object; e:
System.EventArgs);
var
ds : DataSet;
begin
ds := DataSet.Create;
try
ds.ReadXMLSchema('C:\Test\DataSet1.xsd');
ds.Relations.Add(DataRelation.Create('CustomerToOrders',
ds.Tables[0].Columns[0], ds.Tables[1].Columns[1]));
ds.WriteXMLSchema('C:\Test\DataSet1.xsd');
finally
ds.Dispose;
end; // try
end;
7. Run the application, click the button, and exit the application.
8. When I recompile the project after this point, I get some Dataset
Assembly Compile Errors. The first of these is Error: E2089 Invalid typecast
in the DataSet1Unit.pas.DataSet1.CustomersRow.GetOrdersRows function.
I'd appreciate either verification of this behavior or a tip to get me
around the problem. Thanks for your time,
John
Technical Details
Message-ID:
<41dfe355@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out2.kabelfoon.nl!83.128.0.10.MISMATCH!newsfeed.kabelfoon.nl!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,c5dd772e0d9a1597,start X-Google-Attributes: gid1effe6,public X-Google-Language: ENGLISH,ASCII-7-bit From: "John Mace" <jmace@direcway.com> Newsgroups: borland.public.delphi.database.dotnet Subject: Can't compile TDS unit with Relation Date: Sat, 8 Jan 2005 08:43:58 -0500 Lines: 49 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 69.35.178.134 Message-ID: <41dfe355@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1105191765 69.35.178.134 (8 Jan 2005 05:42:45 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out2.kabelfoon.nl!83.128.0.10.MISMATCH!newsfeed.kabelfoon.nl!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail