dcsimg
Results 1 to 8 of 8
  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    4

    Resolved [RESOLVED] Visual Basic Individual Record Help?

    I m using Visual Basic 2012, and my group is making this Patient System wherein you click on a patient s information on a datagrid and a different form shows up where you can list everytime they had a check up, the diagnoses and medication that was recommended for them, using a table in sql and whatnot. Problem is I just recently realized that if I put the information down for one patient it goes to all patients and our defense is on Monday, and as much as I would like to ask out teacher, he never taught us anything about visual basic and sql properly and just tells us to copy paste codes so we end up self studying just to understand them. I ve been checking everywhere I can, even downloading other patient systems but I still can t get the codes I need. My groupmates aren t helping at all either and expect me to do everything so they don t even bother with helping me look for the codes I need. Please help it will be greatly appreciated.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,130

    Re: Visual Basic Individual Record Help?

    Well, there's not much in this question to go on. Usually, when we get a question like "I change one item and they ALL change", it means that the issue has to do with people not understanding how reference types work such that they are entangling things. Beyond that, you'd have to show us some code, but it sounds like you probably have a whole lot more code than that which is useful. I would say that the code to start with is that code where you save the data you have entered for the one patient.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    4

    Re: Visual Basic Individual Record Help?

    Quote Originally Posted by Shaggy Hiker View Post
    Well, there's not much in this question to go on. Usually, when we get a question like "I change one item and they ALL change", it means that the issue has to do with people not understanding how reference types work such that they are entangling things. Beyond that, you'd have to show us some code, but it sounds like you probably have a whole lot more code than that which is useful. I would say that the code to start with is that code where you save the data you have entered for the one patient.

    StrSQL = "INSERT INTO TBLCheckUp (Date, Diagnosis, Medication) VALUES ('" & DTP.Text & "','" & TxtD.Text & "','" & TxtM.Text & "')"

    InsertDataToTable(StrSQL)
    MsgBox("Successfully Added!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Record")
    LoadRecord()

    this is honestly all i have for the save code

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,130

    Re: Visual Basic Individual Record Help?

    That wasn't quite what I was asking for, but it sure seems to at least partially answer the question. You are inserting three fields into a table. Those three are date, diagnosis, and medication....but for whom? There isn't anything that would identify the patient being inserted, so how would you know that information goes with any particular patient?

    I might as well also add that you really need to be using parameters rather than concatenating user supplied information directly into the query string. That concatenation leaves the query open to SQL injection exploits, which parameterized queries would prevent. That has nothing to do with the question at hand, though.
    My usual boring signature: Nothing

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    39,850

    Re: Visual Basic Individual Record Help?

    For further explanation of why you should be using parameters (and links to code examples), see the article Why should I use Parameters instead of putting values into my SQL string? from our Database Development FAQs/Tutorials (at the top of the Database Development forum).

    Your teacher probably wouldn't expect it tho, so don't worry too much about getting it done in this situation, but it's worth remembering for the future.

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    4

    Re: Visual Basic Individual Record Help?

    I just realized after re reading when i woke up that one of my problems was the referencing. I just sorta assumed that when i double clicked on a record in the list view that had all the patient's info like name and stuff, that it would've assigned the form to that patient and all. I do have IDs for the patients that are auto-incremented if that would work to identify which patient, though I don't know how to reference it for the table that has the three fields that I showed.

    I will keep the parameter thing in mind and self study it for after monday or so.

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    39,850

    Re: Visual Basic Individual Record Help?

    Add a PatientID field to TBLCheckUp, which stores the relevant value from the patients info (which you would need to pass from the first form).

    Then whenever you are showing information from TBLCheckUp, use a Where clause that limits it to the PatientID
    (eg: SELECT * FROM TBLCheckUp WHERE PatientID =123 ) .

  8. #8

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    4

    Re: Visual Basic Individual Record Help?

    Thank you both so much for your help! You're lifesavers!

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


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.