繁体   English   中英

使用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".

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM