Hi everyone,
I encountered a problem when trying to do a simple programme of adding, editing of database using VB express edition 2008 with SQL Server 2005 Express Edition.
I was able to add in data but when I tried to edit the data its failed.
My programme will worked in this way:
To do a clock-in and clock-out system for users.
When the user entered their ID number,
if they haven clocked in yet, the programme will add new data for the user with when and where they clocked in data filled in for them.
if they clocked in before, the programme will edit the data by changing the clock out data from "" to current time.
I add data by:
Me.CarLocationBindingSource.AddNew()
UserIDTextBox.Text = UserID
ClockINTextBox.Text = TimeOfDay
LocationTextBox.Text = Locations
Try
Me.Validate()
Me.CarLocationBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.CarLocationDataSet)
Catch ex As Exception
MsgBox("Update failed")
End Try
Edit data:
Dim TheCarLocationRow As CarLocationDataSet.CarLocationRow
TheCarLocationRow = CarLocationDataSet.CarLocation.FindByUserID(Form1TextboxOfDataChecking.Text)
TheCarLocationRow.ClockOUT = TimeOfDay
CarLocationDataSet.CarLocation.AcceptChanges()
Try
Me.Validate()
Me.CarLocationBindingSource.EndEdit()
Me.TableAdapterManager1.UpdateAll(CarLocationDataSet)
MsgBox("Update successful")
Catch ex As Exception
MsgBox("Update failed")
End Try
I can add in new data but can't update the data.
I just figured all this commands by seeing the help section. But I guess I need more than just some simple commands to save the data I edited.
Thanks in advance.. :)
How to update a database successfully
Started by mechslayer, Aug 11 2008 09:03 PM
2 replies to this topic


Sign In
Create Account


Back to top









