I need to create a data relation between two rows in two tables that were
designed poorly years ago. TableA has the ID Number Column as a varchar(50)
array, whereas TableB has the ID Number Column as an integer.
The tables are in production and have several other applications that rely
on them, so they can not simply be changed.
The code below does not work because they two columns are incompatible: -
// ID_Num is type nvarchar(50)
-
DataColumn dcParent
-
= m_dataSet.Tables[m_strTableA].Columns["ID_Num"];
-
// IDNUM is type int
-
DataColumn dcChild
-
= m_dataSet.Tables[m_strTableB].Columns["IDNUM"];
-
DataRelation dr
-
= new DataRelation("AtoB", dcParent, dcChild);
-
m_dataSet.Relations.Add(dr);
-
Can a DataRelation be be created with these two columns? 5 1205
Solved my question via a co-worker that knew a lot more about SQL than I did:
In my select clause, I added a cast to the 'int' variable.
After modifying my select statement, the code below works just fine!
"jp2msft" wrote:
I need to create a data relation between two rows in two tables that were
designed poorly years ago. TableA has the ID Number Column as a varchar(50)
array, whereas TableB has the ID Number Column as an integer.
The tables are in production and have several other applications that rely
on them, so they can not simply be changed.
The code below does not work because they two columns are incompatible: -
// ID_Num is type nvarchar(50)
-
DataColumn dcParent
-
= m_dataSet.Tables[m_strTableA].Columns["ID_Num"];
-
// IDNUM is type int
-
DataColumn dcChild
-
= m_dataSet.Tables[m_strTableB].Columns["IDNUM"];
-
DataRelation dr
-
= new DataRelation("AtoB", dcParent, dcChild);
-
m_dataSet.Relations.Add(dr);
-
Can a DataRelation be be created with these two columns?
On Jun 13, 2:31*pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
I need to create a data relation between two rows in two tables that were
designed poorly years ago. TableA has the ID Number Column as a varchar(50)
array, whereas TableB has the ID Number Column as an integer.
The tables are in production and have several other applications that rely
on them, so they can not simply be changed.
The code below does not work because they two columns are incompatible: -
* // ID_Num is type nvarchar(50)
-
* DataColumn dcParent
-
* * = m_dataSet.Tables[m_strTableA].Columns["ID_Num"];
-
* // IDNUM is type int
-
* DataColumn dcChild
-
* * = m_dataSet.Tables[m_strTableB].Columns["IDNUM"];
-
* DataRelation dr
-
* * = new DataRelation("AtoB", dcParent, dcChild);
-
* m_dataSet.Relations.Add(dr);
-
Can a DataRelation be be created with these two columns?
Why don't you add another column to one of the tables as the other's
table ID type
On Jun 13, 2:59*pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
Solved my question via a co-worker that knew a lot more about SQL than I did:
In my select clause, I added a cast to the 'int' variable.
After modifying my select statement, the code below works just fine!
"jp2msft" wrote:
I need to create a data relation between two rows in two tables that were
designed poorly years ago. TableA has the ID Number Column as a varchar(50)
array, whereas TableB has the ID Number Column as an integer.
The tables are in production and have several other applications that rely
on them, so they can not simply be changed.
The code below does not work because they two columns are incompatible: -
* // ID_Num is type nvarchar(50)
-
* DataColumn dcParent
-
* * = m_dataSet.Tables[m_strTableA].Columns["ID_Num"];
-
* // IDNUM is type int
-
* DataColumn dcChild
-
* * = m_dataSet.Tables[m_strTableB].Columns["IDNUM"];
-
* DataRelation dr
-
* * = new DataRelation("AtoB", dcParent, dcChild);
-
* m_dataSet.Relations.Add(dr);
-
Can a DataRelation be be created with these two columns?- Hide quoted text -
- Show quoted text -
Hi,
But then you are modifying the column, which was one of your
constrains.
I can't help the way the table was designed. :)
"Ignacio Machin ( .NET/ C# MVP )" wrote:
But then you are modifying the column, which was one of your
constrains.
Because the tables are in production and we have a lot of 3rd party companies
and their equipment tied into these tables. Modifying table designs often
causes their software to stop, and that stops production.
That's what happens when people write their SQL queries using "SELECT * FROM
TABLE". That wildcard can cause a lot of problems.
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Why don't you add another column to one of the tables as the other's
table ID type This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Les |
last post by:
I have a problem getting Dataset.WriteXml() to create a nested xml
realtionship. All I get is an inline xsd (all nodes are children of
the root). Documentation says to use...
|
by: Che |
last post by:
Greetings,
I am writing an application that uses an extendible XML file. in order
to validate that XML I use a main XSD and in additional - few more
extensions XSD's that uses the types in the...
|
by: Randy |
last post by:
I have two DataTables in a DataSet. I create a DataRelation between two
like-typed columns in the first and second tables, and it works exactly as
expected.
Unfortunately, the default behavior...
|
by: Fleckman |
last post by:
I have a DataSet with 14 DataTables and 18 Relationships that were defined
within Visual Studio .NET 2003. Everything looks OK in the visual development
environment, i.e. when I preview the DataSet...
|
by: George Durzi |
last post by:
I have a DataSet with 3 tables, and two DataRelations
dsSubs.Tables.TableName = "Subscriptions"
dsSubs.Tables.TableName = "AccountManagers"
dsSubs.Relations.Add
"AccountManagers_Subscriptions",...
|
by: Carlos Albert |
last post by:
Hello everybody,
I'm using some gridviews with datalists inside template columns.
Now, for each datalist I'm calling a method returning a dataset (depending
from a column from the gridview).
...
|
by: Born Bugler |
last post by:
What I'm actually talking about is, when you put the same class in different
assemblies, you get two different types. This is reasonable (if you would
call it) in most cases as it avoids possible...
|
by: =?Utf-8?B?cmFuZHkxMjAw?= |
last post by:
I'm working in Visual Studio 2005 Team Edition for Software Developers.
I have 3 tables defined in the DataSet Designer, and a DataRelation between
each table. The user sees a each of these...
|
by: Vajrala Narendra |
last post by:
hi all,
am working in asp.net
i am using two data entry screens for parent and child tables.
i heard that using datarelations we can achieve this using single screen.
is it ppossible? please...
|
by: tonytech08 |
last post by:
How valuable is it that class objects behave like built-in types? I
appears that the whole "constructor doesn't return a value because
they are called by the compiler" thing is to enable...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |