locked
Help debugging problem RRS feed

  • Question

  • User615288127 posted

    Sorry if this is not in the correct forum.  I'm using Visual Studio 2015 with SQL Server 2014, VB.

    I have a program that is exiting prematurely with no error messages so I have little to go on to solve the problem.  Can someone explain to this novice how to use the debugger (or other tools) to find the problem and fix it?  A sample subroutine is below. This program in its entirety contains 14 UpdatePanels each with their own UpdateProgress.  Clicking on the linkButton in the first panel starts a chain reaction going through all 14 panels, without further user input, reading from the SQL database table and writing to an Access file.  Everything appeared to work fine until adding the 14th UpdatePanel.  The routine reads the SQL file and stops short of completing the write to Access.  No error messages, it just stops.  The SQL database is fine as this is an update to the current method of exporting data and the previous version works fine.  The difference is that the previous version writes to only one UpdateProgress otherwise the two programs are identical.  Confusing me further is that it doesn't stop on the same data row each time.

    Can someone explain how to use the debugger (or other diagnostic tools) so I can figure this out before I get older and greyer?  Please, I'm a novice at this and have never used the debugger before and to understand instructions on various web sites has just confused me more than I thought possible.

            <asp:UpdatePanel ID="UpdatePanel14" runat="server" style="width:750px;" UpdateMode="Conditional" ChildrenAsTriggers="false">
                <ContentTemplate>
                    <fieldset style="width:750px; height: 11px;">              
                    <asp:linkButton ID="Button14" runat="server" Text="Export" OnClick="Button14_Click" Style="width: 56px" ForeColor="White" />
                        &nbsp;              
                    <asp:Label ID="Label14" runat="server" Text="CIS Manufacturer Parts"></asp:Label>
                        &nbsp;
                        <div style="display: inline-block">
                    <asp:UpdateProgress ID="UpdateProgress14" runat="server" AssociatedUpdatePanelID="UpdatePanel14">
                        <ProgressTemplate>
                                <script type="text/javascript">
                                    document.write("<div class='UpdateProgressBackground'></div>");</script>
                                <span class="UpdateProgressContent"                                    
                                        style="background-color: #FFFFFF; font-weight: bold; left: 572px; height: 29px;">CIS Manufacturer Parts export in progress...
                                <asp:Image id="CISWaitCon" runat="server" ImageUrl="~/Images/progress.gif"/>
                                    </span>
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                    </fieldset>
                            <asp:Label ID="Label25" runat="server"></asp:Label>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Button14" EventName="Click"/>
                </Triggers>
            </asp:UpdatePanel>
        Protected Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
            'CIS Manufacturer Parts
    
            Comp = "CIS Manufacturer Parts"
            Dim sqlConnection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("conCString1").ConnectionString)
            Dim ConnString As String = Utils2.GetConnString()
    
            Dim querystring As String = String.Empty
    
            querystring = "DELETE * FROM [CIS Manufacturer Parts]"
            Using conn As New OleDbConnection(ConnString)
                Using cmd1 As New OleDbCommand(querystring, conn)
                    cmd1.CommandType = CommandType.Text
                    conn.Open()
                    cmd1.ExecuteNonQuery()  'delete CIS Manufacturer Parts
                End Using
                conn.Close()
            End Using
    
            Dim cmd As New SqlCommand
            cmd.CommandType = CommandType.Text
            cmd.Connection = sqlConnection
            Dim X As Integer = 1
            Dim Y As Integer = 0
            Dim Z As Integer = 0
            Dim R As Integer = 0
            Dim L As Integer = 0
            Dim AP As Integer = 0
            Dim Tot As Integer = 0
            Dim Tmp As String = String.Empty
            Dim Prt1 As String = String.Empty
            Dim Prt2 As String = String.Empty
            Dim Prt3 As String = String.Empty
            Dim Prt4 As String = String.Empty
            Dim Prt5 As String = String.Empty
            Dim Prt6 As String = String.Empty
            Dim Prt7 As String = String.Empty
            Dim Prt8 As String = String.Empty
            Dim Prt9 As String = String.Empty
            Dim Prt10 As String = String.Empty
            Dim Prt11 As String = String.Empty
            Dim Prt12 As String = String.Empty
            Dim Prt13 As String = String.Empty
            Dim Prt14 As String = String.Empty
    
            Dim Cnt As Integer = 0
            querystring = "SELECT Count(*) FROM [CIS Manufacturer Parts] where (PART_NUMBER) is not null"  '46
            sqlConnection.Open()
            Dim command1 As New SqlCommand(querystring, sqlConnection)
            Dim reader1 As SqlDataReader = command1.ExecuteReader()
            While reader1.Read()
                Cnt = reader1(0)
            End While
            sqlConnection.Close()
    
            querystring = "SELECT * FROM [CIS Manufacturer Parts] ORDER BY [PART_NUMBER]"  '14
            R = 0
            sqlConnection.Open()
            Dim command As New SqlCommand(querystring, sqlConnection)
            Dim reader As SqlDataReader = command.ExecuteReader()
            While reader.Read()
                Prt1 = reader(0).ToString   'AuditID
                idList.Add(Prt1.ToString())
                Prt2 = reader(1).ToString   'PART_NUMBER
                idList.Add(Prt2.ToString())
                Prt3 = reader(2).ToString   'Manufacturer
                '
                'Search for ' in Manufacturer field and add second ' if present
                '
                AP = InStr(Prt3, "'")
                If AP <> 0 Then
                    L = Len(Prt3)
                    Tmp = Left(Prt3, AP - 1)
                    Tmp = Tmp & "''"
                    Tmp = Tmp & Right(Prt3, L - AP)
                    Prt3 = Tmp
                End If
                idList.Add(Prt3.ToString())
                Prt4 = reader(3).ToString
                idList.Add(Prt4.ToString())
                Prt5 = reader(4).ToString
                idList.Add(Prt5.ToString())
                Prt6 = reader(5).ToString
                idList.Add(Prt6.ToString())
                Prt7 = reader(6).ToString
                idList.Add(Prt7.ToString())
                Prt8 = reader(7).ToString
                idList.Add(Prt8.ToString())
                Prt9 = reader(8).ToString
                idList.Add(Prt9.ToString())
                Prt10 = reader(9).ToString
                idList.Add(Prt10.ToString())
                Prt11 = reader(10).ToString
                idList.Add(Prt11.ToString())
                Prt12 = reader(11).ToString
                idList.Add(Prt12.ToString())
                Prt13 = reader(12).ToString
                idList.Add(Prt13.ToString())
                Prt14 = reader(13).ToString
                idList.Add(Prt14.ToString())
                X = X + 14
                R = R + 1
            End While
            sqlConnection.Close()
    
            Z = 0
            'If Z = 1 Then
            For X = 1 To R Step 1
                querystring = "INSERT INTO [CIS Manufacturer Parts] ([AuditID], [PART_NUMBER], [Manufacturer], [Manufacturer PN], [Manufacturer PN Status], [Datasheet], [RoHS Compliant], [Digikey PN], [Newark PN], [Premier Farnell PN], [Future PN], [Mouser PN], [Arrow PN], [MSL Classification]) VALUES("
                For Y = 0 To 13 Step 1
                    querystring = querystring & "'" & idList(Z) & "'"
                    If Y <> 13 Then querystring = querystring & ", "
                    If Y = 13 Then querystring = querystring & ")"
                    Z = Z + 1
                Next
                Using conn As New OleDbConnection(ConnString)
                    Using cmd1 As New OleDbCommand(querystring, conn)
                        cmd1.CommandType = CommandType.Text
                        conn.Open()
                        cmd1.ExecuteNonQuery()  'CIS Manufacturer Parts
                    End Using
                    conn.Close()
                End Using
            Next
            'End If
            Cis = Cnt
            idList.Clear()
    
            Label14.Text = Cis & " CIS Manufacturer Parts exported at " & DateTime.Now.ToString()    '665 at test
            Recs = (Cap + Con + Cry + Dio + Ics + Ind + Mis + Rel + Res + Swi + Xfr + Xtr + Tpp + Cis)
            DataF = ((Cap * 38) + (Con * 43) + (Cry * 42) + (Dio * 41) + (Ics * 61) + (Ind * 40) + (Mis * 36) + (Rel * 45) + (Res * 40) + (Swi * 43) + (Xfr * 44) + (Xtr * 46) + (Tpp * 4) + (Cis * 14))
            Label25.Text = Recs & " Data records exported into " & DataF & " data fields."
    
        End Sub

    Thanks!

    Saturday, July 28, 2018 12:31 AM

Answers

  • User615288127 posted

    Thanks Kathy,

    I've seen this article and for the total novice it is really not much help.  Anyhow, I'm closing this and rewriting it as research has narrowed the area where the problem occurs.

    See follow up post "SQL to Access unexplained read/write error"

    Thanks!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 30, 2018 1:20 PM

All replies

  • User409696431 posted

    See https://msdn.microsoft.com/en-us/library/dn986851.aspx

    If your application compiles without error, skip down to the section on "Debugging Your Running Code"

    Sunday, July 29, 2018 11:42 PM
  • User615288127 posted

    Thanks Kathy,

    I've seen this article and for the total novice it is really not much help.  Anyhow, I'm closing this and rewriting it as research has narrowed the area where the problem occurs.

    See follow up post "SQL to Access unexplained read/write error"

    Thanks!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 30, 2018 1:20 PM