How to insert DBNnull into binary column via parameter list?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jmaes Wang
    New Member
    • Oct 2010
    • 7

    How to insert DBNnull into binary column via parameter list?

    The table was created using the following script:
    Code:
    CREATE TABLE [USERS] (
    [USER_PASSWORD] binary(100) NULL
    );
    The SqlCeCommand command text:
    Code:
    INSERT INTO [USERS]
               ([PASSWORD])
         VALUES
               (@password);

    Add the parameter:
    Code:
    command.Parameters.Add("@password", SqlDbType.Binary).Value = DBNull.Value;
    Execute the command and get the error "Value was either too large or too small for an unsigned byte."

    Can you help please?
  • Jmaes Wang
    New Member
    • Oct 2010
    • 7

    #2
    The problem has been resolved. Actually it's another column that caused the error. I thought it was this column even though I couldn't figure out anything wrong.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32636

      #3
      No worries James, and thanks for posting to clarify.

      BTW if you'd like your account ID changed to James Wang instead, then send a PM to MMcCarthy about it. She's an Admin and I'm sure she'd be happy to fix it for you.

      Comment

      Working...