Why my program "sleep" for a moment [modified]
-
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()
-
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()
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.
-
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.
-
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.
-
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.
-
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.
-
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.