greeny, can you please post the code where you "built" [anndept.announceToFaculty] ?
anndept is a boolean variable, which it can only be set to true and false. When you declared anndept, you declared it as a boolean. Is anndept the column you are trying to update? In order to help you, I gotta know where you set anndept and how you set it. When updating your table, you are probably using anndept.announceToFaculty directly in the query string. You cannot do this because your database column only accepts integers, therefore true and false never get enter because they are not integers. When you set your database variable, do a simple if else statement saying:
if (anndept.announceToFaculty == true)
{
'set your query parameter = 1
} else {
'set your query parameter = 0
}
And it will update how you wish.
SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
the reason why you cannot set anndept.announceToFaculty to an integer (1 or 0) is because you declared it as a boolean [public bool announceToFaculty]. You can change it to an integer by setting the above declaration to "public int announceToFaculty] and you will be able to set it to (1 or 0). If it is required for you to have announceToFaculty as a boolean, create a second variable and make it an integer. This isn't needed as you can set any value within a parameter at the end of the struct anyway:
if (anndept.announceToFaculty.Checked) {
'set parameter equal to 1
} else {
'set parameter equal to 0
}
And you do not need to say:
if (facultychecked.Checked == true)
any checkbox referred to in code is defaulted to true. so saying "if (facultychecked.Checked)" is the same as saying "if (facultychecked.Checked == true)". It's just better programming, but not anything bad.hi shesaidimapregy,
seeing u in this forum after a long time.i have created a object for announcemetBO
public struct AnnouncementBO
{
public bool announceToFaculty;
}
and called this object to my ui page
AnnouncementBO anndept = new AnnouncementBO();
if (facultychecked.Checked == true)
{
anndept.announceToFaculty = true;
}
else
{
anndept.announceToFaculty = false;
}
and iam assgining this object to the businesslogic layer.
iam getting error of invalid cast error ,can not convert bool to int
sorry that i could not reply earlier
SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
Sir, you have this right here:
public bool announceToFaculty;
Which means you can only assign true or false to it. If you are not allowed, change this part to:
public int announceToFaculty;
And assign 1/0.
SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68