I have a bit field in sql server represented by a checkbox ...
I am updating the database in code ( ie not using formview generated update .. )
the line that is falling over is
.Parameters.Add("@.archive", SqlDbType.Bit).Value = txtarchive.Checked
it falls over saying
failed to convert string parameter to boolean
thevalue of txtarchive.checked is either true or false - how do i convertthis to 1 or 0 or something that sql is happy with ...
thanks
you can use IIF. Give this a try:
IIF(txtarchive.Checked = TRUE, 1,0)
NDinakar's solution should work, but I'm confused as to the problem since I have pretty much the same thing you did, and it works fine.
The only difference is how the parameter was set up, I not only told it that it was a bit, but also a size of 1. (Actually, the sql command/parameters were set up by using a designer, and I copied the code)
No comments:
Post a Comment