I'm pretty much a novice at all this. I know bits. Just trying to store a date in an SQL database. I've set it to 06/06/2015 temporarily in code below to see if I can get it to update but it updates it as 01/01/0001. When I suss it, The value I actually want to store is todays date plus 6 months. EG: if its 31/07/2015 today, I want it to store 31/01/2016. Can anyone help ? Much appreciated...
ASPX.VB
Protected Sub imgBtnDatechange_Click(sender As Object, e As ImageClickEventArgs) Handles imgBtn.Click
Dim acc As New accounts(Membership.GetUser().ProviderUserKey)
Dim adjustedDate as Date = "06/06/2015"
acc.UpdateVipEndDate(acc.accountID, acc.adjustedDate)
End Sub
ACCOUNTS.VB
Public Property adjustedDate As Date
Public Sub UpdateVipEndDate(ByVal accountID As Guid, ByVal adjustedDate As Date)
Dim DBConnect As New DBConn
Using db As DbConnection = DBConnect.Conn("DBConnectionString")
Dim cmd As SqlCommand = DBConnect.Command(db, "UpdateVipEndDate")
cmd.Parameters.Add(New SqlParameter("accountID", SqlDbType.UniqueIdentifier, ParameterDirection.Input)).Value = accountID
cmd.Parameters.Add(New SqlParameter("newadjustedDate", SqlDbType.Date, ParameterDirection.Input)).Value = adjustedDate
db.Open()
cmd.ExecuteNonQuery()
cmd.Dispose()
cmd = Nothing
db.Dispose()
db.Close()
End Using
End Sub
STORED PROCEDURE
CREATE PROCEDURE [UpdateVipEndDate]
@accountID uniqueidentifier,
@newadjustedDate date
AS
BEGIN
UPDATE tblAccounts SET [vipEndDate] = @newadjustedDate WHERE [accountID] = @accountID
END