并非所有的代码路径都返回值

gegeblue 2007-05-23 09:45:21
public DateTime UpdateAndInsert(Guid OverTimeHeadId, int OverTimeStatusId, Guid UserId,DateTime CreateTimeId,Guid guidId)
{
using (TransactionScope ts = new TransactionScope())//两个一起执行
{
string strSql = "UPDATE OverTimeHead SET OverTimeStatusId = '{1}' WHERE (OverTimeHeadId = '{0}')";

new CommonData().ExeNonQuery(strSql);

strSql = "INSERT INTO OverTimeFlows ( UserId, OverTimeStatusId,OverTimeFlowsId,CreateDateTime) VALUES ('{2}','{1}','{4}','{3}')";


new CommonData().ExeNonQuery(strSql);

ts.Complete();
}
}
...全文
189 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenyuling 2007-05-23
  • 打赏
  • 举报
回复
public DateTime UpdateAndInsert(Guid OverTimeHeadId, int OverTimeStatusId, Guid UserId,DateTime CreateTimeId,Guid guidId)
改成
public void UpdateAndInsert(Guid OverTimeHeadId, int OverTimeStatusId, Guid UserId,DateTime CreateTimeId,Guid guidId)
guojh021 2007-05-23
  • 打赏
  • 举报
回复
public DateTime UpdateAndInsert

这个函数要示有返回值 DateTime

这样声明就可以无返回值了:public void UpdateAndInsert
lovvver 2007-05-23
  • 打赏
  • 举报
回复
public void UpdateAndInsert(Guid OverTimeHeadId, int OverTimeStatusId, Guid UserId,DateTime CreateTimeId,Guid guidId)
{
using (TransactionScope ts = new TransactionScope())//两个一起执行
{
string strSql = "UPDATE OverTimeHead SET OverTimeStatusId = '{1}' WHERE (OverTimeHeadId = '{0}')";

new CommonData().ExeNonQuery(strSql);

strSql = "INSERT INTO OverTimeFlows ( UserId, OverTimeStatusId,OverTimeFlowsId,CreateDateTime) VALUES ('{2}','{1}','{4}','{3}')";


new CommonData().ExeNonQuery(strSql);

ts.Complete();
}
}
gegeblue 2007-05-23
  • 打赏
  • 举报
回复
在调试,成功了给你们加分
kimiya25 2007-05-23
  • 打赏
  • 举报
回复
你不要return 什么..干吗构造方法时声明了返回值..去掉..改void不就好了?
gegeblue 2007-05-23
  • 打赏
  • 举报
回复
二楼:问错在哪里啊!
三楼:我是要insert和update,我return什么啊?
xray2005 2007-05-23
  • 打赏
  • 举报
回复
都没有return一个值呢!
dengenming 2007-05-23
  • 打赏
  • 举报
回复
你声明的类命是要返回一个DateTime 啊


return ...
lovvver 2007-05-23
  • 打赏
  • 举报
回复
你要问的是什么

110,526

社区成员

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

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

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