【发布时间】:2018-08-18 07:15:59
【问题描述】:
我使用 SQLite 创建了一个数据库,用于存储学生的详细信息,包括
Student Name (String)
Student Password (String)
Student ID (String)
Student Attendance(Boolean)
在我的解决方案中,有 3 个视图控制器,如下所述:
ViewController1 : 表格视图,显示学生列表。
ViewController2 :普通视图控制器,带有 3 个文本字段和 1 个切换按钮,用于获取所有 4 个用户详细信息。
ViewController3 : 一个按钮,让用户可以点击,并打开考勤(布尔值)。
我想使用 ViewController3 的按钮更新特定学生(例如 StudentName = Apple)的数据。
要插入新的学生数据,代码应该是这样的: *(默认情况下,出勤为“假”)
void SaveButton_Clicked(object sender, EventArgs e)
{
using (var connection = new SQLite.SQLiteConnection(pathToDatabase))
{
connection.Insert(new Student() { StudentName = AddStuNameTxt.Text, StudentId = AddStuIdTxt.Text, StudentPassword = AddStuPassTxt.Text, StudentAttendence = false});
new UIAlertView("Updated !", "Student successfully created", null, "OK", null).Show();
}
}
但是,如果我想在 ViewController3 中将“出勤”(布尔值)更新为 true,其中学生名为“Apple”。我可以知道该怎么做吗?
【问题讨论】:
-
检查我的更新答案删除 ContectInfo 并将其设为 Student 您的表名。
标签: c# sqlite xamarin xamarin.ios uibutton