Hi,

In C#, i got sql Exception which consists of 2 lines.
I need only the 2nd line of that Exception only.

Ex:
The transaction ended in the trigger.
Table Validation failed - Name: x; Condition: m!=0

i need "Table Validation failed - Name: x; Condition: m!=0" only.
I have tried e.LineNumber but it not works well.

Can anyone help me?

Recommended Answers

All 2 Replies

Hi,

In C#, i got sql Exception which consists of 2 lines.
I need only the 2nd line of that Exception only.

Ex:
The transaction ended in the trigger.
Table Validation failed - Name: x; Condition: m!=0

i need "Table Validation failed - Name: x; Condition: m!=0" only.
I have tried e.LineNumber but it not works well.

Can anyone help me?

Hi

One way of doing it could be:

catch (Exception ex)
{
	string[] lines = Regex.Split(ex.Message, "\r\n");
	MessageBox.Show(lines[1]);
}

Good luck!

Gossp!
It works,.../

Thanks
Chandru

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.