Click here to Skip to main content
15,925,255 members
Home / Discussions / C#
   

C#

 
AnswerRe: variables not being maintained in Visual C# 2008 Express Edition between two paint event handlers Pin
N a v a n e e t h26-Aug-09 15:39
N a v a n e e t h26-Aug-09 15:39 
GeneralRe: variables not being maintained in Visual C# 2008 Express Edition between two paint event handlers Pin
Christian Graus26-Aug-09 15:57
protectorChristian Graus26-Aug-09 15:57 
GeneralRe: variables not being maintained in Visual C# 2008 Express Edition between two paint event handlers Pin
N a v a n e e t h26-Aug-09 16:06
N a v a n e e t h26-Aug-09 16:06 
GeneralRe: variables not being maintained in Visual C# 2008 Express Edition between two paint event handlers Pin
Christian Graus26-Aug-09 16:18
protectorChristian Graus26-Aug-09 16:18 
GeneralRe: variables not being maintained in Visual C# 2008 Express Edition between two paint event handlers Pin
Jim Darrah27-Aug-09 4:46
Jim Darrah27-Aug-09 4:46 
QuestionKeep application settings on version change Pin
souren7726-Aug-09 14:09
souren7726-Aug-09 14:09 
AnswerRe: Keep application settings on version change Pin
Henry Minute26-Aug-09 14:41
Henry Minute26-Aug-09 14:41 
QuestionTyped Dataset replacing existing relationship for dynamic one throws: The row doesn't belong to the same DataSet as this relation [modified] Pin
Nohcs77726-Aug-09 13:53
Nohcs77726-Aug-09 13:53 
I have built a typed dataset which is Filled by SqlDataAdapter. The dataset has two tables (parent and child) with relationship using multiple columns (composite). The end objective is to replace this relationship with a dynamically generated one as some of the columns for both the parent and child table will be added at runtime and will be used as part of the relationship. The typed dataset has expressions defined, requiring me to have a relationship defined in advance.

The tests I have done ignores the dynamic columns and has fixed ones defined on the typed dataset that match the resultant query/recordset. The code replaces the existing relationship with an _exact_ copy using the same columns and relationship name as before (even having the parent/child relationship columns in the same order). The swap works fine but when I get to fill the dataset it throws the following exception:

<br />
System.ArgumentException: The row doesn't belong to the same DataSet as this relation.<br />
	at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32 pos, Boolean fireEvent)<br />
	at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32 pos)<br />
	at System.Data.DataTable.AddRow(DataRow row, Int32 proposedID)<br />
	at System.Data.DataTable.AddRow(DataRow row) .. blah blah blah<br />

The only difference I can tell between the old relationship and the new is their HashCode (obviously) and that the old relationship still has a reference to the parent and child tables (as MS likes bi-directional dependencies).

Puedo Code:
<br />
var dataSet = new MyDataSet();<br />
var parentTable = dataSet.Parent;<br />
var childTable = dataSet.Child;<br />
<br />
var relationshipName = "myrelationshipname";<br />
var oldRelationship = dataSet.Relations[relationshipName];<br />
<br />
dataSet.Relations.Remove(oldRelationship);<br />
<br />
//have to create these columns again because a column can't be a part of two different relationships ... :/<br />
var parentColumns = new List<DataColumn>();<br />
var childColumns = new List<DataColumn>();<br />
<br />
parentColumns.Add(parentTable.Columns["Column1"]);<br />
parentColumns.Add(parentTable.Columns["Column2"]);<br />
<br />
childColumns.Add(childTable.Columns["Column1"]);<br />
childColumns.Add(childTable.Columns["Column2"]);<br />
<br />
dataSet.Relations.Add(relationshipName, parentColumns.ToArray(), childColumns.ToArray(), false);<br />
<br />
this.FunctionToFillDataSet(dataSet, query);<br />


The above (real) code works fine if I don't remove / add the relationship.

The Original Relationship is setup for "Relation only" and not "constraints". When I add the new relationship, I use the overload to disable constraints ... DataSet.Relations.Add(relationshipName, parentcolumns[], childcolumns[], false) which I take as the same as "Relation only" from the first relationship.

I have searched all over trying to find someone with this problem. Most reference not adding the relationship which is clearly not the case here.

I'm on a strict schedule and having to go to my alternative will mean me having to drop the typed dataset all together and create my expressions and columns completely at runtime which I'd rather not do. We're a .net 2.0 environment. Development is under VS2008.

Any help would be greatly appreciated.

Thanks.

modified on Wednesday, August 26, 2009 8:44 PM

QuestionSQLCE C# Not Selecting New Records Pin
hobbsieoz26-Aug-09 11:11
hobbsieoz26-Aug-09 11:11 
QuestionClickOnce Update Problem Pin
MWRivera26-Aug-09 10:46
MWRivera26-Aug-09 10:46 
AnswerCross post Pin
Not Active26-Aug-09 10:58
mentorNot Active26-Aug-09 10:58 
QuestionUdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permitted PinPopular
zafersavas26-Aug-09 10:10
zafersavas26-Aug-09 10:10 
AnswerRe: UdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permitted Pin
stancrm26-Aug-09 13:05
stancrm26-Aug-09 13:05 
AnswerRe: UdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permitted Pin
N a v a n e e t h26-Aug-09 15:47
N a v a n e e t h26-Aug-09 15:47 
QuestionSpecial character ` in Visual Studio generated queries and how to remove it Pin
prg191226-Aug-09 9:58
prg191226-Aug-09 9:58 
AnswerRe: Special character ` in Visual Studio generated queries and how to remove it Pin
N a v a n e e t h26-Aug-09 15:49
N a v a n e e t h26-Aug-09 15:49 
GeneralRe: Special character ` in Visual Studio generated queries and how to remove it Pin
prg191227-Aug-09 11:15
prg191227-Aug-09 11:15 
QuestionC# Messenger Pin
I Believe In GOD26-Aug-09 9:51
I Believe In GOD26-Aug-09 9:51 
AnswerRe: C# Messenger Pin
DaveyM6926-Aug-09 10:11
professionalDaveyM6926-Aug-09 10:11 
GeneralRe: C# Messenger Pin
I Believe In GOD26-Aug-09 12:13
I Believe In GOD26-Aug-09 12:13 
GeneralRe: C# Messenger Pin
harold aptroot26-Aug-09 10:22
harold aptroot26-Aug-09 10:22 
GeneralRe: C# Messenger Pin
I Believe In GOD26-Aug-09 12:17
I Believe In GOD26-Aug-09 12:17 
GeneralRe: C# Messenger Pin
harold aptroot26-Aug-09 12:47
harold aptroot26-Aug-09 12:47 
AnswerRe: C# Messenger Pin
Patrick Eckler26-Aug-09 12:03
Patrick Eckler26-Aug-09 12:03 
GeneralRe: C# Messenger Pin
harold aptroot26-Aug-09 12:10
harold aptroot26-Aug-09 12:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.