Data Update Problem on one textbox control

Posted on 2008-11-18
Last Modified: 2013-11-26
I have a weird issue in a VB.Net Windows Forms application I cannot work out.

I have a simple Issues Register Application with a text [Status] Field that uses the variables Open, Closed and On Hold bound to a Textbox Control (TextBox_Status ).

If I manually type in the new variable (Open, Closed and On Hold) into the control when the call the Update procedure the Datatable updates the SQL database and all is good.

It falls apart when I want to use a button to update the TextBox (TextBox_Status) using the following;

Me.TextBox_Status.Text = "Open"

At Runtime when I click the button I can see on the form that the text in TextBox_Status has changed but when I call the Update procedure the Datatable does not try to update the database. No error is raised and through SQL Profiler I can see that no attempt is made to update the SQL database. Its as if the bindingsource does not recognise that the text in the textbox has changed unless I directly type the string into the control.

This seems to be working fine elsewhere in the application so if anyone has any suggestions I would really appreciate it.



PS: Update Procedure I am using;      
            Me.IssuesTableAdapter.Connection.ConnectionString = My.Settings.SQLConnectionstring
        Catch ex As Exception
        End Try
Question by:mj_stanton
    LVL 10

    Expert Comment

    Greetings MJ,

    Try adding this line after you set the text on your button update:

    Me.TextBox_Status.Text = "Open"
    Me.TextBox_Status.Modified = True  <---  Add this




    Author Comment

    Hi keith

    Thats for the suggestion I added the line but unfortunatly It did not help.

    I type the word "open" or "Open" at runtime in and then click save and it works fine. If I use the button click event it does not and then click save and the database is not updated.

    The Button Click Event code is below;

        Private Sub UltraButton_Status_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton_Status.Click

            If Me.UltraButton_Status.Text = "Close Item" Then
                Me.Closed_DateTextBox.Text = Today
                Me.TextBox_Status.Text = "Closed"
                Me.TextBox_Status.Modified = True
                Me.UltraButton_Status.Text = "Reopen Item"
                Me.UltraButton_Status.Appearance.Image = Me.ImageList1.Images(1)

            ElseIf Me.UltraButton_Status.Text = "Reopen Item" Then
                Me.UltraButton_Status.Text = "Close Item"
                Me.Closed_ByTextBox.Text = ""
                Me.Closed_DateTextBox.Text = ""
                Me.TextBox_Status.Text = "Open"
                Me.TextBox_Status.Modified = True
                Me.UltraButton_Status.Appearance.Image = Me.ImageList1.Images(0)
            End If

        End Sub

    Author Comment

    That was ment to be Thanks for the suggestion.
    LVL 10

    Expert Comment

    Hmm...strange!  Can you post the code that your TableAdapterUpdate is running?


    Author Comment


    Hi  Keith

    Here is the Update Command Text, The relevent field is [Issue Status]. I hope thai is what you wanted.



    UPDATE       Issues
    SET                ProjectID = @ProjectID, [Item Type] = @Item_Type, [Issue Statement EN] = @Issue_Statement_EN, [Issue Status] = @Issue_Status,
                             [Closed Date] = @Closed_Date, [Closed By] = @Closed_By, [Creation Date] = @Creation_Date, [Created By] = @Created_By,
                             [Buyer Resolution Owner] = @Buyer_Resolution_Owner, [Translation Required] = @Translation_Required, [Assigned To] = @Assigned_To,
                             [Responsible Org/Client Org] = @p1, [Responsible Org/Client Contact] = @p4, [Responsible Org/Client Contact Email] = @p7, Priority = @Priority,
                             Catagory = @Catagory, [Appear in Programme Level Register] = @Appear_in_Programme_Level_Register, [Venue ID] = @Venue_ID,
                             [Issue Name] = @Issue_Name, [Target Completion Date] = @Target_Completion_Date, [Estimated Completion Date] = @Estimated_Completion_Date,
                             [Completion Notes] = @Completion_Notes, [Internal Task] = @Internal_Task, [Risk Likelihood] = @Risk_Likelihood,
                             [Risk Consequence] = @Risk_Consequence, LastUpdate = @LastUpdate, LastUpdateBy = @LastUpdateBy, LastUpdateDate = @LastUpdateDate,
                             LastUpdateTime = @LastUpdateTime, [Related Contact] = @Related_Contact, [External Intergration Required] = @External_Intergration_Required,
                             ProgressPercentage = @ProgressPercentage, [Planned Cost] = @Planned_Cost, [Actual Cost] = @Actual_Cost, [WBS Code] = @WBS_Code,
                             StartDate = @StartDate, Duration = @Duration, [Duration Notes] = @Duration_Notes, [Duration Type] = @Duration_Type, [Actual Duration] = @Actual_Duration,
                              Deleted = @Deleted, [Cost Currency] = @Cost_Currency, [Assigned By] = @Assigned_By, Issue_Log = @Issue_Log, Issue_Client = @Issue_Client,
                             Priority_Order = @Priority_Order, Issue_Client_Name = @Issue_Client_Name
    WHERE        (IssuesID = @Original_IssuesID) AND (@IsNull_ProjectID = 1 AND ProjectID IS NULL OR
                             ProjectID = @Original_ProjectID) AND (@IsNull_Item_Type = 1 AND [Item Type] IS NULL OR
                             [Item Type] = @Original_Item_Type) AND (@IsNull_Issue_Status = 1 AND [Issue Status] IS NULL OR
                             [Issue Status] = @Original_Issue_Status) AND (@IsNull_Closed_Date = 1 AND [Closed Date] IS NULL OR
                             [Closed Date] = @Original_Closed_Date) AND (@IsNull_Closed_By = 1 AND [Closed By] IS NULL OR
                             [Closed By] = @Original_Closed_By) AND (@IsNull_Creation_Date = 1 AND [Creation Date] IS NULL OR
                             [Creation Date] = @Original_Creation_Date) AND (@IsNull_Created_By = 1 AND [Created By] IS NULL OR
                             [Created By] = @Original_Created_By) AND (@IsNull_Buyer_Resolution_Owner = 1 AND [Buyer Resolution Owner] IS NULL OR
                             [Buyer Resolution Owner] = @Original_Buyer_Resolution_Owner) AND (@IsNull_Translation_Required = 1 AND [Translation Required] IS NULL OR
                             [Translation Required] = @Original_Translation_Required) AND (@IsNull_Assigned_To = 1 AND [Assigned To] IS NULL OR
                             [Assigned To] = @Original_Assigned_To) AND (@p3 = 1 AND [Responsible Org/Client Org] IS NULL OR
                             [Responsible Org/Client Org] = @p2) AND (@p6 = 1 AND [Responsible Org/Client Contact] IS NULL OR
                             [Responsible Org/Client Contact] = @p5) AND (@p9 = 1 AND [Responsible Org/Client Contact Email] IS NULL OR
                             [Responsible Org/Client Contact Email] = @p8) AND (@IsNull_Priority = 1 AND Priority IS NULL OR
                             Priority = @Original_Priority) AND (@IsNull_Catagory = 1 AND Catagory IS NULL OR
                             Catagory = @Original_Catagory) AND (@IsNull_Appear_in_Programme_Level_Register = 1 AND [Appear in Programme Level Register] IS NULL OR
                             [Appear in Programme Level Register] = @Original_Appear_in_Programme_Level_Register) AND (@IsNull_Venue_ID = 1 AND [Venue ID] IS NULL OR
                             [Venue ID] = @Original_Venue_ID) AND (@IsNull_Issue_Name = 1 AND [Issue Name] IS NULL OR
                             [Issue Name] = @Original_Issue_Name) AND (@IsNull_Target_Completion_Date = 1 AND [Target Completion Date] IS NULL OR
                             [Target Completion Date] = @Original_Target_Completion_Date) AND (@IsNull_Estimated_Completion_Date = 1 AND [Estimated Completion Date] IS NULL OR
                             [Estimated Completion Date] = @Original_Estimated_Completion_Date) AND (@IsNull_Internal_Task = 1 AND [Internal Task] IS NULL OR
                             [Internal Task] = @Original_Internal_Task) AND (@IsNull_Risk_Likelihood = 1 AND [Risk Likelihood] IS NULL OR
                             [Risk Likelihood] = @Original_Risk_Likelihood) AND (@IsNull_Risk_Consequence = 1 AND [Risk Consequence] IS NULL OR
                             [Risk Consequence] = @Original_Risk_Consequence) AND (@IsNull_LastUpdateBy = 1 AND LastUpdateBy IS NULL OR
                             LastUpdateBy = @Original_LastUpdateBy) AND (@IsNull_LastUpdateDate = 1 AND LastUpdateDate IS NULL OR
                             LastUpdateDate = @Original_LastUpdateDate) AND (@IsNull_LastUpdateTime = 1 AND LastUpdateTime IS NULL OR
                             LastUpdateTime = @Original_LastUpdateTime) AND (@IsNull_Related_Contact = 1 AND [Related Contact] IS NULL OR
                             [Related Contact] = @Original_Related_Contact) AND (@IsNull_External_Intergration_Required = 1 AND [External Intergration Required] IS NULL OR
                             [External Intergration Required] = @Original_External_Intergration_Required) AND (@IsNull_ProgressPercentage = 1 AND ProgressPercentage IS NULL OR
                             ProgressPercentage = @Original_ProgressPercentage) AND (@IsNull_Planned_Cost = 1 AND [Planned Cost] IS NULL OR
                             [Planned Cost] = @Original_Planned_Cost) AND (@IsNull_Actual_Cost = 1 AND [Actual Cost] IS NULL OR
                             [Actual Cost] = @Original_Actual_Cost) AND (@IsNull_WBS_Code = 1 AND [WBS Code] IS NULL OR
                             [WBS Code] = @Original_WBS_Code) AND (@IsNull_StartDate = 1 AND StartDate IS NULL OR
                             StartDate = @Original_StartDate) AND (@IsNull_Duration = 1 AND Duration IS NULL OR
                             Duration = @Original_Duration) AND (@IsNull_Duration_Type = 1 AND [Duration Type] IS NULL OR
                             [Duration Type] = @Original_Duration_Type) AND (@IsNull_Actual_Duration = 1 AND [Actual Duration] IS NULL OR
                             [Actual Duration] = @Original_Actual_Duration) AND (@IsNull_Deleted = 1 AND Deleted IS NULL OR
                             Deleted = @Original_Deleted) AND (@IsNull_Cost_Currency = 1 AND [Cost Currency] IS NULL OR
                             [Cost Currency] = @Original_Cost_Currency) AND (@IsNull_Assigned_By = 1 AND [Assigned By] IS NULL OR
                             [Assigned By] = @Original_Assigned_By) AND (@IsNull_Issue_Client = 1 AND Issue_Client IS NULL OR
                             Issue_Client = @Original_Issue_Client) AND (@IsNull_Priority_Order = 1 AND Priority_Order IS NULL OR
                             Priority_Order = @Original_Priority_Order) AND (@IsNull_Issue_Client_Name = 1 AND Issue_Client_Name IS NULL OR
                             Issue_Client_Name = @Original_Issue_Client_Name)
    LVL 10

    Accepted Solution

    I'm not sure what the problem is here.  Maybe someone else can chime in.

    Sorry I couldn't be of more help.



    Author Closing Comment

    I Recreated the form and the problem went away. I have no idea why.

    Thanks for trying



    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now