Text Box Does Not Update New Values

Joined
Jul 22, 2009
Messages
2
Reaction score
0
When I load the page, it assigns the values from the DB into the Textbox.text property, but when I edit the text box values in the page and submit the page, the values submitted are actually the original values, not the changed values. How can I keep the new values and pass them to the query?


Here's my code:


Code:
Protected Overrides Sub onLoad(ByVal e As EventArgs)

        Dim dbconn As OleDbConnection
        Dim sql As String
        Dim dbcomm As OleDbCommand
        Dim dbread As OleDbDataReader

        isUpdate = False
        lblTEST.Text = Request.QueryString("requestID")

        If Request.QueryString("requestID") <> "" Then



            gotRequestID = Request.QueryString("requestID")


            dbconn = New OleDbConnection(connStr)
            dbconn.Open()
            sql = "SELECT * FROM #TABLENAME WHERE [int_requestID] = " + gotRequestID + " "
            dbcomm = New OleDbCommand(sql, dbconn)
            dbread = dbcomm.ExecuteReader()

            If dbread.HasRows Then
                isUpdate = True
                lbl1.Text = dbread.HasRows.ToString
                dbread.Read()



                If Not Page.IsPostBack Then
                    gisName.Text = dbread.GetString(1) 'Name
                    gisUserID.Text = dbread.GetString(2) 'UserID
                    'gisSpecifiedDate.Text = dbread.GetString(3) 'SpecifiedDate
                    'gisDueDate.Text = dbread.GetString(4) 'DueDate
                    ''''gisType = dbread.GetString(5) 'Type
                    gisTypeTextMap.Text = dbread.GetString(6) 'TextMap
                    gisTypeTextOther.Text = dbread.GetString(7) 'TextOther
                    'label02.Text = dbread.GetString(8) ' Description
                    gisPhoneNum.Text = dbread.GetString(9) 'PhoneNum
                    gisTitle.Text = dbread.GetString(10) 'Title
                    gisProjectAccount.Text = dbread.GetString(11) 'ProjectAccount
                    gisLocation.Text = dbread.GetString(12) 'Location
                    gisMaps.Text = dbread.GetInt32(13).ToString 'Maps
                    gisTheme.Text = dbread.GetString(14) 'Theme
                    gisLayers.Text = dbread.GetString(15) 'Layers
                    gisDefinition.Text = dbread.GetString(16) 'Definition
                    gisExtent.Text = dbread.GetString(17) 'Extent
                    gisFeatures.Text = dbread.GetString(18) 'Features
                    gisOutput.Text = dbread.GetString(19) 'Output
                    gisSize.Text = dbread.GetString(20) 'Size
                    gisOrientation.Text = dbread.GetString(21) 'Orientation
                    ''''gisLocator.dsadfasdfdsaf()= dbread.GetBoolean(22) 'Locator
                    gisInfo.Text = dbread.GetString(23) 'Info
                    'gisAssigned.Text = dbread.GetString(24) 'Assigned
                    ''''var_gisAssignID.ToString() = dbread.GetString(25) 'AssignedID
                    'gisHours.Text = dbread.GetFloat(26).ToString 'Hours
                    'gisCompleted.Text = dbread.GetString(27) 'Completed
                    gisProjLocation.Text = dbread.GetString(28) 'ProjLocation
                    '''''gisStatus.SelectedIndexasdfsadfasdfdsaf()= dbread.GetInt16(29)  'Status
                End If


            End If

            dbread.Close()
            dbconn.Close()
        End If

        If isUpdate = True Then
            Button.Text = "Update Request"
        Else
            Button.Text = "New Request"
        End If




    Sub submit(ByVal sender As Object, ByVal e As EventArgs)
        Dim dbconn As OleDbConnection
        Dim sql As String
        Dim dbcomm As OleDbCommand

        Dim var_gisType As String

        ...

        Dim var_gisHours As Double



        Dim ci As CultureInfo = New CultureInfo("en-US")

        If Page.IsValid Then

            var_gisType = ""

            var_gisTypeText = ""

            Integer.TryParse(gisMaps.Text, var_gisMaps)

            Integer.TryParse(gisAssignID.Text, var_gisAssignID)

            Double.TryParse(gisHours.Text, var_gisHours)


            dbconn = New OleDbConnection(connStr)
            dbconn.Open()
            If isUpdate = False Then
                sql = "INSERT INTO [gisunit].[dbo].[tbl_GISRequest] (" + _
                "[str_requestName], " + _
                "[str_requestContactUserID], " + _
                "[dt_requestDate], " + _
                "[dt_requestDueDate], " + _
                "[str_requestType], " + _
                "[str_requestTypeTextMap], " + _
                "[str_requestTypeTextGIS], " + _
                "[str_requestPhoneNum], " + _
                "[str_requestTitle], " + _
                "[str_requestProjectAccount], " + _
                "[str_requestLocation], " + _
                "[int_requestMaps], " + _
                "[str_requestTheme], " + _
                "[str_requestLayers], " + _
                "[str_requestDefinition], " + _
                "[str_requestExtent], " + _
                "[str_requestFeatures], " + _
                "[str_requestOutput], " + _
                "[str_requestSize], " + _
                "[str_requestOrientation], " + _
                "[bit_requestLocator], " + _
                "[str_requestInfo], " + _
                "[dt_assignAssigned], " + _
                "[int_assignID], " + _
                "[flt_assignHours], " + _
                "[dt_assignCompleted], " + _
                "[str_assignProjLocation], " + _
                "[str_assignStatus]) " + _
               " VALUES " + _
               "( '" + gisName.Text + "' " + _
               ", '" + gisUserID.Text + "' " + _
               ", '" + gisSpecifiedDate.Text + "' " + _
               ", '" + gisDueDate.Text + "' " + _
               ", '" + var_gisType + "' " + _
               ", '" + gisTypeTextMap.Text + "' " + _
               ", '" + gisTypeTextOther.Text + "' " + _
               ", '" + gisPhoneNum.Text + "' " + _
               ", '" + gisTitle.Text + "' " + _
               ", '" + gisProjectAccount.Text + "' " + _
               ", '" + gisLocation.Text + "' " + _
               ", " + var_gisMaps.ToString + " " + _
               ", '" + gisTheme.Text + "' " + _
               ", '" + gisLayers.Text + "' " + _
               ", '" + gisDefinition.Text + "' " + _
               ", '" + gisExtent.Text + "' " + _
               ", '" + gisFeatures.Text + "' " + _
               ", '" + gisOutput.Text + "' " + _
               ", '" + gisSize.Text + "' " + _
               ", '" + gisOrientation.Text + "' " + _
               ", '" + var_gisLocator + "' " + _
               ", '" + gisInfo.Text + "' " + _
               ", '" + gisAssigned.Text + "' " + _
               ", '" + var_gisAssignID.ToString + "' " + _
               ", '" + var_gisHours.ToString + "' " + _
               ", '" + gisCompleted.Text + "' " + _
               ", '" + gisProjLocation.Text + "' " + _
               ", '" + (gisStatus.SelectedIndex + 1).ToString + "' )"

                gotRequestID = 0
            ElseIf isUpdate = True Then
                sql = "UPDATE [gisunit].[dbo].[tbl_GISRequest] SET" + _
                "[str_requestName] =  '" + gisName.Text + "' ," + _
                "[str_requestContactUserID] =  '" + gisUserID.Text + "' ," + _
                "[dt_requestDate] =  '" + gisSpecifiedDate.Text + "' ," + _
                "[dt_requestDueDate] =  '" + gisDueDate.Text + "' ," + _
                "[str_requestType] =  '" + var_gisType + "' ," + _
                "[str_requestTypeTextMap] =  '" + gisTypeTextMap.Text + "' ," + _
                "[str_requestTypeTextGIS] =  '" + gisTypeTextOther.Text + "' ," + _
                "[str_requestPhoneNum] =  '" + gisPhoneNum.Text + "' ," + _
                "[str_requestTitle] =  '" + gisTitle.Text + "' ," + _
                "[str_requestProjectAccount] =  '" + gisProjectAccount.Text + "' ," + _
                "[str_requestLocation] =  '" + gisLocation.Text + "' ," + _
                "[int_requestMaps] =  " + var_gisMaps.ToString + " ," + _
                "[str_requestTheme] =  '" + gisTheme.Text + "' ," + _
                "[str_requestLayers] =  '" + gisLayers.Text + "' ," + _
                "[str_requestDefinition] =  '" + gisDefinition.Text + "' ," + _
                "[str_requestExtent] = " + " '" + gisExtent.Text + "' ," + _
                "[str_requestFeatures] =  '" + gisFeatures.Text + "' ," + _
                "[str_requestOutput] =  '" + gisOutput.Text + "' ," + _
                "[str_requestSize] =  '" + gisSize.Text + "' ," + _
                "[str_requestOrientation] =  '" + gisOrientation.Text + "' ," + _
                "[bit_requestLocator] =  '" + var_gisLocator + "' ," + _
                "[str_requestInfo] =  '" + gisInfo.Text + "' ," + _
                "[dt_assignAssigned] =  '" + gisAssigned.Text + "' ," + _
                "[int_assignID] =  '" + var_gisAssignID.ToString + "' ," + _
                "[flt_assignHours] =  '" + var_gisHours.ToString + "' ," + _
                "[dt_assignCompleted] =  '" + gisCompleted.Text + "' ," + _
                "[str_assignProjLocation] =  '" + gisProjLocation.Text + "' ," + _
                "[str_assignStatus] =  '" + (gisStatus.SelectedIndex + 1).ToString + "' " + _
                " WHERE [int_requestID] = " + gotRequestID.ToString + " "
            Else
                sql = ""
            End If


            dbcomm = New OleDbCommand(sql, dbconn)


            lbl1.Text = "RequestID = " + gotRequestID.ToString + ";  Rows Affected = " + dbcomm.ExecuteReader().RecordsAffected.ToString


            dbconn.Close()

        Else

            lbl1.Text = "Please refrain from using symbols in your input!"

        End If

    End Sub
 
Last edited:
Joined
Jul 22, 2009
Messages
2
Reaction score
0
And here is some snippets from the aspx page:

Code:
        <div class="label01"><b>Name:</b> </div><asp:TextBox ID="gisName" runat="server" maxlength="50" CssClass="txtbox01"></asp:TextBox>
        <asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ControlToValidate="gisName" ValidationExpression="^[\w'\s]*$" ErrorMessage="Invalid text.  Only alphanumeric characters allowed." />
        <br /><br />
        <div class="label01"><b>UserID:</b> </div><asp:TextBox ID="gisUserID" runat="server" maxlength="50" CssClass="txtbox01"></asp:TextBox>
        <asp:RegularExpressionValidator id="RegularExpressionValidator2" runat="server" ControlToValidate="gisUserID" ValidationExpression="^[\w\s]*$" ErrorMessage="Invalid text.  Only alphanumeric characters allowed." />
        <br /><br />



        <asp:Button ID="gisButton" OnClick="submit" Text="Submit" runat="server" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top