How to pass a null variable to a SQL Stored Procedure from C#.net code

前端 未结 8 425
失恋的感觉
失恋的感觉 2020-12-02 19:41

Im calling a SQL stored procedure from a piece of C#.net code:

SqlHelper.ExecuteDataset(sqlConnection, CommandType.StoredProcedure, STORED_PROC_NAME, sqlPara         


        
8条回答
  •  北海茫月
    2020-12-02 20:30

    You can pass the DBNull.Value into the parameter's .Value property:

        SqlParameters[0] = new SqlParameter("LedgerID", SqlDbType.BigInt );
        SqlParameters[0].Value = DBNull.Value;
    

    Just adjust for your two DateTime parameters, obviously - just showing how to use the DBNull.Value property value here.

    Marc

提交回复
热议问题