I am trying to insert a new row into a table in my SQL database through a webform.
The problem is that I need to place the DateTime value in the Description of when the assignment of deliveryman was done.
But because the value is a string and the requirement is to display something like this "Received parcel by StationMgrSG on 19 July 2016 10:34am" but my codes is displaying something like this "Received parcel by StationMgrSG on @TimeNow"
How do i change the value so that it displays the date and time?
This is my code:
public int updateDeliveryHistory() { string strConn = ConfigurationManager.ConnectionStrings["NPCSConnectionString"].ToString(); SqlConnection conn = new SqlConnection(strConn); SqlCommand cmad = new SqlCommand("INSERT INTO DELIVERYHISTORY(ParcelID, Description) VALUES (@ParcelId,'Received parcel by StationMgrSG on @TimeNow')",conn); cmad.Parameters.AddWithValue("@ParcelId", parcelID); cmad.Parameters.AddWithValue("@TimeNow", DHCreateTime); conn.Open(); cmad.ExecuteNonQuery(); conn.Close(); return 0; }