ASP.NET form:
<asp:SqlDataSource ID="dsLoan" runat="server" ConnectionString="<%$ ConnectionStrings:connLibrarySystem %>"
ProviderName="<%$ ConnectionStrings:connLibrarySystem.ProviderName %>"
SelectCommand="SELECT TOP 1 LOAN.LoanID FROM (BOOKS INNER JOIN LOAN ON BOOKS.ACCESSION = LOAN.ACCESSION) WHERE (BOOKS.ACCESSION = @Accession) ORDER BY LOAN.LoanID DESC"
UpdateCommand="UPDATE LOAN SET DATE_OF_RETURN = @ReturnDate, OverDate = 3 WHERE (LOAN.LoanID = @LoanID)"><SelectParameters><asp:ControlParameter ControlID="tbAccession" Name="Accession" PropertyName="Text" Type="String" /></SelectParameters><UpdateParameters><asp:SessionParameter SessionField="LoanID" Name="LoanID" Type="Int32" /><asp:Parameter Name="ReturnDate" Type="DateTime" /></UpdateParameters></asp:SqlDataSource>C# Function
protected void btnBookReturn_Click(object sender, EventArgs e)
{
// Select the latest LoanID based on the specified Book Accession
int loanID = int.Parse((this.dsLoan.Select(DataSourceSelectArguments.Empty) as DataView).Table.Rows[0]["LoanID"].ToString());
Session["LoanID"] = loanID;
// Update the Return Date of the corresponding loan record to today
this.dsLoan.UpdateParameters["ReturnDate"].DefaultValue = DateTime.Today.ToShortDateString();
// Update the Loan record
this.dsLoan.Update();After the update is completed, the Overdate column in the target record is updated but the DATE_OF_RETURN column remains unchanged.
Even if I have insert the following code snippet inside the SqldDataSource and update the C# code as belows,
OnUpdating="dsLoan_Updating"
protected void dsLoan_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
e.Command.Parameters["ReturnDate"].Value = DateTime.Today;
}The problem still occurs.
Please advice how to solve this problem. Thanks in advance.