Help Query DB and Display-VBForums
Results 1 to 4 of 4

Thread: Help Query DB and Display

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    2

    Exclamation Help Query DB and Display

    hi guys i am a total newbie with vb6 can someone please help me with the code? ill give as give as much detail as i can.

    here it goes, im building a simple application that queries from the database if its existing or not. if existing it would display the information required found in the database if not a message box will display that it doesn't exist.

    here is a screenshot of the form i made


    the user will input the patient no. and press the enter key then the rest of the information will be displayed if the record exist.

    i have a database named "mdbCapz" with 4 tables "tblPatientFile", "tblImmuFile", "tblExamfile", and "tblVaccineFile".

    *Primary key

    tblPatientFile - FIELDS *PatNo, CName, FName, MName etc. <-Patient Info dispaly in caption
    tblImmuFile - FIELDS *PatNo, *VCode, Dosage. <-Immunization Info display in flexgrid
    tblExamfile - FIELDS *PatNo, Diag, Direct. <-Diagnosis Info display in flexgrid
    tblVaccineFile - FIELDS *PatNo, *VCode, Description. <-Immunization Info display in flexgrid.

    i hope you guys can help me because i dont even know where to start..

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    8,594

    Re: Help Query DB and Display

    How much do you know about working with databases from VB6?

    You data structure looks a bit off. You have PatNo as the primary key in all the tables which would likely be a problem. In the Patient file it makes total sense to use that as the primary key but not in any of the others as you will likely need a one to many realionship here. In other words 1 patient can have more than 1 immunization, more than 1 exam, more than 1 vaccine. You will need to setup a different primary key on these tables and allow duplicates of the PatNo in order for this to work in a real senario.

    To fetch the data you will need either a complex select query or 4 simple select queries. If you do not know how to do a select query and display the data then you should do a search for working with databases in VB6 and ADO

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    2

    Re: Help Query DB and Display

    Thanks for the reply DataMiser, i really dont know much working with database in vb6.
    also thanks for pointing out the primary key problem ill be changing therm.

    *Primary Key

    tblPatientFile - FIELDS *PFPatNo, CName, FName, MName etc. <-Patient Info dispaly in caption
    tblImmuFile - FIELDS *IMPatNo, *VCode, Dosage. <-Immunization Info display in flexgrid
    tblExamfile - FIELDS *EFPatNo, Diag, Direct. <-Diagnosis Info display in flexgrid
    tblVaccineFile - FIELDS *VFPatNo, *VCode, Description. <-Immunization Info display in flexgrid.

    is the data structure ok now? and can you help me with the code?
    how do i start querying the database to display the info needed?

    also please give me a link where i could easily understand how to work with databases in vb6 and ADO just to point me in the right direction. i tried googling it and read some results but i got more confused. i thought vb6 is easy i guess i was wrong. we will be using the application in our village health center, so all the help you guys give is much appreciated.

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    8,594

    Re: Help Query DB and Display

    It looks like you changed the name of the fields for PatNo. The name was not the issue. Your primary key needs to be something that is not duplicated within the table. You will likely need to repeat the PatNo in 3 of these tables so that is where the issue comes in.

    You should do a google search for database samples or tutorials to help you get started. There are lost of these all over the internet.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.