Hello. I've coded in VB before, but I've only started mixing it with asp. I'm trying to make a scoring website for an annual school competition. I have it based on one main page, and one database. When the page loads, I have it reading all the values into the textboxes, and when the user hits the save button, it should filter through all the textboxes, and update the database with the new values. Only problem is that when I update the database, it doesn't read the new values, it reads the textboxes as still having the same values in them. I'm including the code for the button sub procedure.

Dim path As String = "file name and location"
        Dim sqlString As String = ""
        Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & path & ";"

        Dim contestants2() As String = {"Burke", "Catanzaro", "Conte", "Cuddey", "Elaroussi", "Langan", "Lawrence", "McAndrew", "Olesinski", "Parks", "Price", "Torres"}

        Dim FormalBoxes2() As Integer = {Formalware1.Text, Formalware2.Text, Formalware3.Text, Formalware4.Text, Formalware5.Text, Formalware6.Text, Formalware7.Text, Formalware8.Text, Formalware9.Text, Formalware10.Text, Formalware11.Text, Formalware12.Text}
        Dim TalentBoxes2() As Integer = {Talent1.Text, Talent2.Text, Talent3.Text, Talent4.Text, Talent5.Text, Talent6.Text, Talent7.Text, Talent8.Text, Talent9.Text, Talent10.Text, Talent11.Text, Talent12.Text}
        Dim CIBoxes2() As Integer = {CI1.Text, CI2.Text, CI3.Text, CI4.Text, CI5.Text, CI6.Text, CI7.Text, CI8.Text, CI9.Text, CI10.Text, CI11.Text, CI12.Text}
        Dim UnannouncedBoxes2() As Integer = {Unannounced1.Text, Unannounced2.Text, Unannounced3.Text, Unannounced4.Text, Unannounced5.Text, Unannounced6.Text, Unannounced7.Text, Unannounced8.Text, Unannounced9.Text, Unannounced10.Text, Unannounced11.Text, Unannounced12.Text}


        objConnection = New OleDbConnection(strConnectionString)
        objConnection.Open()

        For x As Integer = 0 To 11

            Dim formal As Integer = FormalBoxes2(x)
            Dim ci As Integer = CIBoxes2(x)
            Dim talent As Integer = TalentBoxes2(x)
            Dim unannounce As Integer = UnannouncedBoxes2(x)
            Dim contestant As String = contestants2(x)

            sqlString = "UPDATE Judge1 SET Formalware = " & formal & ", CI = " & ci & ", Talent = " & talent & ", Unannounced = " & unannounce & ", Total = 5 WHERE Contestant = '" & contestant & "'"
            Dim objCommand As New OleDbCommand(sqlString, objConnection)
            objCommand.ExecuteNonQuery()
        Next x

hi,

try like this

For x As Integer = 0 To 11             Dim formal As Integer = FormalBoxes2(x)            Dim ci As Integer = CIBoxes2(x)            Dim talent As Integer = TalentBoxes2(x)            Dim unannounce As Integer = UnannouncedBoxes2(x)            Dim contestant As String = contestants2(x)             sqlString = "UPDATE Judge1 SET Formalware = " & formal & ", CI = " & ci & ", Talent = " & talent & ", Unannounced = " & unannounce & ", Total = 5 WHERE Contestant = '" & contestant & "'"            Dim objCommand As New OleDbCommand(sqlString, objConnection)            objCommand.ExecuteNonQuery()        Next xDim path As String = "file name and location"
        Dim sqlString As String = ""
        Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & path & ";"

        Dim contestants2() As String = {"Burke", "Catanzaro", "Conte", "Cuddey", "Elaroussi", "Langan", "Lawrence", "McAndrew", "Olesinski", "Parks", "Price", "Torres"}

        Dim FormalBoxes2() As Integer = {Formalware1.Text, Formalware2.Text, Formalware3.Text, Formalware4.Text, Formalware5.Text, Formalware6.Text, Formalware7.Text, Formalware8.Text, Formalware9.Text, Formalware10.Text, Formalware11.Text, Formalware12.Text}
        Dim TalentBoxes2() As Integer = {Talent1.Text, Talent2.Text, Talent3.Text, Talent4.Text, Talent5.Text, Talent6.Text, Talent7.Text, Talent8.Text, Talent9.Text, Talent10.Text, Talent11.Text, Talent12.Text}
        Dim CIBoxes2() As Integer = {CI1.Text, CI2.Text, CI3.Text, CI4.Text, CI5.Text, CI6.Text, CI7.Text, CI8.Text, CI9.Text, CI10.Text, CI11.Text, CI12.Text}
        Dim UnannouncedBoxes2() As Integer = {Unannounced1.Text, Unannounced2.Text, Unannounced3.Text, Unannounced4.Text, Unannounced5.Text, Unannounced6.Text, Unannounced7.Text, Unannounced8.Text, Unannounced9.Text, Unannounced10.Text, Unannounced11.Text, Unannounced12.Text}


        objConnection = New OleDbConnection(strConnectionString)
        objConnection.Open()

        For x As Integer = 0 To 11
           Dim txt As New TextBox
           txt1.id="Formalware"&(x+1)
            Dim formal As Integer =int.parse(txt1.text)
          //repeat this for other controls
            sqlString = "UPDATE Judge1 SET Formalware = " & formal & ", CI = " & ci & ", Talent = " & talent & ", Unannounced = " & unannounce & ", Total = 5 WHERE Contestant = '" & contestant & "'"
            Dim objCommand As New OleDbCommand(sqlString, objConnection)
            objCommand.ExecuteNonQuery()
        Next x

on click button postback occurs.what i think is since postback occurs the code runs from page load. so all the initial values of the text boxes are taken. try debugging the code. if so is the case you have to take the new values in button click event

Hi,

Slovig it may be the asp.net control viewstate management that is creating problem or the code you did is having some mismatch with asp.net page working.

Please send both page(aspx) and its code behind, then only I can solve the problem.

This article has been dead for over six months. Start a new discussion instead.