Relational Tables

Results 1 to 2 of 2

Thread: Relational Tables

  1. #1
    Join Date
    Dec 1969

    Default Relational Tables

    I am wondering if I am going about this in the right way.<BR><BR>I have a shop locator that represents several companies underneath one umbrella company. I need to associate each shop with the correct companies. As it stands now I have a relational table which contains company ID&#039;s and Dealer ID&#039;s. So I am at a point now where I want to be able to add and update my list of dealers. I run into the following problems/questions.<BR><BR>1. When I go to add a dealer and I want to associate it with the correct companies I find it problematic because I do not know the dealerID as it has not yet been dynamically added. So how is it I can get that ID returned to me after I add the dealer to the list so I can then insert that id along with the proper companyID&#039;s into the relational table.<BR><BR>2. When I want to update the list I need to update the relational table. I am assuming I would SELECT from the Relational table with the DealerID as a WHERE Clause and then update with conditional statements. This seems like a bit of a brute force way of doing it and I am wondering if there is a more elegant solution.<BR><BR>Overall I am wondering if this is the right way to structure everything in the first place.<BR><BR>Thanks you very much your help is greatly appreciated.

  2. #2
    Join Date
    Dec 1969

    Default RE: Relational Tables

    Hmmm, would need to see the structure to comment on what you are doing, but it does sound a little &#039;out there&#039;!.<BR><BR>I am assuming that you have a unique ID set against each new entry.<BR><BR>ie.<BR><BR>r.AddNew<BR>r("fld1") = something<BR>r("fld2") = something<BR>r("fld3") = something<BR>r("fld4") = something<BR>...<BR>...<BR>r.Update<BR>r.Close<BR> <BR>then add<BR><BR>s = "select @@identity as newid"<BR>r.Open s,connObj, blah, blah<BR>...<BR>...<BR>...<BR>newid now contains the unique id of the last inserted record<BR>...<BR><BR>Is this what you where after?<BR>

Posting Permissions

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