Reputation: 205
I am using Visual Studio 2012 with vb.net. I am trying to add modified date field into table when the user makes changes to the form in the EditItemTemplate. When I click on the "Edit" button I do see today's date in the field; however when I click on "Update" this date is not being entered into the table. The other fields get edited and saved, it is just the system date field.
UpdateCommand
has
... SET [ModifiedOn] = @ModifiedOn, [ModifiedNotes] = @ModifiedNotes
WHERE [PatronID] = PatronID
Update Parameter tag says
<asp:Parameter Name="ModifiedOn" DbType="Date" />
This is what I am saying for the textfield.
<asp:TextBox runat="server" ID="strModifiedDate" BackColor="Silver"
CssClass="padLR" Text='<%# DateTime.Now.ToString("d")%>' ReadOnly="true" ></asp:TextBox>
Upvotes: 0
Views: 261
Reputation: 205
This solution worked for me. I modified the "UpdateCommand" to say
UpdateCommand="UPDATE [Table] SET [ModifiedOn]=GetDate(),.............."
Upvotes: 0
Reputation: 1538
May be this can solve the issue to update the DB.
Dim myCommand As SqlCommand
'parametrized update sql command
sqlconn.Open()
myCommand = New SqlCommand("UPDATE Table_Name SET ModifiedOn= @ModifiedOn", sqlconn)
myCommand.Parameters.Add("@ModifiedOn", strModifiedDate.Text)
Upvotes: 0