By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,668 Members | 1,606 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,668 IT Pros & Developers. It's quick & easy.

Pls clarify

P: n/a
Dear Guys

Equalant to OnError Resume Next in .net

My problem is : if error is found, it must contiune from next line. Like
OnError Resume Next in vb

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran
Nov 15 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
The only way to do this is to wrap each statement that might throw an
exception in its own try...catch block with an empty catch statement.

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Dear Guys

Equalant to OnError Resume Next in .net

My problem is : if error is found, it must contiune from next line. Like
OnError Resume Next in vb

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran

Nov 15 '05 #2

P: n/a
Dear Peter Rilling

pls give me some exampls or some articles website address.

thanx
G.Prabhakaran

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:ue**************@TK2MSFTNGP11.phx.gbl...
The only way to do this is to wrap each statement that might throw an
exception in its own try...catch block with an empty catch statement.

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Dear Guys

Equalant to OnError Resume Next in .net

My problem is : if error is found, it must contiune from next line. Like
OnError Resume Next in vb

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran


Nov 15 '05 #3

P: n/a
This eaxmple illustrate what Peter is saying

try
{
System.IO.FileInfo Info = new System.IO.FileInfo(tstrFileName);//This
may throw a exeption since file might not be exist
}
catch ()
{
}

string a = "hello";
string b = "How are you";
MessageBox.Show(a + ", " + b); //Even a file not found exception occured,
this line still be executed

Nirosh.

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:#e**************@TK2MSFTNGP10.phx.gbl...
Dear Peter Rilling

pls give me some exampls or some articles website address.

thanx
G.Prabhakaran

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:ue**************@TK2MSFTNGP11.phx.gbl...
The only way to do this is to wrap each statement that might throw an
exception in its own try...catch block with an empty catch statement.

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Dear Guys

Equalant to OnError Resume Next in .net

My problem is : if error is found, it must contiune from next line. Like OnError Resume Next in vb

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran



Nov 15 '05 #4

P: n/a
Dear Champika Nirosh

try
{
line 1: --------------------------//Assume that This may throw a
exeption
line 2 : ------------------------
line 3 : -----------------------//Assume that This may throw a exeption
line 4 : ------------------------
}
catch ()
{
}

Is there any possiable that when line 1 and line 3 throws exeption , it
must excute the line 2 and line 4.
and finally i want to write the exeption message in log file

thanx
prabhakaran.g

"Champika Nirosh" <no****@textcentric.lk> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
This eaxmple illustrate what Peter is saying

try
{
System.IO.FileInfo Info = new System.IO.FileInfo(tstrFileName);//This
may throw a exeption since file might not be exist
}
catch ()
{
}

string a = "hello";
string b = "How are you";
MessageBox.Show(a + ", " + b); //Even a file not found exception occured,
this line still be executed

Nirosh.

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:#e**************@TK2MSFTNGP10.phx.gbl...
Dear Peter Rilling

pls give me some exampls or some articles website address.

thanx
G.Prabhakaran

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:ue**************@TK2MSFTNGP11.phx.gbl...
The only way to do this is to wrap each statement that might throw an
exception in its own try...catch block with an empty catch statement.

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> Dear Guys
>
> Equalant to OnError Resume Next in .net
>
> My problem is : if error is found, it must contiune from next line. Like > OnError Resume Next in vb
>
> Thanx
> Gopal Prabhakaran
>
> --
> "Sucess Comes To Those Who Dare To Dream"
>
> Thanx
> Gopal Prabhakaran
>
>



Nov 15 '05 #5

P: n/a
string lstrError;
try
{
line 1: --------------------------//Assume that This may throw a
}
catch (System.Exception e1)
{
lstrError = e1.Message;
}
line 2 : ------------------------
try
{
line 3 : -----------------------//Assume that This may throw a exeption
}
catch (System.Exception e2)
{
lstrError += "\n" + e2.Message;
}
line 4 : ------------------------

That's All

Nirosh

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:e#**************@tk2msftngp13.phx.gbl...
Dear Champika Nirosh

try
{
line 1: --------------------------//Assume that This may throw a
exeption
line 2 : ------------------------
line 3 : -----------------------//Assume that This may throw a exeption line 4 : ------------------------
}
catch ()
{
}

Is there any possiable that when line 1 and line 3 throws exeption , it
must excute the line 2 and line 4.
and finally i want to write the exeption message in log file

thanx
prabhakaran.g

"Champika Nirosh" <no****@textcentric.lk> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
This eaxmple illustrate what Peter is saying

try
{
System.IO.FileInfo Info = new System.IO.FileInfo(tstrFileName);//This may throw a exeption since file might not be exist
}
catch ()
{
}

string a = "hello";
string b = "How are you";
MessageBox.Show(a + ", " + b); //Even a file not found exception occured, this line still be executed

Nirosh.

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:#e**************@TK2MSFTNGP10.phx.gbl...
Dear Peter Rilling

pls give me some exampls or some articles website address.

thanx
G.Prabhakaran

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:ue**************@TK2MSFTNGP11.phx.gbl...
> The only way to do this is to wrap each statement that might throw an > exception in its own try...catch block with an empty catch statement. >
> "Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
> news:%2****************@tk2msftngp13.phx.gbl...
> > Dear Guys
> >
> > Equalant to OnError Resume Next in .net
> >
> > My problem is : if error is found, it must contiune from next
line. Like
> > OnError Resume Next in vb
> >
> > Thanx
> > Gopal Prabhakaran
> >
> > --
> > "Sucess Comes To Those Who Dare To Dream"
> >
> > Thanx
> > Gopal Prabhakaran
> >
> >
>
>



Nov 15 '05 #6

P: n/a
Same time Please note that this is possible only if the line 2 and 4 has no
effect at all from the exceptions occured at line 1 and 3. but if they have
any effect then you may have to handle the exception accoringly

regards
Nirosh

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:e#**************@tk2msftngp13.phx.gbl...
Dear Champika Nirosh

try
{
line 1: --------------------------//Assume that This may throw a
exeption
line 2 : ------------------------
line 3 : -----------------------//Assume that This may throw a exeption line 4 : ------------------------
}
catch ()
{
}

Is there any possiable that when line 1 and line 3 throws exeption , it
must excute the line 2 and line 4.
and finally i want to write the exeption message in log file

thanx
prabhakaran.g

"Champika Nirosh" <no****@textcentric.lk> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
This eaxmple illustrate what Peter is saying

try
{
System.IO.FileInfo Info = new System.IO.FileInfo(tstrFileName);//This may throw a exeption since file might not be exist
}
catch ()
{
}

string a = "hello";
string b = "How are you";
MessageBox.Show(a + ", " + b); //Even a file not found exception occured, this line still be executed

Nirosh.

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:#e**************@TK2MSFTNGP10.phx.gbl...
Dear Peter Rilling

pls give me some exampls or some articles website address.

thanx
G.Prabhakaran

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:ue**************@TK2MSFTNGP11.phx.gbl...
> The only way to do this is to wrap each statement that might throw an > exception in its own try...catch block with an empty catch statement. >
> "Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
> news:%2****************@tk2msftngp13.phx.gbl...
> > Dear Guys
> >
> > Equalant to OnError Resume Next in .net
> >
> > My problem is : if error is found, it must contiune from next
line. Like
> > OnError Resume Next in vb
> >
> > Thanx
> > Gopal Prabhakaran
> >
> > --
> > "Sucess Comes To Those Who Dare To Dream"
> >
> > Thanx
> > Gopal Prabhakaran
> >
> >
>
>



Nov 15 '05 #7

P: n/a
Dear Champika Nirosh

Is there any other way ? say i have 100 lines what should i do ? i don't
know which line will throw error ?

Pls tell me other way ?

Thanx
G.Prabhkaran
"Champika Nirosh" <no****@textcentric.lk> wrote in message
news:#6**************@TK2MSFTNGP09.phx.gbl...
Same time Please note that this is possible only if the line 2 and 4 has no effect at all from the exceptions occured at line 1 and 3. but if they have any effect then you may have to handle the exception accoringly

regards
Nirosh

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:e#**************@tk2msftngp13.phx.gbl...
Dear Champika Nirosh

try
{
line 1: --------------------------//Assume that This may throw a
exeption
line 2 : ------------------------
line 3 : -----------------------//Assume that This may throw a

exeption
line 4 : ------------------------
}
catch ()
{
}

Is there any possiable that when line 1 and line 3 throws exeption , it
must excute the line 2 and line 4.
and finally i want to write the exeption message in log file

thanx
prabhakaran.g

"Champika Nirosh" <no****@textcentric.lk> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
This eaxmple illustrate what Peter is saying

try
{
System.IO.FileInfo Info = new System.IO.FileInfo(tstrFileName);//This may throw a exeption since file might not be exist
}
catch ()
{
}

string a = "hello";
string b = "How are you";
MessageBox.Show(a + ", " + b); //Even a file not found exception occured, this line still be executed

Nirosh.

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:#e**************@TK2MSFTNGP10.phx.gbl...
> Dear Peter Rilling
>
> pls give me some exampls or some articles website address.
>
> thanx
> G.Prabhakaran
>
> "Peter Rilling" <pe***@nospam.rilling.net> wrote in message
> news:ue**************@TK2MSFTNGP11.phx.gbl...
> > The only way to do this is to wrap each statement that might throw an > > exception in its own try...catch block with an empty catch statement. > >
> > "Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
> > news:%2****************@tk2msftngp13.phx.gbl...
> > > Dear Guys
> > >
> > > Equalant to OnError Resume Next in .net
> > >
> > > My problem is : if error is found, it must contiune from next line. Like
> > > OnError Resume Next in vb
> > >
> > > Thanx
> > > Gopal Prabhakaran
> > >
> > > --
> > > "Sucess Comes To Those Who Dare To Dream"
> > >
> > > Thanx
> > > Gopal Prabhakaran
> > >
> > >
> >
> >
>
>



Nov 15 '05 #8

P: n/a
I think you got to know about the code you are writing so there you should
know which line throw a exception, again your requirement also quite
awkward.

I am not sure how you are executing a line while ignoring the exception
thrown by the previous line I mean these line should have some relation.. I
guess this has something to do with the initial design of the system.

Please get me more specific data then I can try to help you.

If you have already given the full detail the solution is cathing all the
exception thrown by each line (even though there are 100 lines). I mean not
all lines throw exception so you got to find which line throw exceptions ..
lines like string s = "hello"; will not throw a exception at any rate.

Nirosh

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:#G**************@TK2MSFTNGP12.phx.gbl...
Dear Champika Nirosh

Is there any other way ? say i have 100 lines what should i do ? i don't
know which line will throw error ?

Pls tell me other way ?

Thanx
G.Prabhkaran
"Champika Nirosh" <no****@textcentric.lk> wrote in message
news:#6**************@TK2MSFTNGP09.phx.gbl...
Same time Please note that this is possible only if the line 2 and 4 has

no
effect at all from the exceptions occured at line 1 and 3. but if they

have
any effect then you may have to handle the exception accoringly

regards
Nirosh

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:e#**************@tk2msftngp13.phx.gbl...
Dear Champika Nirosh

try
{
line 1: --------------------------//Assume that This may throw a
exeption
line 2 : ------------------------
line 3 : -----------------------//Assume that This may throw a

exeption
line 4 : ------------------------
}
catch ()
{
}

Is there any possiable that when line 1 and line 3 throws exeption , it must excute the line 2 and line 4.
and finally i want to write the exeption message in log file

thanx
prabhakaran.g

"Champika Nirosh" <no****@textcentric.lk> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
> This eaxmple illustrate what Peter is saying
>
> try
> {
> System.IO.FileInfo Info = new

System.IO.FileInfo(tstrFileName);//This
> may throw a exeption since file might not be exist
> }
> catch ()
> {
> }
>
> string a = "hello";
> string b = "How are you";
> MessageBox.Show(a + ", " + b); //Even a file not found exception

occured,
> this line still be executed
>
> Nirosh.
>
> "Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
> news:#e**************@TK2MSFTNGP10.phx.gbl...
> > Dear Peter Rilling
> >
> > pls give me some exampls or some articles website address.
> >
> > thanx
> > G.Prabhakaran
> >
> > "Peter Rilling" <pe***@nospam.rilling.net> wrote in message
> > news:ue**************@TK2MSFTNGP11.phx.gbl...
> > > The only way to do this is to wrap each statement that might
throw an
> > > exception in its own try...catch block with an empty catch

statement.
> > >
> > > "Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
> > > news:%2****************@tk2msftngp13.phx.gbl...
> > > > Dear Guys
> > > >
> > > > Equalant to OnError Resume Next in .net
> > > >
> > > > My problem is : if error is found, it must contiune from next

line.
> Like
> > > > OnError Resume Next in vb
> > > >
> > > > Thanx
> > > > Gopal Prabhakaran
> > > >
> > > > --
> > > > "Sucess Comes To Those Who Dare To Dream"
> > > >
> > > > Thanx
> > > > Gopal Prabhakaran
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 15 '05 #9

P: n/a
Dear Champika Nirosh

When I try to add a record in a table (' using funtion zAddRec which shown
below'), Say if some other user has locked the table . I have to wait for
some time ,and i want to add the record after he releases the lock

how to proceed with managed exception.

Example :

Private Function zAddRec(sod As tsod) As Boolean
zAddRec = False
On Error GoTo err1
open_table
If Not RsAddNew(mytbl) Then Exit Function
mytbl!Fiscalyear = sod.Fiscalyear
mytbl!CusAcNo = NTrim(sod.CusAcNo)
mytbl!SoNo = NTrim(sod.SoNo)
mytbl!Slno = NTrim(sod.Slno)
If Not RsUpdate(mytbl) Then Exit Function
close_table
zAddRec = True
Exit Function
err1:
gERC = ErrDetails(" B1SOD AddRec")
Select Case gERC
Case gResume: Resume
Case gResumeNext: Resume Next
Case gEnd: End
Case gCxlUpdate: 'IF APPL write code here
Case gUptoU: 'Code here Context sensitive
Case gExit: 'Do nothing (Drops down)
End Select
Exit Function
End Function

************************************************** **************************
*****

Public Function ErrDetails%(ByVal Prochead$)
Dim fno%
Dim Ans As Long
'
ErrDetails = gExit
'
If Err.Number > 0 Then
If Err.Number > 3000 And Err.Number < 3999 Then

Select Case Err.Number
Case 3020 'using update without edit/addnew
ErrBox Err.Number & " " & Err.Description
ErrDetails = gEnd
Case 3197
Ans = MsgBox("Data has been changed by another
user,Overwrite changes ?", vbYesNo)
If Ans = vbYes Then
ErrDetails = gResume
Else
ErrDetails = gCxlUpdate
End If
Case Else
ErrBox Err.Number & " : " & Err.Description
ErrDetails = gExit
End Select
Else
ErrBox Err.Number & " : " & Err.Description
ErrDetails = gUptoU
End If
fno = FreeFile
Open oSession.Path & "Err.Txt" For Append As #fno
Print #fno, ERROR DETAILS
Close #fno
End If
End Function

Thanx

Gopal Prabhakaran

"Champika Nirosh" <no****@textcentric.lk> wrote in message
news:eM*************@tk2msftngp13.phx.gbl...
I think you got to know about the code you are writing so there you should
know which line throw a exception, again your requirement also quite
awkward.

I am not sure how you are executing a line while ignoring the exception
thrown by the previous line I mean these line should have some relation.. I guess this has something to do with the initial design of the system.

Please get me more specific data then I can try to help you.

If you have already given the full detail the solution is cathing all the
exception thrown by each line (even though there are 100 lines). I mean not all lines throw exception so you got to find which line throw exceptions ... lines like string s = "hello"; will not throw a exception at any rate.

Nirosh

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:#G**************@TK2MSFTNGP12.phx.gbl...
Dear Champika Nirosh

Is there any other way ? say i have 100 lines what should i do ? i don't
know which line will throw error ?

Pls tell me other way ?

Thanx
G.Prabhkaran
"Champika Nirosh" <no****@textcentric.lk> wrote in message
news:#6**************@TK2MSFTNGP09.phx.gbl...
Same time Please note that this is possible only if the line 2 and 4 has
no
effect at all from the exceptions occured at line 1 and 3. but if they have
any effect then you may have to handle the exception accoringly

regards
Nirosh

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:e#**************@tk2msftngp13.phx.gbl...
> Dear Champika Nirosh
>
> try
> {
> line 1: --------------------------//Assume that This may throw a
> exeption
> line 2 : ------------------------
> line 3 : -----------------------//Assume that This may throw a
exeption
> line 4 : ------------------------
> }
> catch ()
> {
> }
>
> Is there any possiable that when line 1 and line 3 throws exeption
, it > must excute the line 2 and line 4.
> and finally i want to write the exeption message in log file
>
> thanx
> prabhakaran.g
>
>
>
> "Champika Nirosh" <no****@textcentric.lk> wrote in message
> news:OL**************@TK2MSFTNGP09.phx.gbl...
> > This eaxmple illustrate what Peter is saying
> >
> > try
> > {
> > System.IO.FileInfo Info = new
System.IO.FileInfo(tstrFileName);//This
> > may throw a exeption since file might not be exist
> > }
> > catch ()
> > {
> > }
> >
> > string a = "hello";
> > string b = "How are you";
> > MessageBox.Show(a + ", " + b); //Even a file not found exception
occured,
> > this line still be executed
> >
> > Nirosh.
> >
> > "Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
> > news:#e**************@TK2MSFTNGP10.phx.gbl...
> > > Dear Peter Rilling
> > >
> > > pls give me some exampls or some articles website address.
> > >
> > > thanx
> > > G.Prabhakaran
> > >
> > > "Peter Rilling" <pe***@nospam.rilling.net> wrote in message
> > > news:ue**************@TK2MSFTNGP11.phx.gbl...
> > > > The only way to do this is to wrap each statement that might throw an
> > > > exception in its own try...catch block with an empty catch
statement.
> > > >
> > > > "Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
> > > > news:%2****************@tk2msftngp13.phx.gbl...
> > > > > Dear Guys
> > > > >
> > > > > Equalant to OnError Resume Next in .net
> > > > >
> > > > > My problem is : if error is found, it must contiune from

next line.
> > Like
> > > > > OnError Resume Next in vb
> > > > >
> > > > > Thanx
> > > > > Gopal Prabhakaran
> > > > >
> > > > > --
> > > > > "Sucess Comes To Those Who Dare To Dream"
> > > > >
> > > > > Thanx
> > > > > Gopal Prabhakaran
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 15 '05 #10

P: n/a
Gopal Prabhakaran wrote:
Dear Champika Nirosh

When I try to add a record in a table (' using funtion zAddRec which
shown below'), Say if some other user has locked the table . I have
to wait for some time ,and i want to add the record after he
releases the lock

how to proceed with managed exception.

Example :


(snip)

10 Was your example just a generic example?
20 If not:
30 Are you sure you've understood how the .NET framework handles
database I/O?
40 If not: Read the MSDN, GoTo 30
Nov 15 '05 #11

P: n/a
I guess "Read the MSDN" has a "return" at the correct place
"Carsten Posingies" <c.*********@gmx.de> wrote in message
news:#Z**************@TK2MSFTNGP10.phx.gbl...
Gopal Prabhakaran wrote:
Dear Champika Nirosh

When I try to add a record in a table (' using funtion zAddRec which
shown below'), Say if some other user has locked the table . I have
to wait for some time ,and i want to add the record after he
releases the lock

how to proceed with managed exception.

Example :


(snip)

10 Was your example just a generic example?
20 If not:
30 Are you sure you've understood how the .NET framework handles
database I/O?
40 If not: Read the MSDN, GoTo 30

Nov 15 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.