|
-
Sep 28th, 2004, 03:33 PM
#1
Thread Starter
Hyperactive Member
jump in code?
Is there a way to jump to a different spot in my coding if I get to this?:
Catch exp As Exception
Thanks!
Brenda
-
Sep 28th, 2004, 03:55 PM
#2
well what do you mean by JUMP??? it sounds like a dreaded GOTO if you are talking about what I think you are talking about... but lets say you had a sub routine to handle something, you could certainly call it from the catch block
VB Code:
Try
'Code here
Catch exp As Exception
MySubroutine 'calls subroutine to do stuff
End Try
but please clarify what you mean exactly.
-
Sep 28th, 2004, 03:59 PM
#3
Thread Starter
Hyperactive Member
OK. This is what I have:
VB Code:
ElseIf dr("PartNumber") = 5 Then
Dim Insert_case As String
Insert_case = "INSERT INTO tblCapRec (CaseNumber,PartNumber,Status,InGDB, " & _
"DocsOrdered,DocsHere,AppHere,Ubum,Suspended,Trace,SentToHUD,SentToTSI, " & _
"SentToCredit,SpanishCase,PropAddress,PropCity,PropState,PropZipCode,Updated, " & _
"MailKey,MailedFirst,MortgageAmt,PaidUpFront,EndorseDate,Term,MatureDate,EncumDate, " & _
"HoldingMor,ServingMor,RcvdFromOld,RcvdFromRegular,RcvdFromRtn,RcvdFrom2s,RefundAmt, " & _
"RateCharged,FeeAmount,RemainingDue,AfterFee,AmtPaid,LateFees,LastName,FirstName, " & _
"MailAddress,MailCity,MailState,MailZipCode,HomePhone) " & _
"SELECT CaseNumber,6,2,0,0,0,0,0,0,0,0,0,0,0,PropAddress,PropCity,PropState, " & _
"PropZipCode,GETDATE(),1,GETDATE(),MortgageAmt,PaidUpFront,EndorseDate,Term, " & _
"MatureDate,EncumDate,HoldingMor,ServingMor,0,0,0,0,RefundAmt,RateCharged, " & _
"FeeAmount,RemainingDue,AfterFee,0,0,'" & txtLastName.Text & "','" & txtFirstName.Text & "', " & _
"'" & txtAddress.Text & "','" & txtCity.Text & "','" & cbStates.Text & "', " & _
"'" & txtZipCode.Text & "','" & txtPhone.Text & "' " & _
"FROM tblCapRec WHERE CaseNumber = '" & g_CaseNum & "' AND PartNumber = " & g_PartNum & ""
Dim SqlConn1 As SqlConnection = New SqlConnection(strConnectionString)
Dim cmdSqlCommand1 As SqlCommand = New SqlCommand(Insert_case, SqlConn1)
Try
g_PartNum = 6
cmdSqlCommand1.Connection.Open()
cmdSqlCommand1.ExecuteScalar()
[color=red]Catch exp As Exception[/color]
MessageBox.Show(exp.Message)
Exit Sub
Finally
If SqlConn1.State = ConnectionState.Open Then
SqlConn1.Close()
End If
End Try
If it gets to the Catch Exception, I would like to jump to the next ElseIf Statement. Or is that bad to do?
Brenda
-
Sep 28th, 2004, 04:36 PM
#4
you cant do that without a goto, is goto even supported anymore in .net?? If it is its for backwards compatibility (very backwards). even if it was, it would be HIGHLY HIGHLY NOT RECOMMENDED to use it... that being said, what is the next elseif anyway? if it is just some cleanup code or something like that, put it in its own subroutine, so you can call it from wherever you need to call it from and you wont have nasty spaghetti code.
-
Sep 28th, 2004, 11:45 PM
#5
Originally posted by kleinma
you cant do that without a goto, is goto even supported anymore in .net??
Yes it is. 
brendalisalowe, what happens in the next ElseIf statement? Would that ElseIf block be called ONLY if there's an exception?
Also, shouldn't you be checking for SQLException?
-
Sep 29th, 2004, 09:44 AM
#6
Thread Starter
Hyperactive Member
So this is better to do?:
Catch exp As SqlException
I need to think more about what I am trying to do in my coding with the ElseIF. I'll let you know what I think later today. Thanks!
Brenda
-
Sep 29th, 2004, 11:14 AM
#7
Frenzied Member
Your next elseif should be checking for another part #, not checking for some database error.
Besides the subroutine method described above, you can throw the exception and have it caught elsewhere. But the next elseif isn't a good place to do that.
Tengo mas preguntas que contestas
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|