How to insert NULL into database if form field is empty

前端 未结 7 825
花落未央
花落未央 2021-01-01 17:56

I have a form and stored procedure that inserts the data from the form. It works fine except that if a field isn\'t filled in it doesn\'t insert a NULL into SQL

7条回答
  •  不思量自难忘°
    2021-01-01 18:50

    You need to use DBNull.Value

                If String.IsNullOrEmpty(pd_first_name.Text.ToString().Trim) = true Then
                    frmFirstName = DBNull.Value
                Else
                    frmFirstName = pd_first_name.Text
                End If
    

提交回复
热议问题