Results 1 to 5 of 5

Thread: Advice needed with developing database driven application

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2012
    Posts
    75

    Advice needed with developing database driven application

    Hello!

    I am developing an application for my employer. I am not a programmer but I do it as a hobby.
    The story is as follows: we have a store that sells lawn tractors and riders. Every lawn tractor has a serial number, product code etc. I am trying to make a database driven application that stores serial number, product code and other data. I know how to do it with access database and how to add search functions and so on with detail view and grid view. But the thing is that I know how to do it when a customer buys only 1 product. How should I design a database or the application when a customer buys more than 1 machine, let's say 10 for example? Should I do 10 independent databases and link them somehow to the customer? For example: a database (only)with customers data, then a database for his/her purchased machine nr. 1 and then a database for purchased machine nr. 2 and so on.

    What is the most simple solution to this problem. Help me out, I am all out of ideas.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Advice needed with developing database driven application

    Absolutely not. You have one and only one database regardless. The whole point of a database is to relate the tables it contains. You would have one table for the stock items, one for the customers, one for the purchases and whatever else is appropriate. It's all in the one database and you have relations between the appropriate tables. For instance, the purchase table will contain the ID from the customer table to identify the customer who made the purchase. There would also be a purchase item table containing an ID from the purchase table, so a single purchase can include multiple stock items. Each purchase item would include an ID from the stock table to identify what was purchased.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2012
    Posts
    75

    Re: Advice needed with developing database driven application

    Thanks alot!

    I think your advice has pointed me to the right direction. I'll start testing and if some further questions come up I'll post them here.
    Cheers!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2012
    Posts
    75

    Re: Advice needed with developing database driven application

    Hi again!

    New problem has come up. I have 2 tables that are related to each other: Client table and Product table. They are related to each other with Client ID.
    I have designed my application to display data in textboxes and divided textboxes in to 2 groupboxes "Client" and "Product". Client group has textboxes with client data and Product group has textboxes with product data.
    I added 2 buttons: "Previous" and "Next" and made them work with following code:

    Private Sub btnNext_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btnNext.Click
    BindingContext(Dataset1, "Product").Position = BindingContext(Dataset1, "Product").Position + 1
    End Sub

    Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
    BindingContext(Dataset1, "Product").Position = BindingContext(Dataset1,"Product").Position -1

    End Sub


    Now the problem is that it navigates through all data. But what I need is that these buttons will navigate only through product data that has the same Client ID.
    Last edited by lkallas; Oct 10th, 2012 at 01:52 AM.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Advice needed with developing database driven application

    Follow the CodeBank link in my signature and check out my thread on Master/Detail Data-Binding. That will show you how to bind two DataTables in a DataSet with a DataRelation between them to a pair of BindingSources in a master/detail (aka parent/child) configuration. You can then bind the BindingSources to your controls. That has the added advantage of allowing you to simply call MoveNext or MovePrevious on the appropriate BindingSource to navigate the data. I'm not 100% sure but I think that that will also account for the situation where you try to navigate past the beginning or end of the list, which I don't think your current code does.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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