How can I programaticallty check a ms-access check box with C# code(yes/no).problem is when I return the checked or unchecked value it will always return true, whether the box is checked or unchecked. \[code\]using (OleDbConnection myOLEDBConn = new OleDbConnection(ConfigurationManager.AppSettings["conn"])) { myOLEDBConn.Open(); bool value = http://stackoverflow.com/questions/14474626/false; OleDbCommand cmd = myOLEDBConn.CreateCommand(); cmd.CommandText ="SELECT [PreviewLibraryChecked] FROM [tblProducts] WHERE
Code:
= 'SUPN-011'"; OleDbDataReader dbread = cmd.ExecuteReader(); if (dbread.Read()) { value = http://stackoverflow.com/questions/14474626/(bool)dbread["PreviewLibraryChecked"]; } }\[/code\]This is my update command that also does not make any difference to the check box even though it does not cause an error either.\[code\]using (OleDbConnection myOLEDBConn = new OleDbConnection(ConfigurationManager.AppSettings["conn"])) { myOLEDBConn.Open(); OleDbCommand cmd = myOLEDBConn.CreateCommand if (chkPreview.Checked) { cmd.CommandText = @"UPDATE tblProducts SET [PreviewLibraryChecked] = true WHERE [CODE] = '" + codevalue + "'"; cmd.ExecuteNonQuery(); } else { cmd.CommandText = @"UPDATE tblProducts SET [PreviewLibraryChecked] = false WHERE [CODE] = '" + codevalue + "'"; cmd.ExecuteNonQuery(); } }\[/code\]