Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string wrongType = "This is not a date";
- command.Parameters.Add("@Date", SqlDbType.DateTime).Value = wrongType;
- string wrongType = "This is not a date";
- DateTime rightTyped;
- if(DateTime.TryParse(wrongType, out rightTyped))
- {
- command.Parameters.Add("@Date", SqlDbType.DateTime).Value = rightTyped;
- }
- string wrongType = "This is not a date";
- DateTime date;
- if(DateTime.TryParse(wrongType, out date))
- {
- // staff when string converted
- }
- string wrongType = "This is not a date";
- DateTime rightType = ...
- command.Parameters.Add("@Date", SqlDbType.DateTime).Value = rightType;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement