Results 1 to 10 of 10

Thread: More than one table in MDB

  1. #1

    Thread Starter
    Lively Member rabhen's Avatar
    Join Date
    Dec 2001
    Location
    Derby, Derbyshire, UK
    Posts
    79

    Question More than one table in MDB

    Hi there, i hope someone can advise me,
    i am attempting to write a program that links to an access database which has more than one table in it, (3 to be exact) the book i am using only shows how to use one table, but i would like to know what i would need to do to use another table, on the same form, linked to the first table.
    I am using OleDbConnection, OleDbDataAdapter and DataTable (as described by the book) is there another way?
    Do i have to use DataSets? and if so, how do i use them...? (i tried using the Microsoft Help and came away more confused than before )


    R
    Last edited by rabhen; Jun 10th, 2003 at 09:23 AM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Is there any relation between them (tables)? and What do you want to do exactly with these tables ?

  3. #3

    Thread Starter
    Lively Member rabhen's Avatar
    Join Date
    Dec 2001
    Location
    Derby, Derbyshire, UK
    Posts
    79
    Hi Pirate,
    There is a relationship between all the tables, mainly the primary table (Problem) links to both the Action and Users Tables by referencing a Unique number.
    what i would like to do is take the code i have, which allows me to open and read the Problem table and see the matching record on the users table.

    R

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I'm not sure I understood what you are telling but if you want to have two(or more) tables into one dataset do the following .

    this will merge two tables into one ds :
    1- have two oledbadapters
    2-have two datacolumns .
    3-one datarelation which accepts the above datacolumns as paramters .
    4- add this relation obj to the dataset through relation.add method .

    Then , there you go , you have both tables in one dataset . Do whatever you want to do with it . Tell me if you are in troubles .

  5. #5

    Thread Starter
    Lively Member rabhen's Avatar
    Join Date
    Dec 2001
    Location
    Derby, Derbyshire, UK
    Posts
    79
    Thanks Pirate, That gave me a few pointers, as it was i found some info at Code Project..
    however i am now trying to find out how to show the fields of one record on a screen... Hmmm

    Thanks for your help

    R

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You mean this :

    Code:
    System.Data.DataSet ds=new DataSet();
    ds.ReadXml("data.xml");
    
    for (int ii =0;ii<ds.Tables[0].Rows.Count-1;ii++)
    {
    this.listBox1.Items.Add(ds.Tables[ii].Rows[ii]);
    }

  7. #7

    Thread Starter
    Lively Member rabhen's Avatar
    Join Date
    Dec 2001
    Location
    Derby, Derbyshire, UK
    Posts
    79
    That is similar to what i am looking for, however i am not using a listbox, i am using normal text boxes, because the user will eventually be able to enter and edit data in the form, so i want them to only see one record at a time, so i need to populate each text box sepparately (sp?)

    Thanks for the listbox thing though, i will use that for the next stage of my program..

    it it better to use XML based forms with C# then..?

    R

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by rabhen

    it it better to use XML based forms with C# then..?
    R
    I don't think but I found XML File in the MyDocument and I liked to work with it .

  9. #9

    Thread Starter
    Lively Member rabhen's Avatar
    Join Date
    Dec 2001
    Location
    Derby, Derbyshire, UK
    Posts
    79
    i will have a look at the XML stuff then, see there is a way of producing what i want that way..
    Thanks for you help so far Pirate!

    R

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width