在本地,但沒有工作,我有一個插入日期的形式..日期時間在服務器上
在本地工作,當我提交表單它工作得不得了,並保存日期到服務器。
但是當我嘗試從服務器這樣做,我得到一個錯誤:
String was not recognized as a valid DateTime.System.Collections.ListDictionaryInternal
代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
public partial class test : System.Web.UI.Page
{
protected void dog_add_submit_Click(object sender, EventArgs e)
{
/*Create and Populate Dog*/
Dog d = new Dog();
try
{
d.DogName = dog_add_name.Text;
d.ImageUrl = SaveImages();
d.Colour = dog_add_colour.Text;
d.PlaceFrom = dog_add_placeFrom.Text;
d.Breed = dog_add_breed.Text;
d.ArrivalDate = DateTime.Parse(txtDate.Text);
//if fields were populated properly in c# proceed to insert into database
try
{
int numEffected = d.doginsert();
// Response.Write("num of effected rows are " + numEffected.ToString());
Response.Redirect("MedicalHistoryAdd.aspx?dogid=" + d.SqldogID);
}
catch (Exception ex)
{
Response.Write("There was an error when trying to insert the dog into the database" + ex.Message);
}
}
catch (Exception ex)
{
Response.Write(ex.Message + ex.Data);
}
}
}
的可能重複[「字符串未被識別爲有效的DateTime」中唯一的服務器,但它是在我的本地系統工作正常(HTTP: //stackoverflow.com/questions/16495751/string-was-not-recognized-as-a-valid-datetime-in-server-only-but-it-is-working) – Suji