Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UPDATE isn't updating
Message
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Versions des environnements
Environment:
VB.NET 1.1
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
00995762
Message ID:
00995952
Vues:
23
>To all,
>
>I'm taking an "advanced" VB.NET class and we're working with database updates. I've got the connection/dataAdaptor/dataSet things configured so that everything works UNTIL the dataAdaptor.Update() method is run. Nothing happens. No updates, no errors, no messages. NOTHING!
>
>The dataSet looks fine. The data in the dataSet is Inserting/Updating/Deleting OK. But nothing is going to the data source. Other than the obvious (no changes persisting on the data source) the only indication that something's wrong is a test memvar that I've added. I trap the value returned from the Update() method and that value is zero.
>
>My instructor has no suggestions. If this were Basket Weaving 101 or some such, I'd just blow it off, but I'm a professional database applications developer. I need to know what's wrong here.
>
>TIA,
>Thom C.

Thom;

"I love VB.NET"! It lets me do things that I should not and does not throw errors. Then after working for months it will blow up never to work again! So I like to use C# as it does not let me get away with "anything"! :)

Anyway, here is one example I use as a data class.

I have the feeling that this line may not be in your code:

cmd.ExecuteNonQuery()

If you still have a problem please post your code.

Tom




VB NET Update
Public Shared Function UpdateUser(ByVal userID As String, ByVal PhoneExt As String, ByVal FirstName As String, ByVal LastName As String, ByVal DepartmentCode As String, ByVal PositionName As String) As SqlCommand
        ' Update User Record...
        Dim sql As String = "UPDATE UserInfo SET PhoneExt=@PhoneExt, FirstName=@FirstName, LastName=@LastName,DepartmentCode=@DepartmentCode, PositionName=@PositionName WHERE userID=@userID"
        Dim UpdateUserConnection As SqlConnection = GetConnection()
        UpdateUserConnection.Open()
        Dim cmd As New SqlCommand(sql, UpdateUserConnection)

        cmd.Parameters.Add("@UserID", userID)
        cmd.Parameters.Add("@PhoneExt", PhoneExt)
        cmd.Parameters.Add("@FirstName", FirstName)
        cmd.Parameters.Add("@LastName", LastName)
        cmd.Parameters.Add("@DepartmentCode", DepartmentCode)
        cmd.Parameters.Add("@PositionName", PositionName)

        If UpdateUserConnection.State = ConnectionState.Closed Then UpdateUserConnection.Open()

        cmd.ExecuteNonQuery()

        UpdateUserConnection.Close()

End Function
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform