0
사용자의 VotingStatus(Boolean)
에 대한 인증을해야합니다. 일단 투표 상태가 데이터베이스에서 선택되면 다시 투표 할 수 없습니다.부울 값의 데이터 형식 불일치 오류
아래의 코드는 데이터 유형 불일치 오류를 보여줍니다. 이게 뭐가 잘못 되었 니?
MessageBox.Show("Welcome!");
OleDbCommand comd1 = new OleDbCommand();
comd1.Connection = connection;
comd1.CommandText = "SELECT VoterID FROM tbl_voter where Uname='" + txt_user.Text + "' and Pword='" + txt_pass.Text + "'";
voterid = Convert.ToString(comd1.ExecuteScalar());
Program.VoterID = voterid;
string comd21 = "Select VotingStatus from tbl_voter where VoterID='" + voterid + "'";
OleDbCommand comd2 = new OleDbCommand(comd21, connection);
var vstatus = (String)comd2.ExecuteScalar();
if (vstatus == "true")
{
MessageBox.Show("You cannot vote again!");
}
유권자가 이미 투표했는지 확인하기 위해 boolean 값인 "VotingStatus"와 "true/false"를 비교해야합니다. – Theodore
데이터베이스의'VotingStatus' 값은 varchar 유형으로 'true'또는'false'입니까? – Christos
varchar 유형은 무엇을 의미합니까? – Theodore