Results 1 to 6 of 6
  1. #1
    Join Date
    May 2005
    Posts
    23

    Unanswered: How to Populate table from Dropdown List?

    Hi,
    I have table (tbl_a) that get it values form three Dropdown List and the PK of this table is FK in different table(tbl_b).
    Since tbl_a get its values from three Dropdown List the number of rows in this table
    is limited to the number of combinations the three Dropdown List is offer (in any case the number of raws in that table will be final).
    Assuming tbl_a and tbl_b are both empty.

    The problem is that if i want to insert row to tbl_b i have to check first if there is a row that holds the
    values (or combination of values) i am getting from the Dropdown List in tbl_a .
    Then, if such row is exist i have to get the PK of that raw and insert it to tbl_b (as FK),
    if such row does not exist, i have to insert it and then get the PK of this row and insert it to tbl_b (as FK).

    In the end, tbl_a will have all the combination the three Dropdown List can offer so checking if raw exist in this table will not be necessary.

    In my opinion this is not effective way to do that.
    Can someone offer me better way to do it?

    Thanks

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    This is an interface issue, not a server issue. If you are using MS Access (or other VB related product), check out the "On Not In List" event of your combo box, and see the examples in Microsoft Help.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    May 2005
    Posts
    23
    I will make my post more clear.

    Assuming you have those tables:

    Tables Diagram

    tbl_car
    AppealId (PK),
    CustomerId (FK),
    DriverCode (FK),
    ClaimCode (FK),
    ExpansionCod (FK),
    CarType,
    CarProducer,
    CarYear,
    CarModel,
    InsurancePeriod,
    AppealDate

    tbl_customers
    CustomerId (PK),
    FirstName,
    LastName,
    Email,
    Telephone,
    Cellphone,
    Address,
    City,
    Birthdat e

    tbl_drivers
    DriverCode (PK),
    NumberOfDriver ,
    YoungerDriver ,
    NewDriver

    tbl_claims
    ClaimCode (PK),
    LastYear,
    SecondYear,
    ThirdYear

    tbl_expansions
    ExpansionCod (PK),
    DraggingService,
    CarReplacement,
    Windowpane


    What is the best (effective) way to insert row to those table,
    while the values for tbl_expansions ,tbl_claims and tbl_driver came from Dropdowns?

    I also will be happy if you will comment regarding the database design.

    thanks
    Attached Thumbnails Attached Thumbnails diagram.jpg  

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Again, you keep referring to drop-down lists. There are not drop-down lists built into sql server, as this is a function of the presentation layer. So you need code in your presentation layer to handle this. It is not a SQL Server question, and you should repost it in the appropriate forum.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  5. #5
    Join Date
    May 2005
    Posts
    23
    Ignore the dropdowns, i mention them only to emphasis that the tables are
    empty and that the values that can be insert are limited.

    How can you insert row(in effective way) to those tables , while you know that each of the columns in tbl_drivers, tbl_claims and tbl_expansions can get only one of three possible value?

    thanks

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Insert the record into tbl_car with the appropriate foreign key values from your lookup tables.
    I don't get what your problem is.
    "How can you insert row(in effective way) to those tables , while you know that each of the columns in tbl_drivers, tbl_claims and tbl_expansions can get only one of three possible value?"
    Huh?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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