表是WinBid,字段为ProjectID,如果表中有数据,就修改,如果没有,就insert,主要不懂的是如何判断该行数据是否存在
忘了说了,我是用C#做的,在VS内判断
第1个回答 2010-07-10
if exists(select 1 from WinBid where ProjectID = @ProjectID)
-- update...
else
-- insert...
或者
update ...
if @@rowcount <> 1
insert...本回答被网友采纳
-- update...
else
-- insert...
或者
update ...
if @@rowcount <> 1
insert...本回答被网友采纳
第2个回答 2010-07-10
select * from WinBid
SQLhelp类就不举例出来了
假设返回的一张表DataTable dt;
if(dt.rows.count>0)//数据库中有数据
{
insert
}
else
{
update
}
如果是针对某一条数据而言,在SQL语句后面加个 where 条件即可本回答被提问者采纳
SQLhelp类就不举例出来了
假设返回的一张表DataTable dt;
if(dt.rows.count>0)//数据库中有数据
{
insert
}
else
{
update
}
如果是针对某一条数据而言,在SQL语句后面加个 where 条件即可本回答被提问者采纳