我的代码给出了以下错误:输入字符串的格式不正确。
有这个提示:
将字符串转换为 DateTime 时,在将每个变量放入 DateTime 对象之前解析字符串以获取日期
下面是我的代码:( 编辑为只显示有问题的代码)
string username ="aits";
string password = "12345";
Int32 intresortid=7;
string strPartySurname = "Kumar"; ;
string strPartyFirstName = "Test";
string strPartyPrefix = "Mr & Mrs";
Int16 intQtyAdults=1;
Int16 intQtyTotal=1;
string PromotionCode = "TIF";
string flightNO = "FlighDJ76";
string strNotes = "<nl>Provide Breakfast<nl>Honeymooners";
try
{
string url = string.Format("http://localhost/insHold.asp?username={0}&password={1}&intresortid={2}&strPartySurname={3}&strPartyFirstName={4}&strPartyPrefix={5}&intQtyAdults={6}&intQtyTotal={7}&dtmLine1={8:yyyy-MM-dd}&strRoomType1={9}&intRooms1={10}&intnights1={11}&strFlightNo={12}&strNotes={13}&strBookingCode={14}&strPromotionCode={15}", username, password, intresortid, strPartySurname, strPartyFirstName, strPartyPrefix, intQtyAdults, intQtyTotal, CheckInDate, BBRoom, RoomQty, NoofNights, flightNO, strNotes, ResBookingID, PromotionCode);
WebRequest request = HttpWebRequest.Create(url);
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string urlText = reader.ReadToEnd();
bookid = Convert.ToInt16(urlText);
}
catch (System.ApplicationException ex)
{
throw ex;
}
我不知道如何将其更正为我的 DateTime 值:CheckInDate 已经是日期类型。
有人可以告诉我如何解决这个问题或指出我正确的方向。