Can't update my data!

I have a piece of code like this: 

DsContactos1.Contactos(0).Contacto = txtContacto.Text 

then I pass it to my webservice, but the data isn't updated. I'm sure the dataset leaves to the webservice and I quick watch it to see and the text from the textbox was there. But the data wasn't updated :((( 

Suprising is that I tryed like this: 

DsContactos1.Contactos(0).Contacto = "test" 

And it updated the data. How do I solve this problem


Answer this question

Can't update my data!

  • Matthias2005

    well my head is in loops with this yet... Does anyone have more ideas
  • Thomas Scheidegger

    I currently face a similiar problem. In my case the RowState of the updated DataSet row is still "Unchanged" instead of "Modified". That's why ADO.NET doesn't fire off the update of the orignal data source. But I don't know why this happens. May be you should check whether it is the same problem for you.
  • Mr. Pop

    txtContracto.Text.<u><b><color="red">ToString</color></b></u> is the first thing I'd try. If that didn't work, I'd step through the code and verify all the values are as I expected them to be. That's how I usually find all my mistakes.

    Good Luck!  0:) 

  • Dean Harding

    I'm sorry, I was using binding.
    I was thinking that not. That was the error. It's solved. Thank you!!!

    Now I was wondering about the reason for this. I know the canceledit very well but I spended too much time in this that I had forgotten the binding.

    I think that when I associated the txtbox.text it wasn't passing by value but by ref, then if the bindingcontext didn't sended a EndCurrentEdit message the the dataset didn't changed the state for the row. I say this because when I debugged the webservice the value was there. Thanks to Uwe Becker you guessed the two problems :)

  • urbs44

    Note that if write:

    = "xpto test 1234556"

    it updates, but if I type it in the textbox it doen't!!!!!! (but I'll check the state tomorrow and I will post here the result)

    The maxlenght is of 255, and I type simple things not more than 20 chars!

  • mallemukken

    Sounds like to me the .text property of the textbox is too big for the column in the database. I've seen this problem a few times myself. Be sure that the MaxLength of the textbox doesn't exceed the Column in the table and try again.

    Since you said 'test' works, try using 'test' in the textbox as a trial.

    Hope this helps.

  • Giantsonic

    I'm not using databinding. But I tried and it didn't work!
  • RossL

    I've tried that and everything. I sure the value gets there. I've tried trims, lefts, etc....

    This is in my presentation layer: 

    DsContactos1.Contactos(0).Contacto = txtContactos.Text ' My TextBox 
    DsContactos1.Contactos(0).Tipo = CmbTipos.SelectedValue ' My Combo 
    Central.WebRestaunet.UpdateTable("Contactos", DsContactos1) ' Central.WebRestaunet is my WebService and 'Contactos' the table 

    Next, the implementation of the UpdateTable of my Webservice: 

    <WebMethod(True)> Public Sub UpdateTable(ByVal tabela As String, ByVal ds As DataSet) 
    Dim tmp As New SqlClient.SqlDataAdapter("select * From " & tabela, Comuns.GetConnection) 
    Dim tmpi As New SqlClient.SqlCommandBuilder(tmp) 

    tmp.Update(ds, tabela) 
    End Sub 

    My table have the ID row, one Row for the type of Contact (BigInt) and another to the Contact itself (nChar). The reason of being nChar is that my contact type could be and Email, Fax, Phone, IPPhone or Web Page. Initialy it was of nVarChar but in the past (ASP) I had problems with that and I thought it was the problem this time, but it wasn't. 

    Please note that if I change the Type of Contact in my combo it updates the database. I really don't understand!!!! 

  • ACHawk

    Try this: 
    Bevor you send the data to the WebService perform the following command:

    this.BindingContext[DsContactos1,"Contactos"].EndCurrentEdit();

    It worked for me.

  • Can't update my data!