此更新查询正在运行,但它不会更新表上的任何字段。数据库是MSSQL。
这是我页面上的方法:
otAppMainSettingsBLL.updateGameDayWithTeamID(1, true);
这是业务逻辑层:
public bool updateGameDayWithTeamID(int teamID, bool myValue)
{
return otAppMainSettingsDAL.updateGameDayWithTeamID(teamID, myValue);
}
这是数据访问层:
public bool updateGameDayWithTeamID(int teamID, bool myValue)
{
try
{
using (var context = new KsEntities())
{
context.ExecuteStoreCommand("UPDATE tAppMainSettings set isGameDay ='" + myValue + "' WHERE teamID = {0}", teamID);
}
dc.SaveChanges();
return true;
}
catch (Exception ex)
{
return false;
}
}
如果我添加这个int值,如下所示:(int resultValue = 0;)
public bool updateGameDayWithTeamID(int teamID, bool myValue)
{
int resultValue = 0;
try
{
using (var context = new KsEntities())
{
resultValue = context.ExecuteStoreCommand("UPDATE tAppMainSettings set isGameDay ='" + myValue + "' WHERE teamID = {0}", teamID);
}
dc.SaveChanges();
return true;
}
catch (Exception ex)
{
return false;
}
}
我得到resultValue = 1
表名是:tAppMainSettings 字段是:isGameDay(不能为空,我的意思是,不选中Allow Nulls复选框,此字段的默认值为:((0)))