2017-07-07 2 views
0

Ich arbeite mit einem SQL-DataAdapter (sqlDa) und auf dem Klick auf ein Kontrollkästchen Ereignis der sqlDa sollte einen Update-Befehl ausführen.VB.Net SQL DataAdapter Beim ersten Lauf nicht aktualisiert

Der Code wird aufgerufen, aber das Update-Ereignis wird nicht tatsächlich ausgelöst und ich bin mir nicht sicher warum.

Ich habe trat durch und es gibt keine Fehler, ich SQL Profiler ausgeführt haben und es zeigt, dass es keine SQL-Ereignis Ursprünglich gefeuert gab es keine Initializer so eine erstellt und die Bindungsereignisse sind auf die Checkbox ich arbeiten bin

Also, ich bin ein wenig ratlos und brauche etwas Hilfe.

Der Code, den ich mit Arbeit bin, ist

Public Sub New() 

    InitializeComponent() 

End Sub 

Private Sub boundCheckBox_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles boundCheckBox.CheckedChanged 
    ControlSettingsBindingSource.EndEdit() 
    Me.ControlSettingsTableAdapter.Update(Me.BoundTestDataSet.controlSettings) 
    Call diagnosticCheck(boundCheckBox.Checked) ' this is for diagnostic purposes only 
End Sub 

Public Overloads Overridable Function Update(ByVal dataTable As boundTestDataSet.controlSettingsDataTable) As Integer 
     Return Me.Adapter.Update(dataTable) 
    End Function 

Im initializer dies ist die Steuerung, die ich mit

'boundCheckBox 
    ' 
    Me.boundCheckBox.AutoSize = True 
    Me.boundCheckBox.DataBindings.Add(New System.Windows.Forms.Binding("Checked", Me.ControlSettingsBindingSource, "checkBoxSetting", True)) 
    Me.boundCheckBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) 
    Me.boundCheckBox.Location = New System.Drawing.Point(10, 62) 
    Me.boundCheckBox.Margin = New System.Windows.Forms.Padding(4, 3, 4, 3) 
    Me.boundCheckBox.Name = "boundCheckBox" 
    Me.boundCheckBox.Size = New System.Drawing.Size(590, 40) 
    Me.boundCheckBox.TabIndex = 0 
    Me.boundCheckBox.Text = "CheckBox Bound To 'checkBoxSetting'" 
    Me.boundCheckBox.UseVisualStyleBackColor = True 
    ' 

arbeite Irgendwelche und alle Hilfe sehr geschätzt

Simon

Antwort

0

Gefunden das Problem

benötigt ControlSettingsBindingSource.ResetBindings(False)

Private Sub boundCheckBox_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles boundCheckBox.CheckedChanged 
    ControlSettingsBindingSource.EndEdit() 
    ControlSettingsBindingSource.ResetBindings(False) 
    Me.ControlSettingsTableAdapter.Update(Me.BoundTestDataSet.controlSettings) 
    Call diagnosticCheck(boundCheckBox.Checked) ' this is for diagnostic purposes only 
End Sub 
hinzufügen
Verwandte Themen