Article View: borland.public.delphi.database.dotnet
Article #131DataTable.NewRow
From: Eric Orilla
Date: Wed, 04 Oct 2006 08:21
Date: Wed, 04 Oct 2006 08:21
52 lines
2093 bytes
2093 bytes
in C# the following compiles successfully
column = new DataColumn();
column.DataType = System.Type.GetType("System.Int32");
column.ColumnName = "id";
Columns.Add(column);
keys[0] = column;
column = new DataColumn();
column.DataType = System.Type.GetType("System.Double");
column.ColumnName = "ic";
Columns.Add(column);
// Create second column.
column = new DataColumn();
column.DataType = Type.GetType("System.String");
column.ColumnName = "item";
Columns.Add(column);
PrimaryKey = keys;
DataRow row;
row["id"] = 1;
row["ic"] = 123.456;
row["item"] = "Item1";
Rows.Add(row);
in Delphi equivalent produces compilation error
column := DataColumn.Create;
column.DataType := System.Type.GetType('System.Int32');
column.ColumnName := 'id';
Columns.Add(column);
column := DataColumn.Create;
column.DataType := System.Type.GetType('System.Double');
column.ColumnName := 'ic';
Columns.Add(column);
column := DataColumn.Create;
column.DataType := System.Type.GetType('System.String');
column.ColumnName := 'item';
Columns.Add(column);
row := NewRow();
row['id'] := 1; <**** Incompatible types: 'Object' and 'Integer'
row['ic'] := 123.456; <**** Incompatible types: 'Object' and 'Double'
row['item'] := 'Item1';
Rows.Add(row);
What is the rigth way of doing this...
Technical Details
Message-ID:
<45236f21@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,20afc7b05fc3bcdc,start X-Google-Attributes: gid1effe6,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Eric Orilla" <eorilla@yahoo.com> Sender: "Eric Orilla" <eorilla@yahoo.com> Reply-To: "Eric Orilla" <eorilla@yahoo.com> Subject: DataTable.NewRow Newsgroups: borland.public.delphi.database.dotnet X-User-Info: 202.130.156.2 NNTP-Posting-Host: 207.105.83.66 Message-ID: <45236f21@newsgroups.borland.com> Date: 4 Oct 2006 01:21:53 -0700 X-Trace: newsgroups.borland.com 1159950113 207.105.83.66 (4 Oct 2006 01:21:53 -0700) Lines: 53 Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail