Hi i have my INSERT and DELETE command working fine my data gets saved to my database to deleted,
my problem is my UPDATE command. i have a form which displays 'employee' information the form includes text boxes i.e forname surnam etc and this is where the data is displayed when i select a text box and edit the data for instance if i chance the surname and then select my button on my form to update the data back to the database it changes all of the data so that the fornames are no longer names they all display -1 as a forname i dont know why this happens i was wondering if someone could explain where i am going wrong
my code is
OleDbUpdateCommand1 = New System.Data.OleDb.OleDbCommand
OleDbConnection1 = New System.Data.OleDb.OleDbConnection
OleDbUpdateCommand1.CommandText = "UPDATE Employees SET Forename = @p1 OR Surname = @p2 OR Role = @p3 OR Email = @p4 OR Telephone = @p5 OR Extension = @p6 OR Mobile =@p7"
OleDbUpdateCommand1.Connection = Me.OleDbConnection1
OleDbUpdateCommand1.Parameters.AddWithValue("@p1", ForenameTextBox.Text)
OleDbUpdateCommand1.Parameters.AddWithValue("@p2", SurnameTextBox.Text)
OleDbUpdateCommand1.Parameters.AddWithValue("@p3", RoleTextBox.Text)
OleDbUpdateCommand1.Parameters.AddWithValue("@p4", EmailTextBox.Text)
OleDbUpdateCommand1.Parameters.AddWithValue("@p5", TelephoneTextBox.Text)
OleDbUpdateCommand1.Parameters.AddWithValue("@p6", ExtensionTextBox.Text)
OleDbUpdateCommand1.Parameters.AddWithValue("@p7", MobileTextBox.Text)
OleDbUpdateCommand1.Connection = Me.OleDbConnection1
OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\mydatabase.mdb"
Try
OleDbConnection1.Open()
OleDbUpdateCommand1.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.ToString)
End Try
OleDbConnection1.Close()
MsgBox("Employee Details Have Now Been Deleted From Database", MsgBoxStyle.OkOnly + MsgBoxStyle.OkOnly)
End Sub