Link to home
Start Free TrialLog in
Avatar of jekky_rocky
jekky_rocky

asked on

How do I execute a SQL UPDATE command in VB

I'm sorry to say that I'm a complete noob when it comes to programing and I am at a complete loss as to how to get this to work.

I have been tasked with writting a program that will simply update a database field with the click of a radio button.  There will be 5 radio buttons and when the first button is clicked (as well as the 'update' button below)  I need it to execute an UPDATE query to the field with a '1'.  The second button, when clicked, should UPDATE the field with a '2' and so on and so forth up to 5.  Also I have it update the PictureBox with a new image depending upon which RadioButton I click.

I can see the db through Data Connections.  I've also created a StoredProcedure, but can not, due to a lack of knowledge, get it to execute with a RadioButton click though at this point I don't think I want to use a SProc right now.

I currently am using Visual Studio 2008, Visual Basic and have a database called 'defcon' on a SQL2005 server called DEV\SQL2005.  There is a Table called 'Level' and a field named 'defcon'.  I've attached the code that I have so far.

Any help would be appreciated!
Public Class Form1
    Dim SetLevel As String = "Site Availability Level Changed"
 
    Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
 
    End Sub
 
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
 
    End Sub
 
    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        PictureBox1.Image = Image.FromFile(My.Computer.FileSystem.SpecialDirectories.MyPictures & "pic1.jpg")
 
    End Sub
 
    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        PictureBox1.Image = Image.FromFile(My.Computer.FileSystem.SpecialDirectories.MyPictures & "pic2.jpg")
    End Sub
 
    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        PictureBox1.Image = Image.FromFile(My.Computer.FileSystem.SpecialDirectories.MyPictures & "pic3.jpg")
    End Sub
 
    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        PictureBox1.Image = Image.FromFile(My.Computer.FileSystem.SpecialDirectories.MyPictures & "pic4.jpg")
    End Sub
 
    Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
        PictureBox1.Image = Image.FromFile(My.Computer.FileSystem.SpecialDirectories.MyPictures & "pic5.jpg")
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox(SetLevel)
    End Sub
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
    End Sub
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mezillinu
Mezillinu
Flag of Malta image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jekky_rocky
jekky_rocky

ASKER

Thanks guys.  I'll take another stab at it and see how it goes.  I have a feeling I might have to come back for some more hand holding.