I have this code:
If SalaryCbx.Checked = True Then
fundSalary = "S" <- Throws an error
Else
fundSalary = "N" <- Throws an error
End If
SonarQube throws a "Critical" error:
Assignment is not used
(Category: Redundancies in Code)
resharper-vbnet RedundantAssignment
Value assigned is not used in any execution path
Is there a better way to write this kind of logic?
I tried a Select Case
statement but it also threw the error.
I also use this same code except for different variables/checkboxes and it works fine - no errors.
Update: Here's where I am using it.
Dim insertQry As String = "INSERT INTO FUND (FUND_ID, FUND_NM, FUND_TICKER_NM, FUND_SALARY_IND, FUND_BONUS_IND, FUND_ALCTN_IND, BEG_DT, END_DT) "
insertQry &= " VALUES(@FundID, @fndName, @fndTicker, @fndSalary, @fndBonus, @fndAllocation, @fndBeg, @fndEnd) "
'Code omitted
'Declare Connection String
Using sqlConnection As New SqlConnection(myConn)
'Declare variable for SQL command
Using cmd As New SqlCommand(insertQry)
With cmd
.Connection = sqlConnection
.CommandType = CommandType.Text
.Parameters.AddWithValue("@FundID", id)
.Parameters.AddWithValue("@fndName", fundName)
.Parameters.AddWithValue("@fndTicker", fundTicker)
.Parameters.AddWithValue("@fndSalary", fundSalary)