Thursday, October 26, 2006

using OleDbCommand class to update a database table based on one or more variable values C#.net 2005 winform app

using ( OleDbConnection connection = new OleDbConnection( Properties.Settings.Default.HPMConnectionString ) )
{
connection.Open();
OleDbCommand changeActiveToNoCommand = new OleDbCommand( "UPDATE staff SET active = no WHERE staff_id = @staff_id" , connection );
changeActiveToNoCommand.Parameters.AddWithValue( "@staff_id" , Convert.ToInt64( staff_id ) );
changeActiveToNoCommand.ExecuteNonQuery();
}

No comments: