I want to parse a string value that is displayed in a label and then insert that value along with other values to a table in a database .. so I have the stored procedure that contains the insert statement and a method that performs performs the insert statement and finally I call the method in my button click event to perform the insert method but it gives me an exception message "Input string was not in correct format" and a tip which is "Parse the string to take the date before putting each variable into datetime object"
the call of this method in the button click event is:
DateTime billDateTime = DateTime.Parse(pBillDateLbl.Text);
purchaseCashBill.InsertGeneralCashBillInfo(billDateTime, pBillUserNameTxt.Text, Convert.ToInt32(pBillCompCmbo.SelectedValue), pBillCompCmbo.SelectedText, Convert.ToDouble(pBillItmTtlPrice.Text), true);
I have also tried to pare the string using this way also but the same exception appears:
DateTime billDateTime = DateTime.ParseExact(
pBillDateLbl.Text,
"d/M/yyyy hh:mm:ss",
System.Globalization.CultureInfo.CurrentCulture);
and the value of the label is in the form of:
pBillDateLbl.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
appears like this in my application :05:45:22 05/04/2017