1

I am getting an error msg when attempting to update a record from asp.net into a SQL database. The only boolean value being updated is:

cmdAddUser.Parameters.Add(new SqlParameter("@Active", SqlDbType.Bit));
cmdAddUser.Parameters["@Active"].Value = 
    Convert.ToBoolean(cbAddUserActiveUser.Checked);

The datatype for @Active in the database is "bit". Any ideas?

7
  • @user279521: You aren't really indicating what error you are getting. Try posting the exception information that you are getting so we can determine if it is a parse issue (on the call to ToBoolean) or something on the database side. Commented Jun 28, 2010 at 15:55
  • "Failed to convert parameter value from a String to a Boolean." is the error message. Commented Jun 28, 2010 at 15:56
  • Wild guess, but try Convert.ToBoolean(cbAddUserActiveUser.Checked.ToString()); Commented Jun 28, 2010 at 15:58
  • @Jason.... No luck.... Same error Commented Jun 28, 2010 at 16:01
  • What about trying without the convert.toboolean? Isn't .checked already a boolean value? Commented Jun 28, 2010 at 16:04

1 Answer 1

2

Long shot - have you got another parameter that is set as a string but is a bit column in the actual table?

Sign up to request clarification or add additional context in comments.

1 Comment

Good answer. I am modifying this proc that has about 24 paramters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.