This Format Exception tells you that your input(String myId
) is not in a recognized format.
You should handle exceptions clearly your input string format is incorrect so use Guid.TryParse
(This method returns false if input is null or not in a recognized format, and does not throw an exception.) . Here.
Also check for Guid.TryParseExact method .
myGuid = Guid.Parse(myId);
if (Guid.TryParse(myId, out newGuid))
{
try
{
myVehicleDetails.DateCreated = datecreated;
myVehicleDetails.Guid = myGuid;
dc.tblVehicleDetails.InsertOnSubmit(myVehicleDetails);
dc.SubmitChanges();
}
}
else
{
//Input string is not in correct format
}