Click here to Skip to main content
15,908,841 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
how can keep a value which it was recorded in database in variable before i updated it? i want the old value for an operation with new value,
example:
NewValue - OldValue = VariableValue
230 - 200 = 30,
by the way the OldValue is NewValue before i updated it.
can u give me an idea about it, if it's possible.
private void ChargerKiloVoitures()
{
			
try {
	_bd.Command.CommandText = "SELECT Kilometrage FROM Voitures " +
	"WHERE NumeroMatricule = \"" + CBNumMatricule.Text + "\"";
	Debug.WriteLine( Environment.NewLine );
	Debug.WriteLine( _bd.Command.CommandText );
	_bd.Reader = _bd.Command.ExecuteReader();
if ( _bd.Reader.Read());
	this.analogCounter2.Number = int.Parse(_bd.Reader["Kilometrage"].ToString());
	this.analogCounter1.Number = this.analogCounter2.Number + VidangeConstant;
					
					
   //i have problem here exactly 
	int OldKilometrage = int.Parse(_bd.Reader["Kilometrage"].ToString());
	int NewKilometrage = int.Parse(_bd.Reader["Kilometrage"].ToString());
	KiloMetrag.Value = NewKilometrage-OldKilometrage;
					
}//if
	_bd.Reader.Close();
 
}//try
	catch (Exception ex) {
		Debug.WriteLine( Environment.NewLine );
		Debug.WriteLine( ex.Message );
	MessageBox.Show("Une erreur a été détectée : " + Environment.NewLine + ex.Message, "Erreur");
	}//catch

}
Posted

1 solution

You can create local data container (LDC) to cache the old values from the application. LDC can be a simple collection list type with key/value pair.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900