//check if user has completed all five tasks
OleDbConnection dbCon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\zoofari\zoofari\zoofari\MainData.accdb");
OleDbDataAdapter dAdapter = new OleDbDataAdapter();
DataSet ds = new DataSet();
string query = ("select * from tbl_Tasks where Username = '" + _stuUname + "'");
dbCon.Open();
dAdapter = new OleDbDataAdapter(query, dbCon);
OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(dAdapter);
DataTable dTable = new DataTable();
dAdapter.Fill(dTable);
dbCon.Close();
我正在尝试检查用户是否已完成5个任务(布尔值为true),然后将真值写入同一个表中名为“Completed”的另一个字段。我是否需要创建变量来保存前五个值,还是可以在一个SQL语句中检查它?我的SQL技能非常基础,所以请尽可能简单地回复!感谢
答案 0 :(得分:0)
您根本不需要存储任何值。您只需运行查询
即可UPDATE [tbl_Tasks] SET [Completed] = ([1] AND [2] AND [3] AND [4] AND [5])