0

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>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Nita
  • 195
  • 3
  • 8
  • 20

2 Answers2

0

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)
user2526236
  • 1,538
  • 2
  • 15
  • 29
  • I am using SQLDataSource so where can I add this code? Should I add onclick event to EditTemplate Update button? – Nita Nov 04 '13 at 20:52
  • I do not get the option of "SqlCommand" when I try to declare in VS2012. – Nita Nov 25 '13 at 15:50
0

This solution worked for me. I modified the "UpdateCommand" to say

UpdateCommand="UPDATE [Table] SET [ModifiedOn]=GetDate(),.............."
p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
Nita
  • 195
  • 3
  • 8
  • 20