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

This is a discussion on ADO.NET and Relational Data problem.....how start? within the C# Programming forums, part of the General Programming Boards category; Hi! I will write an application that work with an Access DB. My database have 5 table that have a ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    101

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

    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 don't 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!!

  2. #2
    Rog
    Rog is offline
    Registered User
    Join Date
    Jan 2003
    Posts
    78
    It think it depends on what type of application you are writing, and what the program does. For example, are you writing a Web or Windows application?

    You are on the right track about DataSet. You don't need to load the entire database at all times, though. ADO.NET is designed for disconnected access, where you connect each time you query the database.... this works well for many stateless Web applications. Inside your program you will usually write member functions inwhich you will connect to the database and run queries to select, insert, update, or delete specific rows. It's really tough to generalize about it without knowing more about what you want to do.

    Start putting your logic together and post questions/code when you get stuck.

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    To get you started, this is the code to query a database and return just one table. You don't actually need the DataSet if you're just quering for normal data. As for relations, as I haven't done those yet, you might need to get a whole bunch of tables in a DataSet and you should look at the class System.Data.DataRelation. Good luck!

    Code:
    // create a connection to the server
    DataTable data;
    SqlConnection sqlconnection=new SqlConnection("<connection string>");
    
    // get the data
    sqlconnection.Open();
    data=new DataTable("<table name>");
    new SqlDataAdapter(query, sqlconnection).Fill(data);
    sqlconnection.Close();

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Mapping and Moving Relationships
    By Mario F. in forum Tech Board
    Replies: 7
    Last Post: 12-14-2006, 10:32 AM
  2. problem with relational operators
    By manoncampus in forum C++ Programming
    Replies: 10
    Last Post: 12-13-2005, 07:15 PM
  3. problem with relational operators
    By Sargnagel in forum C Programming
    Replies: 4
    Last Post: 10-13-2002, 10:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21