none
Press a print button makes windows app. stop working and must close RRS feed

  • Question

  • Hi everybody,

    I almost done, Now i have a completed windows application, I believed that problems have gone away but this is not true. Any ways I have two problems. The first one is (My App. works well on my PC when i take "Release folder" to another place in my PC but when i take "Release folder" to another PC every action on the application makes "Not Responding" . On the beginning i was confused but Task Manager clears this situation it appeared that on every action on PC2 the CPU reaches to 47% then "Not Responding" then complete the action and some action reaches to 43% or 45% without "Not Responding" and on PC1 has a good relatively configuration CPU reaches to 51% without "Not Responding" and the time to perform the action is not completely reasonable but accepted)I noticed that this abnormal issue is due to the configuration of every PC (on my PC CPU reaches to 13.5% to perform the same action that takes 47% then "Not Responding" on the others). But is this an accepted solution "The configuration of every PC" i think that there is another solution...........

    The second problem is (Pressing on the print button performs the printing action but enforce the application to exit by display a message

    " 'App. name' Has Stopped Working..........Close The Program") This problem occurs on the PC1 and PC2 not on My PC.

    My PC configuration(

    OS: Windows 8.1 Enterprise 64-bit (6.3, Build 9600)

    Processor: AMD A8-5500 APU with Radeon(tm) HD Graphics (4 CPUs), ~3.2GHz  ,  Memory: 8GB RAM)

     
    The PC1 configuration (Processor: AMD Athlon(tm) II X2 220  2.8 GHz   ,  Memory : 4GB   RAM) OS: Windows 7 SP1 32bit       

    The PC2 configuration (Processor: AMD E-300APU with Radeon(tm)HD Graphics    1.30 GHz   ,  Memory :3GB RAM) OS: Windows 8.1 Enterprise 64-bit

    Thanks in advance and sorry for prolongation.



    Regards From Amr_Aly

    Tuesday, November 21, 2017 9:07 AM

Answers

  • The first one is (My App. works well on my PC when i take "Release folder" to another place in my PC but when i take "Release folder" to another PC every action on the application makes "Not Responding" .

    You can't install an application to another machine by copying the release folder.

    You need to publish the application using your machine and then install the application on the other machines.
    https://msdn.microsoft.com/en-us/library/ms953320.aspx

    • Marked as answer by Amr_Aly Thursday, November 30, 2017 11:25 AM
    Tuesday, November 21, 2017 10:13 AM

All replies

  • The first one is (My App. works well on my PC when i take "Release folder" to another place in my PC but when i take "Release folder" to another PC every action on the application makes "Not Responding" .

    You can't install an application to another machine by copying the release folder.

    You need to publish the application using your machine and then install the application on the other machines.
    https://msdn.microsoft.com/en-us/library/ms953320.aspx

    • Marked as answer by Amr_Aly Thursday, November 30, 2017 11:25 AM
    Tuesday, November 21, 2017 10:13 AM
  • Create a very little program which only shows. 

    "I run" and deploy and run that on PC1. 

    After that you know where to search. 

     


    Success
    Cor

    Tuesday, November 21, 2017 10:14 AM
  • You can't install an application to another machine by copying the release folder.

    You need to publish the application using your machine and then install the application on the other machines.
    https://msdn.microsoft.com/en-us/library/ms953320.aspx

    Thank you Mr Acamar,

    It's very useful topic but i faced a problem this error occurs when setup the application

     

    I have this line of code to load the image"DrAhEssmat.png"

    Sub LoadPicture()
            Dim filename As String = Path.Combine(Application.StartupPath, "DrAhEssmat.png") 'System.IO.Path.GetFileName("\DrAhEssmat.png")
            Me.PictureBox1.Image = Image.FromFile(filename)
        End Sub

    Regards From Amr_Aly


    • Edited by Amr_Aly Tuesday, November 21, 2017 10:20 PM
    Tuesday, November 21, 2017 10:14 PM
  • It's very useful topic but i faced a problem this error occurs when setup the applicationI have this line of code to load the image"DrAhEssmat.png"

    Sub LoadPicture()
            Dim filename As String = Path.Combine(Application.StartupPath, "DrAhEssmat.png") 'System.IO.Path.GetFileName("\DrAhEssmat.png")
            Me.PictureBox1.Image = Image.FromFile(filename)
        End Sub

    Is this on one of the installation machines?

    I can't see how that code should affect the setup.   A problem during setup is going to be associated with the  configuration of the project.  Do you have an image file you are using as a resource.  See here for some errors that can occur during setup.
    https://msdn.microsoft.com/en-us/library/ms229001.aspx

    If the error is occurring after setup, when you execute the application, then that indicates that setup has not included the file in the application files folder.  What property settings have you used for this file in the project?
    https://msdn.microsoft.com/en-us/library/kzy0fky2.aspx

    It might appear that the problem is in setup when it is actually in execution because setup tries to execute the application when it is completed.

    Wednesday, November 22, 2017 12:38 AM

  • Is this on one of the installation machines?

    I can't see how that code should affect the setup.   A problem during setup is going to be associated with the  configuration of the project.  Do you have an image file you are using as a resource.  See here for some errors that can occur during setup.
    https://msdn.microsoft.com/en-us/library/ms229001.aspx

    If the error is occurring after setup, when you execute the application, then that indicates that setup has not included the file in the application files folder.  What property settings have you used for this file in the project?
    https://msdn.microsoft.com/en-us/library/kzy0fky2.aspx

    It might appear that the problem is in setup when it is actually in execution because setup tries to execute the application when it is completed.

    This error in my machine , The second link https://msdn.microsoft.com/en-us/library/kzy0fky2.aspx

    is so helpful now i can collect every necessary file in application folder it gave me the way. but i still have an error

    on my machine and on the installation machine(user PC) the error talked about the manifest file and your first link helped me to find the error and searched in the web to fix this issue and i found this link here ....  

    Now In my machine and in the (user PC) i can setup the application but it doesn't open but this action occurs when i left the both check boxes of  1- "Open deployment web page after publish" 2- "Use '.deploy' file extension" checked , Manifest error appears when (1 and 2 check boxes unchecked)......what is the situation now ?

    and which folder have i copied to the user PC (app.publish OR publish)? I'm so confused ......I spend a lot of time searching and testing this issue ..........

    thanks sir for helping me 


    Regards From Amr_Aly

    Wednesday, November 22, 2017 9:47 AM
  • OK Mr Acamar,

    I found another method to make an (.msi package) for my application and this method succeeded and my second problem solved (The print button worked well) this is my second problem ====>>

    "The second problem is (Pressing on the print button performs the printing action but enforce the application to exit by display a message

    " 'App. name' Has Stopped Working..........Close The Program") This problem occurs on the PC1 and PC2 not on My PC. " ..........................

    But the problem now is my first problem still exists.

    This is my first problem ====>>

    The first one is (My App. works well on my PC when i take "Release folder" to another place in my PC but when i take "Release folder" to another PC every action on the application makes "Not Responding" . On the beginning i was confused but Task Manager clears this situation it appeared that on every action on PC2 the CPU reaches to 47% then "Not Responding" then complete the action and some action reaches to 43% or 45% without "Not Responding" and on PC1 has a good relatively configuration CPU reaches to 51% without "Not Responding" and the time to perform the action is not completely reasonable but accepted)I noticed that this abnormal issue is due to the configuration of every PC (on my PC CPU reaches to 13.5% to perform the same action that takes 47% then "Not Responding" on the others). " Can we find a solution of this problem sir?

    Thanks in advance Mr Acamar


    Regards From Amr_Aly

    Thursday, November 23, 2017 8:23 AM
  • But the problem now is my first problem still exists.

    This is my first problem ====>>

    The first one is (My App. works well on my PC when i take "Release folder" to another place in my PC but when I take the 'Reales Folder' th"Not Responding" .

    The solution is what I recommended above - don't take the Release Folder to the other PC: Install the application using the installation package you created when you solved problem 1.

    Thursday, November 23, 2017 8:46 AM

  • The solution is what I recommended above - don't take the Release Folder to the other PC: Install the application using the installation package you created when you solved problem 1.

    OK sir , I already did what you said and installed the application on the other PC and the first problem still persists ......... Is it possible that code itself of any controller cause this error like (for example, click on the grid view, validating of combo boxes that save or update a record in the database, OR the "clear button" that has a loop to empty all the text boxes or combo boxes in the form , 


    Regards From Amr_Aly





    • Edited by Amr_Aly Thursday, November 23, 2017 11:18 AM
    Thursday, November 23, 2017 9:07 AM
  • OK sir , I already did what you said and installed the application on the other PC and the first problem still persists ...

    Then it cannot be the same problem.  If you saying that after you have installed the application on that other machine but when you execute that application there is a problem, then you need to describe what that problem is and what you have attempted so far to diagnose it. Exactly which actions create the Not Responding state, exactly what is not responding (part of the application, the whole application or the whole machine), and what do you mean when you say that Task Manager 'clears' it?

    Thursday, November 23, 2017 8:20 PM
  • Then it cannot be the same problem.  If you saying that after you have installed the application on that other machine but when you execute that application there is a problem, then you need to describe what that problem is and what you have attempted so far to diagnose it. Exactly which actions create the Not Responding state, exactly what is not responding (part of the application, the whole application or the whole machine), and what do you mean when you say that Task Manager 'clears' it?

    I mean Task Manager 'Clarifying' not 'clears' so sorry... This is my code that may cause a problem but i think that database is the problem because the loading of the form on the user PC is taking a long time 

    and validating of combo box responsible for searching and clicking on the grid view make Not Responding  

    Option Strict On
    Option Explicit On
    
    Imports System.Data.OleDb
    Imports System.IO
    Imports DAO
    Imports System.DateTime
    Imports System.Xml
    Imports System.Management
    Imports System.Windows.Forms
    Imports System.Threading
    Imports ApplicationEnhancement.Expiry
    
    Public Class frm1
    
        Inherits System.Windows.Forms.Form
    
        Dim conn As New OleDbConnection("provider=microsoft.ace.oledb.12.0; data source=Dr_T.accdb;jet oledb:database password=000000000")
        Dim cmd As OleDbCommand
    
        Dim f2 As frm2
      
        Public Sub New()
            'MyBase.New()
    
            'This call is required by the Windows Form Designer.
            InitializeComponent()
            'Add any initialization after the InitializeComponent() call
    
            DTPickerNow()
           
            DTPicker.Value = Now
            LoadPicture()
            ClearData()
            ClearGyn()
            lblSearch.Text = CType(dgvPatients.Rows.Count(), String)
    
        End Sub
    
    ''##Very Useful code for make expiration date 
        Public Function DateGood(NumDays As Integer) As Boolean
    
            'Register Parameters:
            ' CRD: Current Run Date
            ' LRD: Last Run Date
            ' FRD: First Run Date
            Dim TmpCRD As Date
            Dim TmpLRD As Date
            Dim TmpFRD As Date
            'Dim dtfi As DateTimeFormatInfo
            'Dim styles As DateTimeStyles
            TmpCRD = CDate(Format(Now, ("dd/MM/yyyy").ToString))
            TmpLRD = CDate(GetSetting(Application.ExecutablePath, "Param", "LRD", "11/9/2017"))
            TmpFRD = CDate(GetSetting(Application.ExecutablePath, "Param", "FRD", "1/9/2017"))
            DateGood = False
            'If this is the applications first load, write initial settings
            'to the register
            If TmpLRD = CDate("11/9/2017") Then
                SaveSetting(Application.ExecutablePath, "Param", "LRD", CType(CDate(TmpCRD), String))
                SaveSetting(Application.ExecutablePath, "Param", "FRD", CType(TmpCRD, String))
            End If
            'Read LRD and FRD from register
            TmpLRD = CDate(GetSetting(Application.ExecutablePath, "Param", "LRD", "11/9/2017"))
            TmpFRD = CDate(GetSetting(Application.ExecutablePath, "Param", "FRD", "1/9/2017"))
            If TmpFRD > TmpCRD Then 'System clock rolled back
                DateGood = False
            ElseIf Now > DateAdd(("d").ToString, NumDays, CDate(TmpFRD)) Then 'Expiration expired
                DateGood = False
            ElseIf TmpCRD > TmpLRD Then 'Everything OK write New LRD date
                SaveSetting(Application.ExecutablePath, "Param", "LRD", CType(TmpCRD, String))
                DateGood = True
            ElseIf TmpCRD = CDate(Format(TmpLRD, ("dd/MM/yyyy").ToString)) Then
                DateGood = True
            Else
                DateGood = False
            End If
        End Function
    ''##When you put this function in the save button click you will notice the difference
        ''##Till now it is useful ( Null value solution )
        Public Function CheckNull(ByVal fieldValue As String) As String
            If fieldValue.Equals(DBNull.Value) Then Return "" Else
            If fieldValue = "N/A" Then
                Return "value for N/A"
            Else
                Return ""
            End If
        End Function
    
    ''##This code for load picture to the form
        Sub LoadPicture()
            Dim filename As String = System.IO.Path.GetFileName("\DrAhEssmat.png")
            Me.PictureBox1.Image = Image.FromFile(filename)
        End Sub
    
        Private Sub frm1_Shown(sender As Object, e As EventArgs) Handles Me.Shown
            'Me.Location = New Point(0, 0)
            'Me.Size = Screen.PrimaryScreen.WorkingArea.Size
            ReleaseMemory()
    
            ShowPatTable()
            ShowGynTable()
            ShowGyn2PatTable()
    
            RDXmlPatNames()
            RDXmlPatNames1()
            RDXmlPatNames2()
            RDXmlDrugs()
            RDXmlDiaInter()
            RDXmlInv()
            DGVArrange()
        End Sub
    
        Private Declare Function SetProcessWorkingSetSize Lib "kernel32.dll" (ByVal hProcess As IntPtr, ByVal dwMinimumWorkingSetSize As Int32, ByVal dwMaximumWorkingSetSize As Int32) As Int32
        Friend Sub ReleaseMemory()
            Try
                GC.Collect()
                GC.WaitForPendingFinalizers()
                If Environment.OSVersion.Platform = PlatformID.Win32NT Then
                    SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1)
                End If
            Catch ex As Exception
                MsgBox(ex.ToString())
            End Try
        End Sub
    
        Private Sub frm1_BindingContextChanged(sender As Object, e As EventArgs) Handles MyBase.BindingContextChanged
    
            FillPat()
            FillGyn()
            FillGyn2()
    
            DGVArrange()
        End Sub
    
    Sub FillPat()
            Dim con As New OleDbConnection("provider=microsoft.ace.oledb.12.0; data source=Dr_T.accdb;jet oledb:database password=******")
            con.Open()
            Dim da As New OleDbDataAdapter("SELECT * FROM Pat ORDER BY Patient_no", con)
    
            Dim ds As New DataSet
            da.Fill(ds, "Pat")
            con.Close()
            'dgvVisit.DataSource = ds.Tables("Visits")
            With dgvPatients
                .DataSource = ds
                .DataMember = "Pat"
            End With
    
            ds = Nothing
            da.Dispose()
            con = Nothing
        End Sub
    
     Private WithEvents usage As ApplicationUsage
        Private _maxTimes As Integer = 100  '10
        Private _usageLimitExceeded As Boolean = False
    
        Private Sub frm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            Me.Location = New Point(0, 0)
            Me.Size = Screen.PrimaryScreen.WorkingArea.Size
    
            Me.AutoScroll = True
            '''''''''''''''''''''''''''''''''''''''''''''''''''''''
            ' Initialize the variable "usage" by using
            ' the NEW keyword along with the number
            ' of maximum "hits" you want to allow:
            usage = New ApplicationUsage(_maxTimes)
    
            ' Now check the usage. If the usage has been
            ' exceeded, the "MaximumExceeded" event will
            ' be raised:
            usage.CheckUsage()
    
            If _usageLimitExceeded Then
                MessageBox.Show(String.Format("The maximum usage of {0:n0} " & vbCrLf &
                                              "times has been exceeded." & vbCrLf &
                                              "Call 00000000 for full version",
                                              _maxTimes), "Cannot Continue")
                Close()
            Else
                ' Just for demonstration here, if the
                ' maximum has not been exceeded then
                ' I'll just show the quantity of times
                ' this program has been run.
    
                MessageBox.Show(String.Format("Usage Quantity: {0:n0} Of " &
                                              _maxTimes, usage.UsageQuantity))
            End If
            '''''''''''''''''''''''''''''''''''''''''''''''''''''''
            lblcurTime.Text = CType(Now.ToShortDateString, String)
            DateTimePicker1.Value = Now
            txtNo.Select()
    
            Fill_Auto()
            LoadPicture()
            DTPickerEDD.Text = CType(Now, String)
            lblSearch.Text = CType(dgvPatients.Rows.Count(), String)
            
            '##Set timer And test
            '##This code for Expiration date it is very useful
            If Not DateGood(5) Then  ''30 or any number for the expiration date
                MsgBox("Trial Period Expired!" & vbCrLf &
                      "Call 000000", vbExclamation,
                      "Unregistered application")
                Close()
                End
            End If
    
        End Sub
    
        Private Sub frm1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
            If e.CloseReason = CloseReason.UserClosing Then
                usage.Save()
            End If
        End Sub
    
        Private Sub _
            usage_MaximumExceeded(sender As Object,
                                  e As System.EventArgs) _
                                  Handles usage.MaximumExceeded
    
            _usageLimitExceeded = True
    
        End Sub
    
        Sub Fill_Auto()
            txtNo.Text = GetAutonumber("Pat", "Patient_no")
            txtVis.Text = GetAutonumber("Gyn2", "Vis_no")
            txtVis1.Text = GetAutonumber("Gyn", "Vis_no")
            txtNo.Select()
        End Sub
    
    
    
        Private Sub cbxSearch_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles cbxSearch.Validating
            If rdoName.Checked Then
                SearchName()
            ElseIf rdoID.Checked Then
                SearchID()
            ElseIf rdoHus.Checked Then
                SearchHusband()
            ElseIf rdoPhone.checked Then
                SearchPhone()
            End If
    
            ClearGyn()
            ShowData()
            ShowGynTable()
            ShowGyn2PatTable()
            btnNewGyn.Enabled = True
            GynPattxtNo()
            Gyn2PattxtNo()
            DGVArrange()
        End Sub
    
        Private Sub txtNo_MouseClick(sender As Object, e As MouseEventArgs) Handles txtNo.MouseClick
    
            SearchPattxtNo()
            GynPattxtNo()
            Gyn2PattxtNo()
            ClearGyn()
    
            ShowData()
            ShowGynTable()
            ShowGyn2PatTable()
            btnNewGyn.Enabled = True
            DGVArrange()
        End Sub
    
    Private Sub SearchID()
    
            Dim con As New OleDbConnection("provider=microsoft.ace.oledb.12.0; data source=Dr_T.accdb;jet oledb:database password=00000000")
            Dim cmd As New OleDbCommand
            Dim da As New OleDbDataAdapter
            Dim dt As New DataTable
            Dim sSQL As String = String.Empty
    
            Try
                con.Open()
                cmd.Connection = con
                cmd.CommandType = CommandType.Text
                '## Two square praktes 
                sSQL = "SELECT * FROM [Pat] " &
                       "WHERE Patient_no LIKE '%" & Me.cbxSearch.Text & "%' " &
                       "ORDER BY Patient_no"
    
                'sSQL = "SELECT * FROM Pat " &
                '       "WHERE Patient_no =" & Me.cbxSearch.Text & " ORDER BY Patient_no"
    
                cmd.CommandText = sSQL
                da.SelectCommand = cmd
                da.Fill(dt)
    
                dgvPatients.DataSource = dt
                If dt.Rows.Count = 0 Then
                    Exit Sub
                    'MsgBox("No record found!")
                End If
    
            Catch ex As Exception
                MsgBox(ErrorToString)
            Finally
                con.Close()
            End Try
    
        End Sub
    
     Sub GynPattxtNo()
    
            Dim con As OleDbConnection = New OleDbConnection("provider=microsoft.ace.oledb.12.0; data source=Dr_T.accdb;jet oledb:database password=**********")
            Dim cmd As OleDbCommand = New OleDbCommand
            Dim da As New OleDbDataAdapter
            Dim dt As New DataTable
            Dim sSQL As String = String.Empty
    
            Try
                con.Open()
                cmd.Connection = con
                cmd.CommandType = CommandType.Text
                'sSQL = "SELECT * FROM Gyn " &
                '       "Where Patient_no like '%" & Me.txtNo.Text & "%'"
    
                sSQL = "SELECT * FROM Gyn " &
                       "WHERE Patient_no =" & Me.txtNo.Text & " ORDER BY Vis_no"
    
                cmd.CommandText = sSQL
                da.SelectCommand = cmd
                da.Fill(dt)
    
                dgvGyn.DataSource = dt
                If dt.Rows.Count = 0 Then
                    Exit Sub
                    'MsgBox("No record found!")
                End If
    
            Catch ex As Exception
                MsgBox(ErrorToString)
            Finally
                con.Close()
            End Try
    
        End Sub


    Regards From Amr_Aly



    • Edited by Amr_Aly Thursday, November 23, 2017 10:53 PM
    Thursday, November 23, 2017 10:46 PM
  • Hi Amr,

    How much access do you have to the other computer? Can you run the VS source there?

    Can you look on the problem computer to see if the files are there after setup? Is it getting past setup? Its not clear what you are describing.

    If setup creates a copy of your app.exe on the problem computer and you start that what happens? Is that when the error occurs? Make sure you can understand your err msg from your try/catch

    If the app has been installed then put messages in the code at key points so you know how far the app.exe is getting and what it is doing when running on the other computer.

    So for example put a line in form load that checks if a file exists and then give messages for example (not real code):

        dim mypath as string = "the path"

        msgbox("starting picture test: " & mypath)

        if thefile exists then  msgbox(" file exists")

       msgbox("picture test complete " & mypath)


    or get a data record or whatever.


    If you have events put msg in there to see if they are called etc.

    Find the exact line the error occurs on.

    Thursday, November 23, 2017 11:34 PM
  • This is the my code that may has a problem

    You haven't indicated what the problem is. You have said 'the application makes "Not Responding" "  Does this happen when the application starts, or when you select the print option (which is what your thread title implies) or when you do something else.  What exactly is 'Not Responding' - is it a Windows message (the whole application) or the procedure that you select? What do you mean by 'Task Manager clears this situation'?

    The code you have posted is far too big to analyze.  You need to isolate the problem to a smaller section by inserting debugging statements, such as stopwatches for each method or logging method calls to a file or even just messageboxes.

    Thursday, November 23, 2017 11:53 PM
  • Indeed Mr Acamar and Mr Tommy i'm so frustrated because this problem is so difficult or it seems to me like that and i intended to root the problem from the root ,I don't know how but i'm sure that Patience and Purposefulness

    I will get what i want so i will begin with this photo to indicate the problem 


    Regards From Amr_Aly

    Friday, November 24, 2017 6:56 PM
  • Indeed Mr Acamar and Mr Tommy i'm so frustrated because this problem is so difficult or it seems to me like that and i intended to root the problem from the root ,I don't know how but i'm sure that Patience and Purposefulness

    You need to tackle one problem at a time.  For instance, what is the code for the Clear button click event handler, and what was the result when you inserted timing and logging code for that button click?

    Friday, November 24, 2017 9:01 PM
  • Amr,

    Yeah. Half of learning to program is learning to debug. It does get very messy on the customers computer. Makes you appreciate Visual Studio IDE.

    Another brute force debugging technique is to remove code from the project until it works. Then the last thing you removed is a clue to the problem. Get the framework running. Then add things back in debugging each one before moving to the next.

    Plus, dont execute the code in the event handler for the controls where you think a problem occurs. Just exit sub first line. After removing the event sub, does everything work now (except the event)? If so you know its in that click event. Put a break point there in the event sub and single step through that code. What where it goes. Look at the values. Watch for errors you don't know about. Most likely you trigger some other event you dont realize or error not reported and on and on...

    Friday, November 24, 2017 9:22 PM
  • OK Mr Tommy an Mr Acamar , I appreciate your efforts

    I've a good news but unfortunately the bad news follow it, Any ways I've created a new program and used the two methods of installation (Publish method and .msi package) publish method was not succeeded to me in my app. but with the new program it succeeded

    My new program depends on clear button and click on grid view and combo box for search in database and there is the summary after (setup my new program on another device) 

    1- Click on grid view is beautiful it's more fast than my app. (it display the data on the combo boxes by normal way like my PC do)

    2- Search by ID takes a time but without "NOT RESPONDING" and it's reasonable and accepted

    3- Clear button takes a time but more fast than my app. and with "NOT RESPONDING" appears like the above picture and then disappears instantly.

    This is my Clear button code 

            cbxSearch.Text = ""
            cbxPatName.Text = ""
            cbxAddress.Text = ""
            DTPicker.Value = Now
            txtAge.Text = ""
            txtPhone.Text = ""
            
            cbxHusband.Text = ""
            
            txtNo.Text = GetAutonumber("Pat", "Patient_no")
            txtNo.Select()
            FillPat()
            FillGyn()
            FillGyn2()
    Sub FillPat()
            Dim con As New OleDbConnection("provider=microsoft.ace.oledb.12.0; data source=TestDB.accdb;jet oledb:database password=******")
            con.Open()
            Dim da As New OleDbDataAdapter("SELECT * FROM Pat ORDER BY Patient_no", con)
    
            Dim ds As New DataSet
            da.Fill(ds, "Pat")
            con.Close()
            
            With dgvPatients
                .DataSource = ds
                .DataMember = "Pat"
            End With
    
            ds = Nothing
            da.Dispose()
            con = Nothing
    End Sub

    Do you think that the method of filling grid view is the reason ?

    By the way  try/catch didn't appear any errors and i'm using trace.writeline instead of stopwatch,why the old app. and new program take a long time to open after setup.........

    I'm so happy to reach to this point and happy that two persons like you try helping me and guide me to the right way 

        

    Regards From Amr_Aly



    • Edited by Amr_Aly Saturday, November 25, 2017 10:03 PM
    Saturday, November 25, 2017 9:54 PM
  • Do you think that the method of filling grid view is the reason ?

    When you used the stopwatch component to time those routines and write the timings into your log file, which one took the longest?

    Saturday, November 25, 2017 11:07 PM
  • Amr,

    Try to be systematic, logical... if A then B.

    You say you setup with click once and with .msi and this works and that does not... So why is that? Did you figure that out? You need to pin point the exact reason something does not work. Then you know why. Then you know how it works. You cant just trial and error chunks of code that you cut and paste together. You need to understand what each line does and why. You wont ever be able to assemble a large complex something if you dont learn how each piece works and how to debug it. And practice it over and over.

    Ones mind gets lots of pieces of code and you logically assemble them in your mind and write them in the code editor and run them and debug them. Your mind cant assemble the chunks if your mind does not understand how each different chunk fits together.

    Then when it wont run or your mind is in overload, you have to systematically step through each line, this works, that works, this works.... whaaaaaaat ?????????

    I dont know databases but I dont see any reason why you cant retreive a record from a database and show it in a datagrid they way you show. So hang in there you are making progress, right? Its normally something simple once you figure it out.

    Sunday, November 26, 2017 1:02 AM
  • Amr,

    Try to be systematic, logical... if A then B.

    You say you setup with click once and with .msi and this works and that does not... So why is that? Did you figure that out? You need to pin point the exact reason something does not work. Then you know why. Then you know how it works. You cant just trial and error chunks of code that you cut and paste together. You need to understand what each line does and why. You wont ever be able to assemble a large complex something if you dont learn how each piece works and how to debug it. And practice it over and over.

    Ones mind gets lots of pieces of code and you logically assemble them in your mind and write them in the code editor and run them and debug them. Your mind cant assemble the chunks if your mind does not understand how each different chunk fits together.

    Then when it wont run or your mind is in overload, you have to systematically step through each line, this works, that works, this works.... whaaaaaaat ?????????

    I dont know databases but I dont see any reason why you cant retreive a record from a database and show it in a datagrid they way you show. So hang in there you are making progress, right? Its normally something simple once you figure it out.

    Thanks Tommy, 

    But i don't understand many of your words and your advices ,This is due to the nature of being new in programming by vb.net , i red some articles about debugging but i found that i didn't understand it completely ...

    Till now i don't know how break point work . i really tried it more than once but i didn't understand what it talk about (it didn't help me at all) .Trace helped me to find the time that every sub took but when i test my problem on my machine every thing is OK the problem on the other machine   .I will try to copy my new project to the second machine and try to debug it ...........

    thanks in advance sir


    Regards From Amr_Aly


    • Edited by Amr_Aly Sunday, November 26, 2017 7:12 AM
    Sunday, November 26, 2017 7:03 AM

  • When you used the stopwatch component to time those routines and write the timings into your log file, which one took the longest?

    Thanks Mr Acamar,

    I'm using Trace like this

        Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btnclear.Click
            Trace.WriteLine("btnclear_Click STARTED @ " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
            
            cbxSearch.Text = ""
            cbxPatName.Text = ""
            cbxAddress.Text = ""
            DTPicker.Value = Now
            txtAge.Text = ""
            txtPhone.Text = ""    
            cbxHusband.Text = ""
            
            txtNo.Text = GetAutonumber("Pat", "Patient_no")
            txtNo.Select()
            FillPat()
            FillGyn()
            FillGyn2()
    
            Trace.WriteLine("btnclear_Click FINISHED @ " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
        End Sub

    this method enables me to find the time that clear button took to perform the task.....this result in my PC by the new program some times took 1 second or two or none

    btnclear_Click STARTED @ 2017-11-26 09:18:59
    GetAutonumber STARTED @ 2017-11-26 09:18:59
    GetTable STARTED @ 2017-11-26 09:18:59
    FillPat STARTED @ 2017-11-26 09:18:59
    FillPat FINISHED @ 2017-11-26 09:18:59
    FillGyn STARTED @ 2017-11-26 09:18:59
    FillGyn FINISHED @ 2017-11-26 09:18:59
    FillGyn2 STARTED @ 2017-11-26 09:18:59
    FillGyn2 FINISHED @ 2017-11-26 09:18:59
    btnclear_Click FINISHED @ 2017-11-26 09:18:59

    btnclear_Click STARTED @ 2017-11-26 09:23:24
    GetAutonumber STARTED @ 2017-11-26 09:23:24
    GetTable STARTED @ 2017-11-26 09:23:24
    FillPat STARTED @ 2017-11-26 09:23:24
    FillPat FINISHED @ 2017-11-26 09:23:24
    FillGyn STARTED @ 2017-11-26 09:23:24
    FillGyn FINISHED @ 2017-11-26 09:23:24
    FillGyn2 STARTED @ 2017-11-26 09:23:24
    FillGyn2 FINISHED @ 2017-11-26 09:23:25
    btnclear_Click FINISHED @ 2017-11-26 09:23:25

    thanks in advance sir


    Regards From Amr_Aly

    Sunday, November 26, 2017 7:25 AM
  • this method enables me to find the time that clear button took to perform the task.....this result in my PC by the new program some times took 1 second or two or none

    There is no point in running it on your machine - you need to run it on the machines that have the problem.   However, you now have times to compare those other machines against.

    Sunday, November 26, 2017 8:58 AM
  • But i don't understand many of your words and your advices ,This is due to the nature of being new in programming by vb.net , i red some articles about debugging but i found that i didn't understand it completely ...

    Till now i don't know how break point work . i really tried it more than once but i didn't understand what it talk about (it didn't help me at all) .Trace helped me to find the time that every sub took but when i test my problem on my machine every thing is OK the problem on the other machine   .I will try to copy my new project to the second machine and try to debug it ...........

    thanks in advance sir


    Regards From Amr_Aly


    Amr,

    I figured that.  :)

    I am just giving you the words to learn. I am not explaining them. You have to look them up. Then you learn them.

    You can make a break point several ways. One is just put a line like this in your code:

        Stop

    But I just click the left border of the Visual Studio code window. That creates a red line at the break and then when you run the code it stops execution on that line (it is then yellow as shown):

    Then when the code stops on the break point, I examine the values with Intellisense by hovering the mouse over the variables.

    And then I single step to the next line using the debug tool bar. Look at the values. Step again...

    You may need to show the debug toolbar (I think its called that). I think <F8> key is single step but not sure. I just click the button.

    It takes practice. But this is how you start.

    I don't really know what the problem is. I am just helping you learn to debug.

    I suspect something is not installed properly on the problem machine, like the database version. Or its not referenced properly in your code. But I don't know just guessing.

    PS You cant do this on your customers problem computer as it is done in the VS IDE. But you can do the same thing using message boxes instead of debug break points. Or you can log them as you are. But that's why I asked if you can run your source code in VS on the problem computer. That would be easiest. However maybe you cant.

    Then you have to do the other things.


    And that's another thing you learn, how to look things up in the docs.
    Sunday, November 26, 2017 12:30 PM
  • OK Mr Tommy, 

    thank you for your explanation but this is like the articles i red before i'm hoovering the mouse and after single step and step over and out what's happen no result and no errors appear, I think break point when error occurs it's so helpful but here in my problem there is no field to break point i have no errors every thing is OK but when click on the grid view (when cell mouse click event has only this sub "ShowData" no hanging occurs )this is the code of "ShowData"

     Sub ShowData()
    
            If dgvPatients.CurrentRow IsNot Nothing Then
                txtNo.Text = dgvPatients.CurrentRow.Cells(0).Value.ToString
                cbxPatName.Text = dgvPatients.CurrentRow.Cells(1).Value.ToString
                cbxAddress.Text = dgvPatients.CurrentRow.Cells(2).Value.ToString
                DTPicker.Text = CType(dgvPatients.CurrentRow.Cells(3).Value, String)
                txtAge.Text = dgvPatients.CurrentRow.Cells(4).Value.ToString
                txtPhone.Text = dgvPatients.CurrentRow.Cells(5).Value.ToString
                cbxHusband.Text = dgvPatients.CurrentRow.Cells(6).Value.ToString
            End If
    
        End Sub

    but when i put in this event with "ShowData" another Subs the hanging and not responding appear again

    Private Sub dgvPatients_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvPatients.CellMouseClick
            ClearGyn2()
            ShowData()
            ShowGyn2PatTable()
            ShowGynTable()
        End Sub

    and this is ShowGyn2PatTable() code

        Sub ShowGyn2PatTable()
    
            Using con As New OleDbConnection("provider=microsoft.ace.oledb.12.0; data source=TestDB.accdb;jet oledb:database password=mero1981923")
                con.Open()
    
                Using cmd As New OleDbCommand
                    cmd.Connection = con
                    cmd.CommandText = "SELECT * FROM Gyn2 WHERE Patient_no=@Patient_no"
                    cmd.Parameters.Add("@Patient_no", OleDbType.Integer).Value = CInt(Val(txtNo.Text))
    
                    Using dt As New DataTable
                        dt.Load(cmd.ExecuteReader)
                        If dt.Rows.Count > 0 Then
                            txtVis.Text = dt.Rows(0).Item("Vis_no").ToString
                            txtNo.Text = dt.Rows(0).Item("Patient_no").ToString
                            cbxGL.Text = dt.Rows(0).Item("GL").ToString
                            cbxPuls.Text = dt.Rows(0).Item("Pls").ToString
                            cbxBP.Text = dt.Rows(0).Item("BP").ToString
                            cbxWeight.Text = dt.Rows(0).Item("Wt").ToString
                            cbxBodyBuilt.Text = dt.Rows(0).Item("BdBt").ToString
                            cbxChtH.Text = dt.Rows(0).Item("ChtH").ToString
                            cbxHdNe.Text = dt.Rows(0).Item("HdNe").ToString
                            cbxExt.Text = dt.Rows(0).Item("Ext").ToString
                            cbxFunL.Text = dt.Rows(0).Item("FunL").ToString
                            cbxScars.Text = dt.Rows(0).Item("Scrs").ToString
                            cbxEdema.Text = dt.Rows(0).Item("Edm").ToString
                            cbxUS.Text = dt.Rows(0).Item("US").ToString
                            txtAmount.Text = dt.Rows(0).Item("Amount").ToString
                            DTPickerAtt.Text = dt.Rows(0).Item("AttDt").ToString
                        End If
                    End Using
                End Using
            End Using
        End Sub

    and ClearGyn2()

     Sub ClearGyn2()
            Trace.WriteLine("ClearGyn STARED @ " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
    
            cbxGL.Text = ""
            cbxPuls.Text = ""
            cbxBP.Text = ""
            cbxWeight.Text = ""
            cbxBodyBuilt.Text = ""
            cbxChtH.Text = ""
            cbxHdNe.Text = ""
            cbxExt.Text = ""
            cbxFunL.Text = ""
            cbxScars.Text = ""
            cbxEdema.Text = ""
            cbxUS.Text = ""
            txtAmount.Text = ""
            DTPickerAtt.Value = Now
            txtVis.Text = GetAutonumber("Gyn2", "Vis_no")
    
            Trace.WriteLine("ClearGyn FINISHED @ " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
    
        End Sub

    and ShowGynTable()

    Sub ShowGynTable()
            Using con As New OleDbConnection("provider=microsoft.ace.oledb.12.0; data source=TestDB.accdb;jet oledb:database password=mero1981923")
                con.Open()
                Using cmd As New OleDbCommand
                    cmd.Connection = con
    
                    cmd.CommandText = "SELECT * FROM Gyn WHERE Patient_no=@Patient_no"
                    cmd.Parameters.Add("@Patient_no", OleDbType.Integer).Value = CInt(Val(txtNo.Text))
                    Using dt As New DataTable
                        dt.Load(cmd.ExecuteReader)
                        If dt.Rows.Count > 0 Then
                            txtNo.Text = dt.Rows(0).Item("Patient_no").ToString
                            txtVis1.Text = dt.Rows(0).Item("Vis_no").ToString
                            txtG.Text = dt.Rows(0).Item("G").ToString
                            txtP.Text = dt.Rows(0).Item("P").ToString
                            txtA.Text = dt.Rows(0).Item("A").ToString
                            cbxHPOC.Text = dt.Rows(0).Item("HPOC").ToString
                            cbxLD.Text = dt.Rows(0).Item("LD").ToString
                            cbxLC.Text = dt.Rows(0).Item("LC").ToString
                            DTPickerMns.Text = dt.Rows(0).Item("MNSDate").ToString
                            DTPickerLMP.Text = dt.Rows(0).Item("LMPDate").ToString
                            DTPickerEDD.Text = dt.Rows(0).Item("EDDDate").ToString
                            txtElapsed.Text = dt.Rows(0).Item("ElapW").ToString
                            txtGA.Text = dt.Rows(0).Item("GAW").ToString
                            cbxMedH1.Text = dt.Rows(0).Item("MedH1").ToString
                            cbxMedH2.Text = dt.Rows(0).Item("MedH2").ToString
                            cbxMedH3.Text = dt.Rows(0).Item("MedH3").ToString
                            cbxSurH1.Text = dt.Rows(0).Item("SurH1").ToString
                            cbxSurH2.Text = dt.Rows(0).Item("SurH2").ToString
                            cbxSurH3.Text = dt.Rows(0).Item("SurH3").ToString
                            cbxGynH1.Text = dt.Rows(0).Item("GynH1").ToString
                            cbxGynH2.Text = dt.Rows(0).Item("GynH2").ToString
                            cbxGynH3.Text = dt.Rows(0).Item("GynH3").ToString
                            cbxDrugH1.Text = dt.Rows(0).Item("DrugH1").ToString
                            cbxDrugH2.Text = dt.Rows(0).Item("DrugH2").ToString
                            cbxDrugH3.Text = dt.Rows(0).Item("DrugH3").ToString
                        End If
                    End Using
                End Using
            End Using
        End Sub

    I've no error message the Application on my PC is so smooth and work normally but on any device has low configuration makes not responding and hanging,It's a small application has 2 forms only I think this problem concern database or something like that ..........Task manager appears on my PC that action consumes till 10% of the CPU but the same action takes 50% of the CPU on the other PC................

    Now i have VS 2015 on the other PC and break point didn't help me to solve the problem because it's no problem(But consuming CPU occurs to perform tasks on my app.)

    and Trace appears that the same action takes a long time and this is the difference between my PC and the other PC ........... 

    when i took my app.msi package to one of my old friend and installed my app. on his PC and the hanging appeared quickly he said one thing i can't forget it .... He said to me "this is another application on the same machine works with SQL server and the database locates in another PC(via network) and it works normally without hanging or any delay in  any tasks " . He wondered when he saw my database file so small and this hanging occurs with every action........

    Thanks Mr Tommy and Mr Acamar   


    Regards From Amr_Aly

    Monday, November 27, 2017 2:37 PM
  • Amr,

    Hmmm.

    Well break points dont always tell you anything.

    Especially if the problem is due to looping caused by other events calling each other.

    When you break on a line of code, and step through the code, you may not get all the events firing when you can step through them in debug. Say you set gridview selected index = 4. That will fire the dgv selected index changed event, maybe there in the dgv event you picturebox.invalidate, And then keep single stepping. You may not ever single step into the paint event. Sometimes if the code is not exectuting normally as when single stepping the system will have to skip some events.

    Well as I say I dont know databases. But you are basically saying you need to make a simple example that reproduces the problem. A one form example that just does the db lookup to test that. Thats what you keep thinking is the problem. So make a simple test. And install it the same way with the msi. Something that Acamar or Karen or others that know db can spot something. A simple example that you can post here and others here can reproduce. Then if you do that post a new question and ref this one. That way more will look at it.

    I am still thinking you need to check your setup/installer things. I recall lots of version issues I see on the forum. Like one is x86 and one is 64 bit.


    PS when your current app is slow on the problem computer, is it giving the right answer?
    Monday, November 27, 2017 2:54 PM
  • and Trace appears that the same action takes a long time and this is the difference between my PC and the other PC ........... 

    Then you need to narrow down the code included in each trace.  Remove the tracing where the timing information tells you that there is no delay problem.  Where you are seeing from the tracing times that there is a delay, add more trace commands so that you can see the time taken by smaller and smaller sections of code.   You might even have to get down to timing individual statements.

    If you see that there are several statements each one taking a long time (such as populating the comboboxes) then you need to consider whether you can do it differently.  If you see that one statement causes a big delay then  you need to look closer.  For instance, do any of those controls invoke other events (eg, textchanged events for the textboxes) which is causing other code to execute?  Do you need to disable those events while you do the update?   Only when you know exactly where the delays are occurring can you start to consider the cause. 

    Monday, November 27, 2017 8:23 PM
  • Many Thanks Mr Acamar and Mr Tommy really i appreciated your efforts and time but i'm so happy this forum let me know respectable persons like you ......

    As i said before my problem was a database issue, I noticed that when i removed some code the problem didn't solve as well ,But when i removed the "Data Grid View" the problem completely solved. I've programmed by VB.Net 5 months ago ,I thought that DGV is very helpful but i found the opposite thing it makes the program hanging every time ,Because it loads the whole database table so if the database now has 100 ID and 100 Name and 100 Address and 100 Phone number and 100 Birth date ,Then what about after 1 year of working , DGV must load all of the table immediately to play a role of displaying(to enable the users from clicking and get the data by simple way) and this method is very very wrong because the heavy load unable the application to perform well. Unfortunately i thought all the time that DGV is useful and i can't get rid of it but after i felt disappointing and frustrating in the last 15 days i can now say that there are a lot of things and methods instead of DGV .......

      


    Regards From Amr_Aly


    • Edited by Amr_Aly Wednesday, November 29, 2017 5:29 PM
    Tuesday, November 28, 2017 6:46 PM
  • Hi Amr_Aly,

    It seems that you have some update about your issue, please remember to close your thread by marking the helpful post as answer, it is beneficial to other community members who face the same issue.

    Thanks for your understanding.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 30, 2017 8:32 AM
    Moderator
  • Hi Amr_Aly,

    It seems that you have some update about your issue, please remember to close your thread by marking the helpful post as answer, it is beneficial to other community members who face the same issue.

    Thanks for your understanding.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thanks Kunmo bu,

    but i am waiting for a response my question has not finished yet


    Regards From Amr_Aly

    Thursday, November 30, 2017 8:39 AM
  • There are so many solutions given, that it is better first to try it yourself and if you don't succeed show the piece of code you made.

    Max 20 lines to give us insight and not your whole program.


    Success
    Cor

    Thursday, November 30, 2017 9:44 AM
  • There are so many solutions given, that it is better first to try it yourself and if you don't succeed show the piece of code you made.

    Max 20 lines to give us insight and not your whole program.


    Success
    Cor

    Excuse me sir, 

    "Many solutions given" didn't solve my problem ,But when i removed the DGV my big problem solved ... But Mr Acamar solved my first issue of  the print button by guide me to install my app. and i was have a second issue, The problem was in the DGV .........

    "As i said before my problem was a database issue, I noticed that when i removed some code the problem didn't solve as well ,But when i removed the "Data Grid View" the problem completely solved."

    I will close this question    


    Regards From Amr_Aly

    Thursday, November 30, 2017 10:04 AM
  • There are so many solutions given, that it is better first to try it yourself and if you don't succeed show the piece of code you made.

    Max 20 lines to give us insight and not your whole program.


    Success
    Cor

    Excuse me sir, 

    "Many solutions given" didn't solve my problem ,But when i removed the DGV my big problem solved ... But Mr Acamar solved my first issue of  the print button by guide me to install my app. and i was have a second issue, The problem was in the DGV .........

    "As i said before my problem was a database issue, I noticed that when i removed some code the problem didn't solve as well ,But when i removed the "Data Grid View" the problem completely solved."

    I will close this question    


    Regards From Amr_Aly

    This does not help you.

    Mark the answer from Acamar as answer and create a new Question. 

    In that way you are not only helping yourself but make it easier for those who want that to help you.


    Success
    Cor

    Thursday, November 30, 2017 10:32 AM
  • No one said that i'm helping myself, That's exactly what i will do sir ,Without Mr Acamar i didn't reach to solve my problem, But i wait him to response to discuss about removing DGV and what's we can use instead of it ,

    But i think it's time to end this thread

    thank you sir .... and  i want you to know that Amr Aly appreciates anyone here do his best to help and give an advice 


    Regards From Amr_Aly

    Thursday, November 30, 2017 11:24 AM
  • No one said that i'm helping myself, That's exactly what i will do sir ,Without Mr Acamar i didn't reach to solve my problem, But i wait him to response to discuss about removing DGV and what's we can use instead of it ,

    But i think it's time to end this thread

    thank you sir .... and  i want you to know that Amr Aly appreciates anyone here do his best to help and give an advice 


    Regards From Amr_Aly

    Amr,

    Yes its best to start an new question with that now. You will get new info and others looking. Since this thread asks about printing in the title you don't get db people looking at it as much.

    I will guess now that you have the dgv bound to a datatable and you should update the datatable not the DGV? But just guessing.

    Ref this thread. Try to make a simple example to post of just the exact problem with the latest info you have now.


    PS We always say make a simple example. I know its hard. But its how we understand the question. But more important its how you understand the question. And many many times when I am making my example and writing my question for the forum I figure out the problem and don't have to post the question.

    :)


    Thursday, November 30, 2017 11:51 AM
  • Thanks Mr Tommy ,

    I appreciate your time and efforts you are a respectable man, I will do.

    Many thanks sir....................................... 


    Regards From Amr_Aly

    Thursday, November 30, 2017 4:03 PM