access 2003 vs 2010 c#
I cannot see where I have gone wrong. There is no error but no data is being updated. I have the insert, delete and edit working but I don't know why I can't get this to work. Please can someone kindly help me here, thanks in advance...
connection string
myCon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:..\TempDB.mdb");
Update method...
private void btnUpdate_Click(object sender, EventArgs e)
{
OleDbCommand cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "UPDATE [Family] SET [FirstName] = ?, [LastName] = ?, [FamilyDOB] = ?, [Medical] = ? WHERE [ID] = ?";
//tried this as well
//cmd.CommandText = "UPDATE [Family] SET [FirstName] = FirstName, [LastName] = @LastName, [DOB] = @StudentDOB, [Medical] = @Medical WHERE [ID] = @ID";
cmd.Parameters.AddWithValue("@ID", txtFamID.Text);
cmd.Parameters.AddWithValue("@FirstName", txtFirstName.Text);
cmd.Parameters.AddWithValue("@LastName", txtLastName.Text);
cmd.Parameters.AddWithValue("@FamDOB", txtFamDOB.Text);
cmd.Parameters.AddWithValue("@Medical", txtMedical.Text);
cmd.Connection = myCon;
myCon.Open();
cmd.ExecuteNonQuery();
myCon.Close();
}