Click here to Skip to main content
15,896,606 members
Home / Discussions / C#
   

C#

 
AnswerRe: add dynamic number of radio buttons to a panel in C# Pin
SomeGuyThatIsMe19-May-08 3:26
SomeGuyThatIsMe19-May-08 3:26 
QuestionRe: add dynamic number of radio buttons to a panel in C# Pin
Knowledgestudent19-May-08 4:13
Knowledgestudent19-May-08 4:13 
AnswerRe: add dynamic number of radio buttons to a panel in C# Pin
SomeGuyThatIsMe19-May-08 4:22
SomeGuyThatIsMe19-May-08 4:22 
GeneralRe: add dynamic number of radio buttons to a panel in C# Pin
Knowledgestudent19-May-08 6:59
Knowledgestudent19-May-08 6:59 
GeneralRe: add dynamic number of radio buttons to a panel in C# Pin
SomeGuyThatIsMe19-May-08 7:02
SomeGuyThatIsMe19-May-08 7:02 
QuestionSend Parameters To Crystal Report... Pin
Harvey Saayman19-May-08 2:17
Harvey Saayman19-May-08 2:17 
AnswerRe: Send Parameters To Crystal Report... Pin
geekfromindia19-May-08 3:27
geekfromindia19-May-08 3:27 
QuestionDataset relations problem. Removing row exception! Pin
oscarderooij19-May-08 2:07
oscarderooij19-May-08 2:07 
Hi there,

After reading msdn, looking for answers in google and testing a lot of different things, I gave up and now I'm here hoping for an answer.

The Problem:
I'm having a big problem trying to delete a row from a DataTable wich is related to its father. The exception I'm receiving is "Null Reference exception" (or something like that, my visual studio isn't in english)

The structure:
DataSet dsData contains:
DataTable dtbClients -> PrimaryKey: 'MotherAccount'
DataTable dtbAccounts -> PrimaryKey: 'ClientName'
DataTable dtbProducts -> PrimaryKey: 'CodeProduct'

Wich are related like this:
dtbClientes -> dtbAccounts (through column 'MotherAccount')
dtbAccounts -> dtbProducts (through column 'ClientName')

The data:
In this specific case, dtbClients has only 1 client wich has 1 account (in dtbAccounts) with no products.

What am I tried to do:
First I tried to remove the client directly because I though that the cascade constraint automatically created when we make a relation would take care of deleting the associated row in dtbAccounts. But that didn't happend.

The application threw and Null Referenec exception, and the stackTrace pointed to a function with 'Cascade' in its name.

Question 1): Is it possible to fix this exception and make c# delete everything associated to the removed client?

Well, with this exception I quited trying to delete the client directly and tried something else.
This time I'm removing the account related to the client first, this way when deleting the client there would be no problems since there are no rows related to it (I've no problems deleting clients with no accounts associated).

The problem:
It gives me the same Null Reference exception when trying to delete the account first! And it doesn't have any product related to it. My guess is that somehow the parent row(client) is related to it, so I can't delete it.

Question 2): How do I delete this account?

Can anyone help me with this ?
I hope I was clear enough.

Oh, another thing,

What I'm trying to do over there is actually one part of a mergin process of 2 datatables.
Actually is not a merge, it is an update.

The old dataset will be updated to look exactly like the new one, wich means that new rows will be added, old rows will be updated and old rows will be removed.

Well, I've just discovered the DataSet.Merge(DataSet) function and it is quite usefull.
The problem is that it doesn't seem to remove old rows in the target dataset that are not in the (updated version) source dataset.

Is there a way to do this not manually? A function? A property? I don't know... something that would make the Merge function delete rows from the target dataset.

Thanks in advance!
Oscar
QuestionAccurate UDP connection Pin
Berlus19-May-08 2:03
Berlus19-May-08 2:03 
AnswerRe: Accurate UDP connection Pin
Mike Dimmick19-May-08 2:23
Mike Dimmick19-May-08 2:23 
GeneralRe: Accurate UDP connection Pin
Berlus20-May-08 19:03
Berlus20-May-08 19:03 
QuestionDictionary Values copy Pin
George_George19-May-08 2:02
George_George19-May-08 2:02 
AnswerRe: Dictionary Values copy Pin
J4amieC19-May-08 2:07
J4amieC19-May-08 2:07 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 2:13
George_George19-May-08 2:13 
GeneralRe: Dictionary Values copy Pin
J4amieC19-May-08 2:18
J4amieC19-May-08 2:18 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 2:22
George_George19-May-08 2:22 
GeneralRe: Dictionary Values copy Pin
J4amieC19-May-08 2:41
J4amieC19-May-08 2:41 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 2:49
George_George19-May-08 2:49 
GeneralRe: Dictionary Values copy Pin
J4amieC19-May-08 3:10
J4amieC19-May-08 3:10 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 3:18
George_George19-May-08 3:18 
AnswerRe: Dictionary Values copy Pin
leppie19-May-08 2:29
leppie19-May-08 2:29 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 2:34
George_George19-May-08 2:34 
GeneralRe: Dictionary Values copy Pin
J4amieC19-May-08 2:47
J4amieC19-May-08 2:47 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 2:52
George_George19-May-08 2:52 
GeneralRe: Dictionary Values copy Pin
leppie19-May-08 3:32
leppie19-May-08 3:32 

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.