none
Problem with LinqToSQL, a listbox, a textbox, and SubmitChanges RRS feed

  • Question

  • In a simple test form, I have a listbox and a textbox. The form is bound to a datacontext, which has a single table. The listbox has two items, and is not bound. The textbox is bound to a property (a field) in the datacontext.

    When I select an item from the listbox, the following code runs:

    txtTest.Text = lstTest.SelectedItems(0).ToString

    Then when I push my Save button, the following code runs:

    Me.TextDC.SubmitChanges()

    But - the database field which the textbox is bound to is NOT updated.

    If I MANUALLY type in a value into the textbox and then push the Save button, the database field IS updated.

    I've been trying to solve this on and off for several days, and I finally made this very simple text form to confirm or deny what was happening. No errors occur.

    So, for some reason SubmitChanges() does not recognize that the textbox needs to be updated if it's .Text property has been updated from the listbox, but does recognize that it needs to be updated if I manually type in a value.

    Any thoughts?

    Thursday, July 21, 2011 2:17 PM

Answers

  • Hi Saswati,

    I did get this solved from a reply elsewhere in this forum. Somehow, I don't know how exactly, the connection string to SQL Server in the dbml file and the connection string in the application settings file were slightly different. I made absolutely sure they were both pointing to the same sql server database, and all works correctly now.

    Thanks!


    DanW52
    • Marked as answer by DanW52 Saturday, July 23, 2011 12:57 AM
    Saturday, July 23, 2011 12:57 AM

All replies

  • Hi DAnw52,

     

    It looks like when you select the value from the listbox it is not reflecting in the textbox. To provide you some sort of solution I need to look into your code. So if possible can you please share this portion of the code.  

     

    Thanks

    Saswati


    Saswati Sanyal
    Friday, July 22, 2011 3:28 AM
  • Hi Saswati,

    I did get this solved from a reply elsewhere in this forum. Somehow, I don't know how exactly, the connection string to SQL Server in the dbml file and the connection string in the application settings file were slightly different. I made absolutely sure they were both pointing to the same sql server database, and all works correctly now.

    Thanks!


    DanW52
    • Marked as answer by DanW52 Saturday, July 23, 2011 12:57 AM
    Saturday, July 23, 2011 12:57 AM