Reputation: 0 Apprentice
- New Members
- Active Posts:
- 8 (0.01 per day)
- 11-October 11
- Profile Views:
- Last Active:
- Oct 14 2011 09:45 AM
- OS Preference:
- Favorite Browser:
- Who Cares
- Favorite Processor:
- Who Cares
- Favorite Gaming Platform:
- Who Cares
- Your Car:
- Dream Kudos:
Posts I've Made
Posted 11 Oct 2011Done, and no exception is caught at all.
To clarify, no exception is caught in the function.
Posted 11 Oct 2011No 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
Posted 11 Oct 2011I 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:
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:
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.
Posted 11 Oct 2011Well, 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...
Posted 11 Oct 2011Yep.
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
I seem to get it wrong when I paste the code. Sorry about that...
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
- Years Programming:
- Programming Languages:
- vb6, vb.net, sql