M
marc
I am getting the following error when running this sample code on .Net Framework 1.1, but this runs fine with .Net Framework 1.0. I have highlighted (in red) the line of code that the exception is coming from. Any ideas?:
"A column named 'address' already belongs to this DataTable: cannot set a nested table name to the same name."
Private Sub Test()
Dim ods As DataSet
Dim sXml As String
Dim oParentCol As DataColumn
Dim oChildCol As DataColumn
Dim oRelation As DataRelation
Dim oStrReader As StringReader
Try
ods = New DataSet
sXml = "<root><person id=""1"" name=""bob""><address personid=""1"" street=""123 Main Street"" /></person></root>"
oStrReader = New StringReader(sXml)
ods.ReadXml(oStrReader, XmlReadMode.InferSchema)
ods.Relations.Remove("person_address")
oParentCol = ods.Tables("person").Columns("id")
oChildCol = ods.Tables("address").Columns("personid")
oRelation = New DataRelation("person_address", oParentCol, oChildCol, True)
oRelation.Nested = True
ods.Relations.Add(oRelation)
Catch ex As Exception
TextBox1.Text = ex.Message
End Try
End Sub
"A column named 'address' already belongs to this DataTable: cannot set a nested table name to the same name."
Private Sub Test()
Dim ods As DataSet
Dim sXml As String
Dim oParentCol As DataColumn
Dim oChildCol As DataColumn
Dim oRelation As DataRelation
Dim oStrReader As StringReader
Try
ods = New DataSet
sXml = "<root><person id=""1"" name=""bob""><address personid=""1"" street=""123 Main Street"" /></person></root>"
oStrReader = New StringReader(sXml)
ods.ReadXml(oStrReader, XmlReadMode.InferSchema)
ods.Relations.Remove("person_address")
oParentCol = ods.Tables("person").Columns("id")
oChildCol = ods.Tables("address").Columns("personid")
oRelation = New DataRelation("person_address", oParentCol, oChildCol, True)
oRelation.Nested = True
ods.Relations.Add(oRelation)
Catch ex As Exception
TextBox1.Text = ex.Message
End Try
End Sub