这是我到目前为止所拥有的。
//Getting access value from the AccessTable
SqlCommand cmadAccess;
string strAccess;
strAccess = "select * from AccessTable where Email='" +
EmailTextBox.Text.Trim() + "'";
cmadAccess = new SqlCommand(strAccess, conn);
SqlDataReader readAccess = cmadAccess.ExecuteReader();
if (readAccess.Read()) {
//here I am trying to display data from the database to the checkbox but it does not work.
}
这是我尝试过的两个例子:
TechnitianCheckBox.Checked = Convert.ToBoolean(readAccess["ClientTechnitian"]);
TechnitianCheckBox.Checked = readAccess["ClientTechnitian"].ToString();
有人能指出正确的方法吗?
答案 0 :(得分:0)
您正在寻找读者的GetOrdinal(...)
。
TechnitianCheckBox.Checked = readAccess.GetBoolean(readAccess.GetOrdinal("ClientTechnitian"));