SQLTeam.com | Weblogs | Forums

cmd.Parameters.AddWithValue


#1

I am wondering if it is possible to concatenate a parameter in the cmd.Parameters.AddWithValue.
In this case the update_table would be written '08-01-2020

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 concatenate, properly, the value to be written.

DECLARE @reportYear int = YEAR(getdate()) + 1

                                UPDATE Last_Update_table
                                SET FHU = @fhu")

            cmd.Parameters.AddWithValue("@fhu", SqlDbType.DateTime), value = "08-01-" + "@reportYear"

            cmd.Connection = con
            con.Open()
            cmd.ExecuteNonQuery()

#2

This sounds like a vb question. You need to start using stored procedures.
Also why do you have a static value of 08-01 or is that just a sample.


#3

I am building Stored procedures thus why it looks like I'm asking a lot of question. Apologize for that.

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 s filed then I check it off as complete and I want to write the next year's "reminder date" so it is not overlooked again.


#4

No need to apologize just asking. When you call this vb code what is the value of @fhu