ADO.NET and Relational Data problem.....how start?

gicio

Well-known member
Joined
Aug 26, 2002
Messages
90
Hi!

I will write an application that work with an Access DB.
My database have 5 table that have a relationship to each other.

tables in DB:

Table 1: Car: CarID, Manufactore, Colour, Hp, Displacement, Price, Model
Table 2: SaleContractCar: SaleContractID, CarID
Table 3: SaleContract: SaleContractID, CustomerID, Date
Table 4: Customer: CustomerID, CustomerAddressID, Tel, Age, SeconCar, Name
Table 5: CustomerAddress: CustomerAddressID, Street, StreetNr, Zip, City

relationship between the tables:

Table 1 (one to more) Table 2
Table 2 (more to one) Table 3
Table 3 (more to one) Table 4
Table 4 (more to one) Table 5


at this moment I dont know how to start.

should I first load all tables I one DataSet?
and create for each table a DataTable?

how I should start?
how I should write an update SQL statement for this DataSet?

where I can find some sample application that work with Relational Data?


thx!!
 
I think Id use the wizard in VS.NET to create a typed dataset with all the tables in it for now. I wouldnt actually use this, but itll give a good idea of where to go from there. This page has a tutorial on Data and ADO.NET -> Working with Relational Data that should prove useful.
http://samples.gotdotnet.com/quickstart/howto/

I guess the jury is still out on how exactly people are using datasets in their apps and what the best practices are but Im starting to not use typed datasets and doing more of a pseudo-typed dataset, similiar to Duwamish. Of course this involves manually maintaining them but its worked well so far without the bloat of typed datasets. This allows you to only build the datatables you need at any given time too.
 
thanks!!


another question: Is it possible to select all data from DB with one statement and fill the DataSet?


gicio
 
Sure. This is especially easy if your database contains only one table;)

On a serious note, I cant imagine why youd want to do that. I dont know if theres a quick way to do it either, but I doubt it. Ill look closer if you have a convincing reason why youd want to do it.:)
 
I know you can do this in SQL Server with no problem. When you create your DataAdapters sql string, you just put in multiple SELECT statements or use a proc that has multiple SELECT statements. Im not sure if Access will allow this or not, but I think it will. Id give it a try - start with two tables and separate each SELECT with a semicolon (I think thats what Access uses).

SELECT CarID, Manufactore, Colour, Hp, Displacement, Price, Mode FROM Car; SELECT SaleContractID, CarID FROM SaleContractCar

Let me know if this doesnt work - I dont have Access installed right now, but I can get it on pretty quick.

-Nerseus
 
Back
Top