Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Newbie - Problem Updating! - getting desperate!
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00861305
Message ID:
00861423
Vues:
27
>>Here's where I'm stuck...
>> ....
>>I've been stuck on this since last week!
>>I'm completely baffled!
>>Any help would be greatly appreciated!
>>Someone please help!

>>
>>Rick
---------------------------------------------
>I am just taking a guess here but if you have an UPDATE SQL statement, wouldn't that be used in some sort of command execute statement. Is there an Execute method on that object? Again, just a quick guess. I will have to look at the object model to see later.
---------------------------------------------
I think I'm most of the way there now...It seems that the update code wasn't firing. Although I was editing the fields on my form, and they are bound to fields of my dataset, the UPDATE() code never fired, supposedly because it thought the dataset hadn't been altered.

I'm still having a problem, with the display of my dataset, after the update...


After I execute my Save code, the 1st record of my DataSet is containing the changes of my edits.

I edited record 10, EmployeeID=10, and record 1, employeeID=1 in the DataSet, is showing the save content.
All the other records in the DataSet show the correct content.

If I exit the app and go back in then I see that all is fine...

What am I not doing?



Here's the current code of my save routine.
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        'Save the information currently displayed on the screen
        Dim UpdateResult As Integer = -1

        'RML 12/19/2003 - I believe I need to update the DataSet
        'before the update of the DataAdapter will work

        If lAdding Then
            'inserting new data - still a work in process
            'UpdateResult = OleDbDataAdapter2.Update(DsEmployees1)
        Else
            'updating existing data
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("Address") = Me.txtAddress.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("BirthDate") = Me.txtBirthDate.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("City") = Me.txtCity.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("Country") = Me.txtCountry.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("Extension") = Me.txtExtension.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("FirstName") = Me.txtFirstName2.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("HireDate") = CDate(Me.txtHireDate.Text)
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("HomePhone") = Me.txtHomePhone.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("LastName") = Me.txtLastName2.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("Notes") = Me.txtNotes.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("Photo") = Me.txtPhoto.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("PostalCode") = Me.txtPostalCode.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("Region") = Me.txtRegion.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("ReportsTo") = CInt(Me.txtReportsTo.Text)
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("Title") = Me.txtTitle.Text
            DsEmployees1.Tables(0).Rows(intCurrentRecord).Item("TitleOfCourtesy") = Me.txtTitleOfCourtesy.Text

            UpdateResult = OleDbDataAdapter2.Update(DsEmployees1)
            DsEmployees1.AcceptChanges()
        End If
        If UpdateResult = 0 Then
            MessageBox.Show("no records affected", 
                        "Intro to ADO.Net", 
                        MessageBoxButtons.OK, 
                        MessageBoxIcon.Information, 
                        MessageBoxDefaultButton.Button1, 
                        MessageBoxOptions.DefaultDesktopOnly)
        End If
        lAdding = False
        ShowRecord(intCurrentRecord, intCurrentRecordEmployeeID)
    End Sub
The Update code for my OleDbDataAdapter2.Update() is
UPDATE Employees SET 
 Address = ?, 
 BirthDate = ?, 
 City = ?, 
 Country = ?, 
 Extension = ?, 
 FirstName = ?, 
 HireDate = ?, 
 HomePhone = ?, 
 LastName = ?, 
 Notes = ?, 
 Photo = ?, 
 PostalCode = ?, 
 Region = ?, 
 ReportsTo = ?, 
 Title = ?, 
 TitleOfCourtesy = ? 
WHERE (EmployeeID = ?)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform