Showing form information from a view

Hello experts. I have a view that contains a bunch of calculations. For example a small part of the code is listed below.

SELECT     dbo.tbl_Employee.Department, dbo.tbl_Employee.EmployeeNumber, dbo.tbl_Employee.FirstName, dbo.tbl_Employee.LastName,
                      ROUND((CASE WHEN [Supp Dent Enrolled] = 'True' THEN (CASE WHEN ([Supp Dent] = 8.08) THEN (16.14 / 160) WHEN ([Supp Dent] = 24.96) THEN (16.16 / 160)
                      WHEN ([Supp Dent] = 24.72) THEN (16.16 / 160) WHEN ([Supp Dent] = 44.61) THEN (16.16 / 160) ELSE (0) END) ELSE 0 END), 4) AS SuppDental,
                      ROUND((CASE WHEN [Supp Vision Enrolled] = 'True' THEN (2.54 / 160) ELSE 0 END), 4) AS SuppVision, (CASE WHEN ([HDHP Enrolled] = 1) THEN (([HDHP Amt] / 12)
                      / 160) ELSE (0) END)
For now lets focus on Supp Dent = 8.08 and Supp Den = 24.96.

What I am looking to do is create some sort of admin screen in vb.net that allows me to view these figures and change them when needed thus updating the view (right now I am going into the view directly to update) How do I go about searching the statement to get the dollar amounts appear on the front end of my admin screen? I hope this makes sense. If not I attached a crude mock up.
example.docx
DJ PAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can directly update the table using standard SQLConnection and SQLCommand methods:

Using con As New SQLConnection(YourConnectionSTring)
  con.Open
  Using cmd As New SQLCommand
    cmd.Connection = con
    cmd.CommandText = "UPDATE YourView SET SomeField=" & YourTextboxName.Value & " WHERE SomeOtherField=" & SomeOtherTextbox.Value
    cmd.ExecuteNonQuery
  End Using
End Using

Of course, you'd have to know the Primary or Secondary key of the table you're updating (which would be the SomeOtherField item).
DJ PAuthor Commented:
I'm afraid I'm not understanding how that gets me to display the dollar amounts in a form from the sql code I posted.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I thought you wanted to update the view after viewing the information on your form, and I assumed you already were viewing that data.

You can bind your form to the view to different controls. For example, here's how to bind it to a DataGridView:

https://docs.microsoft.com/en-us/dotnet/framework/winforms/controls/displaying-data-in-the-windows-forms-datagridview-control

Personally, I just grab the data from the database and handle the data display myself, either by setting the .Text value of textboxes, the Datasource of a combo or datagridview, etc.
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

DJ PAuthor Commented:
I'll do some reading per your link. I still cant make the connection on how to display the value in the code on a form
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
If you do it entirely manual, you'd just open the connection and command object, retrieve the data from the database, and then write the data into the textboxes of a form (assuming you're using textboxes, of course).

Using con As New SQLConnection(YourConnectionSTring)
  con.Open
  Using cmd As New SQLCommand
    cmd.Connection = con
    cmd.CommandText = "SELECT * FROM SomeTable WHERE SomeField=SomeValue"
    cmd.ExecuteNonQuery
    Using dt As New Datatable
      dt.Load(cmd.ExecuteReader)
      If dt.Rows.Count > 0 Then
        YourTextbox.Text = dt.Rows(0).Item("Field1")
        YourTextbox2.Text = dt.Rows(0).Item("Field2")
        ... and so on
      End If
    End Using
  End Using
End Using

You can also bind a form to a datasource. I don't do that, so couldn't really give you any guidance, but there are many, many tutorials that show how to do this.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DJ PAuthor Commented:
Ok so when looking at this portion of my code:

 ROUND((CASE WHEN [Supp Dent Enrolled] = 'True' THEN (CASE WHEN ([Supp Dent] = 8.08) THEN (16.14 / 160) WHEN ([Supp Dent] = 24.96) THEN (16.16 / 160)

Notice there can be two different amounts for Supp Dent. How do I represent this on my form. Sorry but I'm still a bit lost.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.