webform
によって、SQL
データベースのテーブルに新しい行を挿入しようとしています。CのExecuteNonQueryのSQLステートメント
問題は、deliverymanの割り当てが完了したときの説明にDateTime
の値を配置する必要があることです。
しかし、値が文字列で、要件は、この"Received parcel by StationMgrSG on 19 July 2016 10:34am"
のようなものを表示することですが、私のコードので、そのように私は値を変更するにはどうすればよい
をこの「@TimeNow上StationMgrSGで受信された小包」のようなものが表示されます日付と時刻が表示されますか?
これは私のコードです:
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;
}
このデータのDBにDateTime列がある場合はさらに優れています。 –