typed datasets from an existing database

  • Thread starter Thread starter Samuel
  • Start date Start date
S

Samuel

Hello coders:

I'm trying to create a typed dataset from a Microsoft Access database. I
follow these steps (with visual studio 2003):

I add a new empty DataSet to the project (Project->Add New Item->Data Set).

I open the Server Explorer window and I create a new connection to my .mdb
database.

Then I drag the 'Tables' item under my connection to the dataset, and all
the tables are copied.

But thus the relations aren't copied, and the keys' names are incorrect, it
assigns new names to the keys like DataSet1KeyX, where X is a number.

I can't use DataAdapters to generate the typed dataset's schema because I
create DataAdapters manually by code, but also I don't know if using
DataAdapters would copy the relations and the keys correctly.

So, what's the way to generate a complete and correct dataset schema from an
existing database?

Thank you.
 
The relationships must be defined one way or another.
The dataadpater is only responsible for marshalling
data. The architecture of ADO.NET is built to do things
like load a bunch of datatables into a dataset from
Access and then use the dataset to put it back in an
Oracle/SQLServer/TakeYourPick database. Therefore, DB
specific objects like relationships, indexes etc aren't
handled per se by the DA (this is an oversimplification
but ignore that for a second).

ANyway, you can define your relationships using the
DataRelation object and it's pretty kewl. You can also
define all of your keys locally, as well indices.

I'll walk you through it if it will help.

Good Luck,

Bill

Cordially,

W.G. Ryan
(e-mail address removed)
www.knowdotnet.com
 
Back
Top