Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Why my program "sleep" for a moment [modified]

Why my program "sleep" for a moment [modified]

Scheduled Pinned Locked Moved Visual Basic
databaseannouncement
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ivo75
    wrote on last edited by
    #1

    Why my program "sleep" when I use this code for export data from one Database to another

    Public Sub uchenici_DataU()

        If Exists(strAcessFilePath11 & "\\Update.mdb") Or Exists(strAcessFilePath11 & "\\Update.accdb") Then
    
            Dim selectdata2 As String
            selectdata2 = "SELECT Students.\[ID number\], Students.\[Name 1\], Students.\[Name 2\], Students.\[Name 3\], \[Code Class\].\[Class No\], \[Code Paralell class\].\[Paralell class Name\], Students.Address FROM ((\[C<ode Paralell class\] INNER JOIN \[Code Class\] ON \[Code Paralell class\].\[Paralell class ID\] = \[Code Class\].\[Paralell class\]) INNER JOIN \[Class Details\] ON \[Code Class\].\[Class ID\] = \[Class Details\].Class) INNER JOIN (Students INNER JOIN StudentClass ON Students.\[ID number\] = StudentClass.\[ID number\]) ON (\[Class Details\].BasicClass = StudentClass.BasicClass) AND (\[Class Details\].Group = StudentClass.Group) AND (\[Class Details\].Class = StudentClass.Class) WHERE (((StudentClass.\[Position\])=1)) ORDER BY \[Code Class\].\[Class No\], \[Code Paralell class\].\[Paralell class Name\]"
            Dim strConn As String
            Dim reader1 As OleDbDataReader
            strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strAcessFilePath3 & ";User ID=Admin;Password="
            Using theConnection As New OleDbConnection(con\_str)
                theConnection.Open()
                Using OleDbCommand2 = New OleDbCommand(selectdata2, theConnection)
                    reader1 = OleDbCommand2.ExecuteReader()
                    FlowLayoutPanel1.Visible = True
                    ProgressBar1.MarqueeAnimationSpeed = 50
                    ProgressBar1.Style = ProgressBarStyle.Marquee
                    While (reader1.Read())
                        masiv(0) = reader1.Item(0)
                        If masiv(0).Length = 8 Then
                            masiv(0) = "00" & masiv(0)
                        ElseIf masiv(0).Length = 9 Then
                            masiv(0) = "0" & masiv(0)
                        End If
                        masiv(1) = reader1.Item(1).ToString & " " & reader1.Item(2).ToString & " " & reader1.Item(3).ToString
                        masiv(2) = reader1.Item(4) & reader1.Item(5)
                        masiv(3) = reader1.Item(4)
                        masiv(4) = reader1.Item(6).ToString
                        Get\_egn()
                        If vzemi\_egn = "" Then
                            prehvyrlqne\_ot\_DGrid()
    
    L 1 Reply Last reply
    0
    • I ivo75

      Why my program "sleep" when I use this code for export data from one Database to another

      Public Sub uchenici_DataU()

          If Exists(strAcessFilePath11 & "\\Update.mdb") Or Exists(strAcessFilePath11 & "\\Update.accdb") Then
      
              Dim selectdata2 As String
              selectdata2 = "SELECT Students.\[ID number\], Students.\[Name 1\], Students.\[Name 2\], Students.\[Name 3\], \[Code Class\].\[Class No\], \[Code Paralell class\].\[Paralell class Name\], Students.Address FROM ((\[C<ode Paralell class\] INNER JOIN \[Code Class\] ON \[Code Paralell class\].\[Paralell class ID\] = \[Code Class\].\[Paralell class\]) INNER JOIN \[Class Details\] ON \[Code Class\].\[Class ID\] = \[Class Details\].Class) INNER JOIN (Students INNER JOIN StudentClass ON Students.\[ID number\] = StudentClass.\[ID number\]) ON (\[Class Details\].BasicClass = StudentClass.BasicClass) AND (\[Class Details\].Group = StudentClass.Group) AND (\[Class Details\].Class = StudentClass.Class) WHERE (((StudentClass.\[Position\])=1)) ORDER BY \[Code Class\].\[Class No\], \[Code Paralell class\].\[Paralell class Name\]"
              Dim strConn As String
              Dim reader1 As OleDbDataReader
              strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strAcessFilePath3 & ";User ID=Admin;Password="
              Using theConnection As New OleDbConnection(con\_str)
                  theConnection.Open()
                  Using OleDbCommand2 = New OleDbCommand(selectdata2, theConnection)
                      reader1 = OleDbCommand2.ExecuteReader()
                      FlowLayoutPanel1.Visible = True
                      ProgressBar1.MarqueeAnimationSpeed = 50
                      ProgressBar1.Style = ProgressBarStyle.Marquee
                      While (reader1.Read())
                          masiv(0) = reader1.Item(0)
                          If masiv(0).Length = 8 Then
                              masiv(0) = "00" & masiv(0)
                          ElseIf masiv(0).Length = 9 Then
                              masiv(0) = "0" & masiv(0)
                          End If
                          masiv(1) = reader1.Item(1).ToString & " " & reader1.Item(2).ToString & " " & reader1.Item(3).ToString
                          masiv(2) = reader1.Item(4) & reader1.Item(5)
                          masiv(3) = reader1.Item(4)
                          masiv(4) = reader1.Item(6).ToString
                          Get\_egn()
                          If vzemi\_egn = "" Then
                              prehvyrlqne\_ot\_DGrid()
      
      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      That code dump is not formatted and unreadable, please edit your message and add PRE tags.

      ivo75 wrote:

      Why my program "sleep"

      You probably mean the GUI freezes (i.e. high CPU load, no Form resize/repaint; a sleeping program would not cause any CPU load), which would suggest you have too much going on in some event handler; if so, the solution is using one or more additional threads (Thread, ThreadPool, BackgroundWorker, etc). :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      I 1 Reply Last reply
      0
      • L Luc Pattyn

        That code dump is not formatted and unreadable, please edit your message and add PRE tags.

        ivo75 wrote:

        Why my program "sleep"

        You probably mean the GUI freezes (i.e. high CPU load, no Form resize/repaint; a sleeping program would not cause any CPU load), which would suggest you have too much going on in some event handler; if so, the solution is using one or more additional threads (Thread, ThreadPool, BackgroundWorker, etc). :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        I Offline
        I Offline
        ivo75
        wrote on last edited by
        #3

        I insert in SQL statment another SQL statment maybe for this is hapent this.

        L 1 Reply Last reply
        0
        • I ivo75

          I insert in SQL statment another SQL statment maybe for this is hapent this.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Your SQL operations really are too complex, and hence will take too long, to run them on the main thread. I suggest you use a BackgroundWorker and use its progress reporting to update the GUI (the DoWork handler itself is not allowed to touch the GUI Controls!). :)

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          I 1 Reply Last reply
          0
          • L Luc Pattyn

            Your SQL operations really are too complex, and hence will take too long, to run them on the main thread. I suggest you use a BackgroundWorker and use its progress reporting to update the GUI (the DoWork handler itself is not allowed to touch the GUI Controls!). :)

            Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

            I Offline
            I Offline
            ivo75
            wrote on last edited by
            #5

            give me some example how to use BackgroundWorker

            L 1 Reply Last reply
            0
            • I ivo75

              give me some example how to use BackgroundWorker

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Of course, Sir. Here you go, Sir: examples[^]. Anything else you require, Sir? :)

              Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

              I 1 Reply Last reply
              0
              • L Luc Pattyn

                Of course, Sir. Here you go, Sir: examples[^]. Anything else you require, Sir? :)

                Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                I Offline
                I Offline
                ivo75
                wrote on last edited by
                #7

                Thanks :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups