locked
Update more then one vlaue at the time Alternative databinding Property RRS feed

  • Question

  • i have a question about the SQLCE Update command. I want to update a whole record.
    I do have Form with some controls like textbox1 - textbox5.
     
    When i click on insert the new record is created. Now suppose the value which i have entered is wrong i want to provide the user a possibllity to chance whatever he needs. 5 entries and 3 wrong the user already have clicked save.
     
    In this case, the user just have to choose the new created User from the combobox, the other values are shown automatically. Now he should be able to change 3 values at the time, how can i do that? Like make the dataset editable?
     
    - custom databindings on the controls? // text1.databindings.add(values, editparamater?)
    - make the whole dataset editable? // like when i select the Username the whole record should be editable.
     
     
    Hier is the code: User can only change 1 value at the time, but he should be able to do 3 at the time
     
    Public Function Edit_SQLCE(ByVal vsDBName1 As String, ByVal vsTabellenName1 As String, ByVal feld As String, ByVal vsWert As String, ByVal vsWert_ As String)
     
            Dim cd As String = IO.Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase())
            cd = cd + "\" + vsDBName1 + ".sdf;"
            Dim conn As New SqlCeConnection("Data Source=" + cd)
            Try
                If conn.State = System.Data.ConnectionState.Closed Then
                    conn.Open()
                Else
                    MsgBox("Konnte keine Verbindung herstellt werden!", MsgBoxStyle.Critical)
                End If
     
                Dim query = "Update " + vsTabellenName1 + " set " + feld + "=' " + vsWert + " ' where Id='" & vsWert_ & "'"
                Dim cmd As SqlCeCommand = New SqlCeCommand(query, conn)
                Dim ro As Integer = cmd.ExecuteNonQuery.ToString
                MsgBox(ro.ToString)
     
     
            Catch ex As Exception
                MsgBox("Verbindungsfehler mit dem SQL - Server", MsgBoxStyle.Critical)
            End Try
            SpitexTableAdapter.Fill(Me.SpitexDataSet.Spitex)
    end Function
     
     
    call Function: Edit_SQLCE("Test1", "TableName", Spalte, wert, SpaltenNummer)
     

    kind regrads
     
    Suren
    Ariyaratnam
    • Moved by Max Wang_1983 Thursday, April 21, 2011 11:08 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Thursday, October 8, 2009 9:52 AM

Answers

  • this question would fit better for the netcf forum. but let me try my best. you can do one of these:
    1. use the same logic and loop in the records that need to be udpated.
    2. refill the UI using the sqlceDataAdapter and change the data then update them again.

    Hope this helps.

    thanks
    Yunwen
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, October 8, 2009 10:42 PM
    Moderator