使用 C# 从 Access DB 中读取复选框值
Reading a checkbox value from Access DB using C#
我正在处理登录表单。希望在按下“登录”按钮并查看数据库时检查用户名和密码是否正确以查看复选框是否已标记。
这是登录按钮代码的一部分!
AppDataTableAdapters.MemberTableAdapter user = new AppDataTableAdapters.MemberTableAdapter();
AppData.MemberDataTable dt = user.GetDataByUsernamePassword(txtuser.Text, txtpw.Text);
if (dt.Rows.Count > 0)
{
if(Convert.ToInt32(dt.ManagerColumn)>0)
{
MessageBox.Show("Successfully logged in ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
//manager login process
}
else
{
MessageBox.Show("Successfully logged in", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
//Normal guest Login
}
}
我希望 IF 语句继续并选中复选框并继续
我使用了不同的语句,但我只能回忆起 2 个错误 rn
if (Convert.ToInt32(dt.ManagerColumn)>0)
错误:无法将类型 'system.data.datacolumn' 的对象转换为类型 'system.iconvertible'
if(dt.ManagerColumn == 1) - tying to see if it is true or no ^^
错误 1 运算符“==”不能应用于 'System.Data.DataColumn' 和 'int'
类型的操作数
例如
if(tbl.Rows.Count > 0)
{
foreach(DataRow row in tbl.Rows)
{
string fName = row[2].ToString(); // value in column 2 (zero-based).
string lName = row[3].ToString(); // value in column 3 (zero-based).
或:
string src = sources.Tables[0].Rows[i].Field<string>("Source").ToString();
// sources dataset;
// Table 0 in the dataset;
// Row i in the loop;
// value in the Field of type <string>, named "Source".
我正在处理登录表单。希望在按下“登录”按钮并查看数据库时检查用户名和密码是否正确以查看复选框是否已标记。
这是登录按钮代码的一部分!
AppDataTableAdapters.MemberTableAdapter user = new AppDataTableAdapters.MemberTableAdapter();
AppData.MemberDataTable dt = user.GetDataByUsernamePassword(txtuser.Text, txtpw.Text);
if (dt.Rows.Count > 0)
{
if(Convert.ToInt32(dt.ManagerColumn)>0)
{
MessageBox.Show("Successfully logged in ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
//manager login process
}
else
{
MessageBox.Show("Successfully logged in", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
//Normal guest Login
}
}
我希望 IF 语句继续并选中复选框并继续 我使用了不同的语句,但我只能回忆起 2 个错误 rn
if (Convert.ToInt32(dt.ManagerColumn)>0)
错误:无法将类型 'system.data.datacolumn' 的对象转换为类型 'system.iconvertible'
if(dt.ManagerColumn == 1) - tying to see if it is true or no ^^
错误 1 运算符“==”不能应用于 'System.Data.DataColumn' 和 'int'
类型的操作数例如
if(tbl.Rows.Count > 0)
{
foreach(DataRow row in tbl.Rows)
{
string fName = row[2].ToString(); // value in column 2 (zero-based).
string lName = row[3].ToString(); // value in column 3 (zero-based).
或:
string src = sources.Tables[0].Rows[i].Field<string>("Source").ToString();
// sources dataset;
// Table 0 in the dataset;
// Row i in the loop;
// value in the Field of type <string>, named "Source".