M
Mario Acevedo-Bengoechea
I have two tables, Students and Citizenship. The tables
are related by the Citizenship.CitiNum as the Primary Key
table and Students.Citizenship as the Child. Both are
defined in SQL Server 2000 as tinyint.
Dim StAdapter As SqlDataAdapter = Nothing
sql = "SELECT * FROM Citizenship; SELECT * FROM
Students"
conn = New SqlConnection
conn.ConnectionString = ConnectionString
conn.Open()
StAdapter = New SqlDataAdapter(sql, conn)
StDS = New DataSet("StData")
StAdapter.Fill(StDS, "Citizenship")
StAdapter.Fill(StDS, "Students")
Dim ParentCol As DataColumn = New DataColumn
Dim ChildCol As DataColumn = New DataColumn
ChildCol = StDS.Tables("Students").Columns
("Citizenship")
ParentCol = StDS.Tables("Citizenship").Columns
("CitiNum")
Dim StudentToCitizen As DataRelation = New
DataRelation("St2Cit", ParentCol, ChildCol, True)
StDS.Relations.Add(StudentToCitizen)
When running the code I get that the fields are not of
the same data type. When I check the ChildCom and
ParentCol in the watch windows I see that the system is
bringing Students.Citizenship as System.String instead of
System.Byte. The ParentCol, however is being brought in
as System.Byte without any problems. I tried loading the
schema using:
StDataAdapter.fillschema(StDs.Tables
("Students"),SchemaType.Mapped)
StDataAdapter.fillschema(StDs.Tables
("Citizenship"),SchemaType.Mapped)
I also tried SchemaType.Source but did not work either.
I have no clue of what is going on and help will be
appreciated.
Thank you,
Mario Acevedo-Bengoechea
are related by the Citizenship.CitiNum as the Primary Key
table and Students.Citizenship as the Child. Both are
defined in SQL Server 2000 as tinyint.
Dim StAdapter As SqlDataAdapter = Nothing
sql = "SELECT * FROM Citizenship; SELECT * FROM
Students"
conn = New SqlConnection
conn.ConnectionString = ConnectionString
conn.Open()
StAdapter = New SqlDataAdapter(sql, conn)
StDS = New DataSet("StData")
StAdapter.Fill(StDS, "Citizenship")
StAdapter.Fill(StDS, "Students")
Dim ParentCol As DataColumn = New DataColumn
Dim ChildCol As DataColumn = New DataColumn
ChildCol = StDS.Tables("Students").Columns
("Citizenship")
ParentCol = StDS.Tables("Citizenship").Columns
("CitiNum")
Dim StudentToCitizen As DataRelation = New
DataRelation("St2Cit", ParentCol, ChildCol, True)
StDS.Relations.Add(StudentToCitizen)
When running the code I get that the fields are not of
the same data type. When I check the ChildCom and
ParentCol in the watch windows I see that the system is
bringing Students.Citizenship as System.String instead of
System.Byte. The ParentCol, however is being brought in
as System.Byte without any problems. I tried loading the
schema using:
StDataAdapter.fillschema(StDs.Tables
("Students"),SchemaType.Mapped)
StDataAdapter.fillschema(StDs.Tables
("Citizenship"),SchemaType.Mapped)
I also tried SchemaType.Source but did not work either.
I have no clue of what is going on and help will be
appreciated.
Thank you,
Mario Acevedo-Bengoechea