Tildha's Profile
Reputation: 0
Apprentice
- Group:
- New Members
- Active Posts:
- 8 (0.01 per day)
- Joined:
- 11-October 11
- Profile Views:
- 39
- Last Active:
Oct 14 2011 09:45 AM- Currently:
- Offline
Previous Fields
- Country:
- GB
- OS Preference:
- Windows
- Favorite Browser:
- Who Cares
- Favorite Processor:
- Who Cares
- Favorite Gaming Platform:
- Who Cares
- Your Car:
- Volkswagen
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: If statement where both conditions get used
Posted 11 Oct 2011
Done, and no exception is caught at all.
To clarify, no exception is caught in the function. -
In Topic: If statement where both conditions get used
Posted 11 Oct 2011
No changes at all, unfortunatly.
When the Yellow debugger is on MessageBox.Show, ex is still nothing, and after it passed it (and leaves the sub) the Message box doesn't even appear.
Private Sub sSetUpBranchVisabilities() Try If objSQLServ_DAL.fGetReadPNR(cboHandlingBranches.Text.Trim) Then cmdReadPNR.Visible = True Else cmdReadPNR.Visible = False End If Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub -
In Topic: If statement where both conditions get used
Posted 11 Oct 2011
I see your point with the Try Catch statment.
Private Sub sSetUpBranchVisabilities() Try If objSQLServ_DAL.fGetReadPNR(cboHandlingBranches.Text.Trim) Then cmdReadPNR.Visible = True Else cmdReadPNR.Visible = False End If Catch ex As Exception MessageBox.Show(ex.ToString) End Try End Sub
When the Yellow debugger is on cmdReadPNR.Visible = True I can see the following in Watch:
Name: objSQLServ_DAL.fGetReadPNR(cboHandlingBranches.Text.Trim)
Value: True
Type: Boolean
As far as I understand it, that means that the return value from the function is correct, and exactly what we want to test.
The strange thing that happens next when debugging is that the Yellow jumps down to the line Message.Show(ex.string).It does not even go to the Catch line first. At this point Watch displayes:
Name: ex
Value: Name 'ex' is not declared.
Also the Message box does never open up and at all even if the "Yellow" is on it.
Again, I don't understand how this can happen, because normally when an exception is caught there is always a message. -
In Topic: If statement where both conditions get used
Posted 11 Oct 2011
Well, I'm aware of that the function that calls the SQL might not be the best constructed, it's something I've "inherited" and never spent any time on working on really. (Which I probably should do..) But, I don't think that's the issue here, and also the reason why I posted the easy code snippet on top in the first place. Here it's clear that it is True as boolean that is in the variable that is being tested, and it still errors out.
In the meantime since my last post, I have worked the following out, while trying to debug it:
Private Sub sSetUpBranchVisabilities() If objSQLServ_DAL.fGetReadPNR(cboHandlingBranches.Text.Trim) Then cmdReadPNR.Visible = True MessageBox.Show("True") Else cmdReadPNR.Visible = False MessageBox.Show("False") End If Dim newbool As Boolean newbool = cmdReadPNR.Visible End Sub
By adding the Message boxes and then the new boolean in the bottom, I though that would make things easier to debug - and for some reason now when the function returns True it skipps the Else statement just as it should do.
But If I go in and remove the two newbool lines, then it steps through both again.
I guess this would mean, I have solved my issue, but I haven't got a clue why... -
In Topic: If statement where both conditions get used
Posted 11 Oct 2011
Yep.
<CODE>
Public Function fGetReadPNR(ByVal strHandlingBranch As String) As Boolean ' Created in v3.0.0 Dim connectionString As String = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX" Dim SQLcon As New SqlConnection(connectionString) Dim ReadPNR As Boolean Dim SQLCmd As New SqlCommand("GetReadPNR_v1", SQLcon) ' Name of stored procedure SQLCmd.CommandType = CommandType.StoredProcedure SQLCmd.Parameters.AddWithValue("@CallHandlBranch", CObj(strHandlingBranch)) SQLcon.Open() ReadPNR = CBool(SQLCmd.ExecuteScalar) SQLcon.Close() Return ReadPNR End Function
</CODE>
I seem to get it wrong when I paste the code. Sorry about that...
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
-
- Location:
- England
- Years Programming:
- 3
- Programming Languages:
- vb6, vb.net, sql
Contact Information
- E-mail:
- Private
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
Tildha has no profile comments yet. Why not say hello?