C# Programming
11-11-2009, 08:22 AM
Hi,
I am using a text box on the UI to query the database using the entered text.
Following is the code snippet
string refNum = (from Example in db.Orders
where Example.Reference == textBox1.Text
select Example.OrderId).First().ToString();
My question is..
How to show a friendly error message if Example.Reference is not equal to input value in textBox OR if no value is entered into the text field ?
Because am getting this error "{"Sequence contains no elements"}" when no value is entered or if any wrong value is eneterd. Can any1 tell me how to catch this error and show it as a friendly message to the user.
Thanks,
I am using a text box on the UI to query the database using the entered text.
Following is the code snippet
string refNum = (from Example in db.Orders
where Example.Reference == textBox1.Text
select Example.OrderId).First().ToString();
My question is..
How to show a friendly error message if Example.Reference is not equal to input value in textBox OR if no value is entered into the text field ?
Because am getting this error "{"Sequence contains no elements"}" when no value is entered or if any wrong value is eneterd. Can any1 tell me how to catch this error and show it as a friendly message to the user.
Thanks,