日期:2014-05-17 浏览次数:20788 次
string TrainNo = textBox5.Text.Trim();
string TotalNumber = textBox2.Text.Trim();
SqlCommand MyCommand = new SqlCommand();
string sql = "select MNO from TrainInfo where TNO='" + TrainNo + "'";
MyCommand.Connection = conn;
MyCommand.CommandText = sql;
MyCommand.CommandType = CommandType.Text;
//执行sql语句 返回第一行第一列的记录
string result = cmd.ExecuteScalar().ToString();
int intrest = int.Parse(result);//进行你需要的转换
int total = int.Parse(TotalNumber);
int i=intrest-total;
string varString = Convert.ToString(i);
string update = "Update TrainInfo set MNO='" + varString + "' where TNO='" + TrainNo + "'";
MyCommand.Connect