M
Mircea Pleteriu
Hi All,
byte[] b1 = Guid.NewGuid().ToByteArray();
byte[] b2 = Guid.NewGuid().ToByteArray();
DataTable dt = new DataTable();
dt.Columns.Add("C1", typeof(byte[]));
dt.PrimaryKey = new DataColumn[] {dt.Columns["C1"]};
dt.Rows.Add(new object[] {b1});
dt.Rows.Add(new object[] {b2});
This code throws the exception shown below. Does anyone know why?
Unhandled Exception: System.Data.ConstraintException: Column 'C1' is
constrained
to be unique. Value 'System.Byte[]' is already present.
at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32
pos)
at System.Data.DataRowCollection.Add(Object[] values)
at ConsoleApplication1.Class1.Main(String[] args) in d:\projects
development\
c#\test\consoleapplication1\consoleapplication1\class1.cs:line 34
byte[] b1 = Guid.NewGuid().ToByteArray();
byte[] b2 = Guid.NewGuid().ToByteArray();
DataTable dt = new DataTable();
dt.Columns.Add("C1", typeof(byte[]));
dt.PrimaryKey = new DataColumn[] {dt.Columns["C1"]};
dt.Rows.Add(new object[] {b1});
dt.Rows.Add(new object[] {b2});
This code throws the exception shown below. Does anyone know why?
Unhandled Exception: System.Data.ConstraintException: Column 'C1' is
constrained
to be unique. Value 'System.Byte[]' is already present.
at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32
pos)
at System.Data.DataRowCollection.Add(Object[] values)
at ConsoleApplication1.Class1.Main(String[] args) in d:\projects
development\
c#\test\consoleapplication1\consoleapplication1\class1.cs:line 34