VS .net 2005, Windows aplikacija, C#
ima li mogućnosti u VS .Netu, da se na osnovu broja greške, ispiše odgovarajuća poruka korisniku.
naime, testiram jednu aplikaciju, koja za bazu koristi MS SQL 2005.
Postavio sam try-catch kod, i Logovanje grešaka.
Medjutim, ono što me zanima, je da li mogu (kao što može u Accessu) na osnovu broja greške da se korisniku prikaže odgovarajuća poruka
tipa.
try
{
uradi nesto ....
}
catch (5608)
{
MessageBox.Show("Prekinula se konekcija sa bazom. Pokrenite program opet")
{
catch (6208)
{
MessageBox.Show("Prekinula se konekcija sa bazom. Pokrenite program opet")
{
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
Evo recimo, nekih grešaka koje sam dobio, kada sam usred rada stopirao MS SQL server
Prva greška
2009-12-09 23:45:13,785 [5608] ERROR - System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)
Druga greška (ista kao prva, samo što je sistem izbacio različiti kod ? )
2009-12-09 23:35:42,429 [6268] ERROR - System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)
Treca greska (ovo je vec greška u kodu)
2009-12-04 21:49:42,204 [4432] ERROR - System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Windows.Forms.DataGridViewSelectedRowCollection.get_Item(Int32 index)
Kako bi vi ove greske prikazali korisniku ??? ako imu izadju ove cifre, i silni podaci, samo ce se uplasiti :))