[英]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.