Parameter has no default value if previous param is null?

前端 未结 1 714
一向
一向 2021-01-15 16:38

I have this query which seems to work unless I try to pass a null value in a parameter:

using (OleDbCommand com = new OleDbCommand(\"INSERT INTO [GROUP] ([Gr         


        
相关标签:
1条回答
  • 2021-01-15 17:09

    Parameters with a .Value of null are not passed. At all.

    You need to pass DBNull.Value instead to pass a semantic null. For example:

    com.Parameters.Add("@p7", OleDbType.Char, 255).Value =
             ((object)values7[0]) ?? DBNull.Value;
    

    (etc)

    And yes: I agree that this is ridiculous

    0 讨论(0)
提交回复
热议问题