troubleshooting Question

Failed to update and save Checkbox controls action to a field of SQL database table

Avatar of GaiaGia
GaiaGiaFlag for United States of America asked on
ASP.NETVisual Basic.NETMicrosoft SQL Server 2005
4 Comments2 Solutions450 ViewsLast Modified:
Hi Gurus,

my web app page has 3 checkbox and 1 text field, I need to submit values of these controls by the button control, and update a field in the SQL Server 2005 database, by matching a field called [File Number] .

I put my code below, no error when debugging, but no data saved in the data table as well.

Please advise.

 Protected Sub Button1AfterReadLetter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1AfterReadLetter.Click

        Dim Username2 As String = Request.QueryString("Val")

        Dim DBconn As New SqlClient.SqlConnection("Data Source=Myserver;Initial Catalog=MyDB;Integrated Security=True;")
        Dim DBcmd As New SqlClient.SqlCommand
        Dim DBAdap As New SqlClient.SqlDataAdapter
        Dim DS As New DataSet

            DBcmd = New SqlClient.SqlCommand("update MyTable set EnglishCheckbox =@eCheckbox where [File Number] = @File Number", DBconn)
            DBcmd = New SqlClient.SqlCommand("update MyTable  set SpanishCheckbox=@sCheckbox where [File Number] = @File Number", DBconn)
            DBcmd = New SqlClient.SqlCommand("update  MyTable  set OtherLanguageCBox=@oCheckbox where [File Number] = @File Number", DBconn)
            DBcmd = New SqlClient.SqlCommand("update MyTable set languageName=@LanguageName where [File Number] = @File Number", DBconn)

            DBcmd.Parameters.Add("@eCheckbox", SqlDbType.Char).Value = CheckBox1.Checked
            DBcmd.Parameters.Add("@sCheckbox", SqlDbType.Char).Value = CheckBox2.Checked
            DBcmd.Parameters.Add("@oCheckbox", SqlDbType.Char).Value = CheckBox3.Checked
            DBcmd.Parameters.Add("@LanguageName", SqlDbType.VarChar).Value = TextBox1.Text

        Catch exp As Exception
        End Try
        DBconn = Nothing

        Response.Redirect("WebForm2.aspx?val2=" + Username2)

    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros