Updated record shown in datatable but not in DB

Hi, ive got a Store procedure to update a record:

CREATE PROCEDURE dbo.spUpdateCustomer
      @CName      nvarchar(50),
      @CPhone      nvarchar(13),
      @CustomerID      int
           UPDATE Customers  SET CName=@CName,CPhone=@CPhone
            WHERE CustomerID=@CustomerID

In a form ive got two fields to update the selected row:
   with row                .
            .CName = Me.txt_CustomerName.Text
            .CPhone = Me.txt_Phone.Text
     End with

     'Now call function to send updates...

 Private Function UpdateRecords() As Boolean
            Dim da As SqlDataAdapter
            da = New SqlDataAdapter("SELECT CName,CPhone FROM Customers", cnStr)
            da.UpdateCommand = updateCustomer()
 End Function

Private Function UpdateCustomer() As SqlCommand
        Dim cmd As SqlCommand
        Dim cn As SqlConnection
        cn = New SqlConnection(cnStr)
        cmd = New SqlCommand("spUpdateCustomer", cn)
        cmd.CommandType = CommandType.StoredProcedure

        Dim param As SqlParameter
        param = cmd.Parameters.Add("@CName", SqlDbType.NVarChar, 50, "CName")
        param.SourceVersion = DataRowVersion.Original
        param.Direction = ParameterDirection.Input

        param = cmd.Parameters.Add("@CPhone", SqlDbType.NVarChar, 13, "CPhone")
        param.SourceVersion = DataRowVersion.Original
        param.Direction = ParameterDirection.Input

        '// ID
        param = cmd.Parameters.Add("@CustomerID", SqlDbType.Int, 4, "CustomerID")
        param.Direction = ParameterDirection.Input
        param.SourceVersion = DataRowVersion.Original
         Return cmd
    End Function

This goes through with no errors but the database is not been updated. any ideas??
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Christopher KileSenior Software AnalystCommented:
You're using the Original values as input to the stored procedure for update.  I'm giving this a quick reading, mind you, but it appears to me that you should be using the Current row version rather than the Original version.  Try changing that and let me know if it works.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arcrossAuthor Commented:
yes  that was it.!
thank you!
arcrossAuthor Commented:
but ive got another problem. I alter the update to
UPDATE Customers  SET CName=@CName,CPhone=@CPhone
            WHERE CustomerID=@CustomerID
            AND (CName = @CName OR ((@CName IS NULL) AND (CName IS NULL)))
            AND (CPhone =@CPhone OR ((@CPhone IS NULL) AND (CPhone IS NULL)))

Now when i try to update one field, when the parameters are set to CURRENt i got an concurrentcy exeception. I know why is happening but i dont know hot to solve it.
arcrossAuthor Commented:
I figured it out. I was using the same parameters in the where clause ! doh!

UPDATE Customers  SET CName=@CName,CPhone=@CPhone
            WHERE CustomerID=@CustomerID
            AND (CName = @Orig_CName OR ((@Orig_CName IS NULL) AND (CName IS NULL)))
            AND (CPhone =@Orig_CPhone OR ((@Orig_CPhone IS NULL) AND (CPhone IS NULL)))

then add more paratemeters to the Update command

Christopher KileSenior Software AnalystCommented:
:) Glad I helped, and glad you figured out the other problem.  Good luck with the rest of your project.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.