Hi Vanessa,
You need to check the FileUpload has file or not. If not the insert null value.
Refer below modified code.
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
Using con = OpenCon()
Dim cmd As New SqlCommand
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "INSERT_APPLICATION"
cmd.CommandType = CommandType.StoredProcedure
If FileUpload1.HasFile Then
Dim filename As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
FileUpload1.SaveAs(Server.MapPath("Files/" & filename))
With cmd.Parameters
.Clear()
.AddWithValue("@Service", cboServices.Text.Trim())
.AddWithValue("@NameOfClient", txtName.Text.Trim())
.AddWithValue("@FileName", filename)
.AddWithValue("@FilePath", "Files/" & filename)
.AddWithValue("@DateAdded", DateTime.Now.ToString)
End With
Else
With cmd.Parameters
.Clear()
.AddWithValue("@Service", cboServices.Text.Trim())
.AddWithValue("@NameOfClient", txtName.Text.Trim())
.AddWithValue("@FileName", DBNull.Value)
.AddWithValue("@FilePath", DBNull.Value)
.AddWithValue("@DateAdded", DateTime.Now.ToString)
End With
End If
cmd.ExecuteNonQuery()
End Using
End Sub