Best method of assigning NULL value to SqlParameter

前端 未结 7 1322
野的像风
野的像风 2021-01-07 20:53

I have a number of optional input parameters I am using in a C# class method. Since the optional syntax creates a value of \'0\' when the parameter is not used, the SQL inse

相关标签:
7条回答
  • 2021-01-07 21:33

    short syntax!

      cmd.Parameters.Add(new SqlParameter{SqlValue=username ?? (object)DBNull.Value,ParameterName="usuario" }  );
    
    0 讨论(0)
提交回复
热议问题