Update更新语句问题,求高手,在线等

mm6268 2009-02-19 11:01:07
以下是我插入时的原码,现在要做修改了,不知道这个语句应该怎么写
数据库中满足更新条件的一次只有12条记录,要全部更新,但是12条记录中有一个字段的值都是不同的
希望大家能明白我的意图如果有不明确的地方见回复,在线等...

public int Add(Model.FCEngineData model)
{
StringBuilder InsertString = new StringBuilder();
InsertString.Append("insert tbFCEngineData(AircraftFlightRecordID,EngineID,PositionDesc,FCParamterGroupID,ParamterID,ParamterValue)");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDleft + "'" + "," + "'" + model.PositionDescleft + "'" + "," + model.FCParamterGroupID + "," + 9 + "," + model.Qygd + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDleft + "'" + "," + "'" + model.PositionDescleft + "'" + "," + model.FCParamterGroupID + "," + 6 + "," + model.Dqwd + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDleft + "'" + "," + "'" + model.PositionDescleft + "'" + "," + model.FCParamterGroupID + "," + 5 + "," + model.TemLeft + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDleft + "'" + "," + "'" + model.PositionDescleft + "'" + "," + model.FCParamterGroupID + "," + 4 + "," + model.RevLeft + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDleft + "'" + "," + "'" + model.PositionDescleft + "'" + "," + model.FCParamterGroupID + "," + 18 + "," + model.MaxtemLeft + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDleft + "'" + "," + "'" + model.PositionDescleft + "'" + "," + model.FCParamterGroupID + "," + 17 + "," + model.MaxrevLeft + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDright + "'" + "," + "'" + model.PositionDescright + "'" + "," + model.FCParamterGroupID + "," + 9 + "," + model.Qygd + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDright + "'" + "," + "'" + model.PositionDescright + "'" + "," + model.FCParamterGroupID + "," + 6 + "," + model.Dqwd + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDright + "'" + "," + "'" + model.PositionDescright + "'" + "," + model.FCParamterGroupID + "," + 5 + "," + model.TemRight + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDright + "'" + "," + "'" + model.PositionDescright + "'" + "," + model.FCParamterGroupID + "," + 4 + "," + model.RevRight + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDright + "'" + "," + "'" + model.PositionDescright + "'" + "," + model.FCParamterGroupID + "," + 18 + "," + model.MaxtemRight + " union all ");
InsertString.Append("select " + model.AircraftFlightRecordID + "," + "'" + model.EngineIDright + "'" + "," + "'" + model.PositionDescright + "'" + "," + model.FCParamterGroupID + "," + 17 + "," + model.MaxrevRight );

string sql = InsertString.ToString();
int count = DbHelperSQL.ExecuteSql(sql);
return count;

}
...全文
168 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
sxmonsy 2009-02-19
  • 打赏
  • 举报
回复
写存储过程
mm6268 2009-02-19
  • 打赏
  • 举报
回复
我的意思是对插入后的结果进行修改,并不是修改插入语句,而是要做一个对数据库进行修改操作的方法,也就等于是写一条Update语句
NealXX 2009-02-19
  • 打赏
  • 举报
回复
这样好像没什么问题
insert dbo.Table_1(a, b, c, d, e)
select '1a',2,3,4,5
union all
select '1b',2,3,4,5
union all
select '1c',2,3,4,5
union all
select '1d',2,3,4,5
union all
select '1f',2,3,4,5
union all
select '1e',2,3,4,5
select * from Table_1

select * from Table_1
1a 2 3 4 5
1b 2 3 4 5
1c 2 3 4 5
1d 2 3 4 5
1f 2 3 4 5
1e 2 3 4 5
数据也插入了...
NealXX 2009-02-19
  • 打赏
  • 举报
回复
用存储过程好了。。
wuyi8808 2009-02-19
  • 打赏
  • 举报
回复
[Quote=引用楼主 mm6268 的帖子:]
以下是我插入时的原码,现在要做修改了,不知道这个语句应该怎么写
数据库中满足更新条件的一次只有12条记录,要全部更新,但是12条记录中有一个字段的值都是不同的
希望大家能明白我的意图如果有不明确的地方见回复,在线等...
[/Quote]

要修改什么地方?
suners 2009-02-19
  • 打赏
  • 举报
回复
不懂i。。。。。。。。。。
esft 2009-02-19
  • 打赏
  • 举报
回复

帮顶
浮生若梦丶 2009-02-19
  • 打赏
  • 举报
回复
e
EveryCase 2009-02-19
  • 打赏
  • 举报
回复
顶~~~~~
luyuans86 2009-02-19
  • 打赏
  • 举报
回复
首先要知道你数据表的结构,你能截取个图吗
huanxiangsugars 2009-02-19
  • 打赏
  • 举报
回复
用存储过程比较方便。
yyed 2009-02-19
  • 打赏
  • 举报
回复
觸發下吧
gaolei477 2009-02-19
  • 打赏
  • 举报
回复
up
麻子Mozart 2009-02-19
  • 打赏
  • 举报
回复
学习
周公 2009-02-19
  • 打赏
  • 举报
回复
我觉得用存储过程写好。
缪军 2009-02-19
  • 打赏
  • 举报
回复
可以加个insert触发器,处理insert表
lipenggege 2009-02-19
  • 打赏
  • 举报
回复
增删改~~一起可以搞定
lipenggege 2009-02-19
  • 打赏
  • 举报
回复
用非连接~~sqldataAdapter帮我们搞定~~不用写那么多代码的~~~

用非连接~~把数据都加载到页面的dataGridVIew里面

在dataGridVIew 里面随意的修改~~

最后在更新按钮单击事件上写

sqlCommandBuilder b=new sqlCommandBuilder(dataAdapter)
dataAdapter.updata(ds,"...");

就搞定了~~有修改的他会自动修改 没有动过的 它就不管~~
一天雨水 2009-02-19
  • 打赏
  • 举报
回复
这样的写法不是太好。
最好在数据库中写存储过程
king19840811 2009-02-19
  • 打赏
  • 举报
回复
存储过程up
加载更多回复(4)

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧