Results 1 to 6 of 6

Thread: Having Trouble Updating Values [Resolved]

Threaded View

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Having Trouble Updating Values [Resolved]

    Creating a simple db application. 4 textboxes, and this is the code I am using in the click event of the update button:

    VB Code:
    1. 'dsDataSet is my dataset, already declared.
    2.  
    3.  Dim dr As DataRow
    4.  
    5.         'Set the primary key for the table
    6.         With dsDataSet.Tables("Customers")
    7.             dsDataSet.Tables("Customers").PrimaryKey = New DataColumn() {.Columns("CustomerID")}
    8.         End With
    9.  
    10.         Dim pkey As Object
    11.         pkey = TextBox1.Text
    12.  
    13.         dr = dsDataSet.Tables("Customers").Rows.Find(pkey)
    14.         dr.BeginEdit()     'Start editing process
    15.  
    16.         'Enter new field values in the row
    17.         dr.Item(0) = TextBox1.Text
    18.         dr.Item(1) = TextBox2.Text
    19.         dr.Item(2) = TextBox3.Text
    20.         dr.Item(3) = TextBox4.Text
    21.  
    22.  
    23.         dr.EndEdit() 'End editing process
    24.         dsDataSet.AcceptChanges()  'Submit changes to dataset
    25.  
    26.  
    27.      
    28.         MessageBox.Show("Successfully Updated")

    It seems that the dataset is being updated, but the values are not being changed in the database. What am I missing?
    Last edited by mendhak; May 25th, 2004 at 08:46 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width