Converting Untyped Datasets into Strongly Typed Datasets with Foreign Key Constraints.

A

Alex Berryhill

Hi all,

This might seem naive, but been spending quite a bit of time on this;
was wondering if anyone could help me out here.

My problem is as follows:- I have an (MS Data Access Applications
Blocks-generated) untyped dataset that has data grabbed from the
database. I need to convert it into (an already defined) strongly
typed dataset, but one with a foreign key constraint enabled in it
(that is, it has two tables). Any simple way of doing this?

I had, previously, done that for single-table-datasets by declaring
the table name (of the untyped dataset) to be the same as that of its
strongly typed equivalent, and then doing a Merge() for both. I,
obviously, can't do the same thing over here, mainly because of the,
you guessed it, foreign key constraint.

Any help on this would be deeply appreciated.

TIA!
Alex B.
 
M

Miha Markic [MVP C#]

Hi Alex,

Alex Berryhill said:
Hi all,

This might seem naive, but been spending quite a bit of time on this;
was wondering if anyone could help me out here.

My problem is as follows:- I have an (MS Data Access Applications
Blocks-generated) untyped dataset that has data grabbed from the
database. I need to convert it into (an already defined) strongly
typed dataset, but one with a foreign key constraint enabled in it
(that is, it has two tables). Any simple way of doing this?

I had, previously, done that for single-table-datasets by declaring
the table name (of the untyped dataset) to be the same as that of its
strongly typed equivalent, and then doing a Merge() for both. I,
obviously, can't do the same thing over here, mainly because of the,
you guessed it, foreign key constraint.

Why not?
I mean if you want to have a relation between table it won't let you have
"bad" data because relation enforces consistency.
 
A

Alex Berryhill

Why not?
I mean if you want to have a relation between table it won't let you have
"bad" data because relation enforces consistency.

What I meant to say was that I was getting an error if I did that.

Fixed it now; all I needed to do was to turn .EnforceConstraints to
false before doing a .Merge()

Thanks anyway for your response!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top