更新前如何保持价值? [英] how can i keep a value before i updated?

查看:56
本文介绍了更新前如何保持价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在更新变量之前,如何在数据库中保留记录在数据库中的值?我希望将旧值用于具有新值的操作,
例如:
NewValue-OldValue = VariableValue
230-200 = 30,
顺便说一句,在我更新它之前,OldValue是NewValue.
如果可以的话,你能给我一个想法吗?

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

}

推荐答案

您可以创建本地数据容器(LDC),以缓存应用程序中的旧值. LDC可以是具有键/值对的简单收集列表类型.
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.


这篇关于更新前如何保持价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆