I am wondering how to use the SQL variable as a cmd.Parameters.AddWithValue "value."
In this case the update_table would be written '08-01-2020'
The STATIC value needs to be exactly that. Each year on 08-01-yyyy I need to be reminded to file Federal paperwork. Once the paperwork is filed then I check it off as complete and write the next year's "reminder date" so it is not overlooked again.
I am updating the DB to a new date 1 year in the future which will be used to check against and then kick a reminder up that the date is approaching. That part of the code works fine. I'm not sure how to properly use the @Year value.
The area in question is red emboldened:
Code:If ccbUCR.Checked = True Then Try cmd.CommandType = CommandType.Text cmd.CommandText = ("DECLARE @reportYear int = YEAR(getdate()) + 1 Declare @Year date = concat('08-01-', @reportYear) Update Last_Update_table SET UCR = @ucr") cmd.Parameters.AddWithValue("@ucr", "@Year") cmd.Connection = con con.Open() cmd.ExecuteNonQuery() MsgBox("UCR Update Successfully Added", MsgBoxStyle.Information, "Add") Catch ex As Exception MessageBox.Show(ex.Message) End Try cmd.Connection.Close() End If




Reply With Quote
