| | |
Elapsed time for retriving data from database
![]() |
•
•
Join Date: Jul 2004
Posts: 5
Reputation:
Solved Threads: 0
Hye, im new here. Need some help on Vb6 coding.
I've look up some of the treads on timing in this site but i have problem implementing it.
-------------------------------------------------------------
I want the timer to start when i press the EXECUTE button(cmdSQL) , and start counting from miliseconds and stop after the result being displayed.
We are able to start the timer after pressing the EXECUTE button but it won't stop even after the data has been retrieve from the database.
We have been using MS SQL Server2000.
Thank you in advanced.
I've look up some of the treads on timing in this site but i have problem implementing it.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Public CHours As Variant Public CMins As Variant Public CSecs As Variant Public CMSecs As Variant Dim StrNested(4) As String ------------------------------------------------------------ Private Sub cmdSQL_Click() On Error Resume Next Adodc1.RecordSource = txtSQL.Text Adodc1.Refresh End Sub ----------------------------------------------------------- Private Sub Combo1_Click() Label1.Caption = Combo1.List(Combo1.ListIndex) txtSQL.Text = StrNested(Combo1.ListIndex) txtSQL.Enabled = False End Sub ------------------------------------------------------ Private Sub DataGrid1_Click() Adodc1.Refresh Timer_1.Enabled = False End Sub ------------------------------------------------------- Private Sub Form_Load() Text1.Text = "00:00:00:00" Timer_1.Enabled = True StrNested(0) = "SELECT * from products" StrNested(1) = "SELECT * from suppliers" StrNested(2) = "SELECT * from orders" StrNested(3) = "SELECT * from customers " StrNested(4) = "SELECT ProductID, ProductName From Products" Combo1.AddItem "Nested Loop" Combo1.AddItem "Nested Loop(with Option) " Combo1.AddItem "Hash Join" Combo1.AddItem "Merge Join" Combo1.AddItem "NEW" End Sub ------------------------------------------------------- Private Sub Timer_1_Timer() parts = Split(Text1.Text, ":") CHours = CInt(parts(0)) CMins = CInt(parts(1)) CSecs = CInt(parts(2)) CMSecs = CInt(parts(3)) If CSecs >= 10 Then CMins = CMins + 1 CSecs = 0 Else CSecs = CSecs + 1 End If If CMins >= 60 Then CHours = CHours + 1 CMins = 0 End If If CHours < 10 Then CHours = "0" & CHours If CMins < 10 Then CMins = "0" & CMins If CSecs < 10 Then CSecs = "0" & CSecs Text1.Text = CHours & ":" & CMins & ":" & CSecs & ":" CMSecs End Sub
I want the timer to start when i press the EXECUTE button(cmdSQL) , and start counting from miliseconds and stop after the result being displayed.
We are able to start the timer after pressing the EXECUTE button but it won't stop even after the data has been retrieve from the database.
We have been using MS SQL Server2000.
Thank you in advanced.
Last edited by Comatose; Apr 27th, 2006 at 7:16 am.
•
•
Join Date: Jul 2004
Posts: 5
Reputation:
Solved Threads: 0
it still won't work, this is the new code i've tried, instead of datagrid_click i use _change:-
----------------------------------------------------------------
and another problem i encountered is that, the mseconds suppose to run fast as in the example in this thread the stop watch, but after execution it moves like seconds. Do u know why is this happening? Or it will be great if u can suggest any other way to get the elapsed time while retrieving the data. Thank You!
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim StrNested(4) As String Public CMins As Variant Public CSecs As Variant Public CMSecs As Variant ----------------------------------------------------- Private Sub cmdSQL_Click() cmdSQL.Caption = "EXECUTE" Timer1.Enabled = True On Error Resume Next Adodc1.RecordSource = txtSQL.Text Adodc1.Refresh End Sub ----------------------------------------------------- Private Sub Combo1_Click() Label1.Caption = Combo1.List(Combo1.ListIndex) txtSQL.Text = StrNested(Combo1.ListIndex) txtSQL.Enabled = False End Sub ---------------------------------------------------------------- Private Sub DataGrid1_AfterUpdate() Timer1.Enabled = False End Sub ---------------------------------------------------------------- Private Sub Form_Load() Text1.Text = "00:00:00" Timer1.Enabled = True StrNested(0) = "SELECT pdN.ProductID, pdN.ProductName, spN.CompanyName, spN.ContactName FROM dbo.ProductsNew pdN INNER JOIN dbo.SuppliersNew spN ON pdN.SupplierId = spN.SupplierId" StrNested(1) = "SELECT ProductID, ProductName, CompanyName, ContactName FROM dbo.ProductsNew JOIN dbo.SuppliersNew ON ProductsNew.SupplierId = SuppliersNew.SupplierId OPTION (LOOP JOIN)" StrNested(2) = "SELECT ProductID, ProductName, CompanyName, ContactName From dbo.ProductsNew, dbo.SuppliersNew WHERE ProductsNew.SupplierId = SuppliersNew.SupplierId" StrNested(3) = "SELECT ProductID, ProductName, CompanyName, ContactName From ProductsNew Join SuppliersNew ON ProductsNew.SupplierId = SuppliersNew.SupplierId OPTION (MERGE JOIN)" StrNested(4) = "SELECT * From Suppliers WHERE SupplierID >=20" Combo1.AddItem "Nested Loop" Combo1.AddItem "Nested Loop(with Option) " Combo1.AddItem "Hash Join" Combo1.AddItem "Merge Join" Combo1.AddItem "NEW" Timer1.Enabled = False End Sub ------------------------------------------------------------------------- Private Sub Timer1_Timer() parts = Split(Text1.Text, ":") CMins = CInt(parts(0)) CSecs = CInt(parts(1)) CMSecs = CInt(parts(2)) If CMSecs >= 10 Then CSecs = CSecs + 1 CMSecs = 0 Else CMSecs = CMSecs + 1 End If If CSecs >= 60 Then CMins = CMins + 1 CSecs = 0 End If If CMins < 10 Then CMins = "0" & CMins If CSecs < 10 Then CSecs = "0" & CSecs If CMSecs < 10 Then CMSecs = "0" & CMSecs Text1.Text = CMins & ":" & CSecs & ":" & CMSecs End Sub
----------------------------------------------------------------
and another problem i encountered is that, the mseconds suppose to run fast as in the example in this thread the stop watch, but after execution it moves like seconds. Do u know why is this happening? Or it will be great if u can suggest any other way to get the elapsed time while retrieving the data. Thank You!
Last edited by cscgal; Apr 29th, 2006 at 11:06 am.
•
•
Join Date: Jul 2004
Posts: 5
Reputation:
Solved Threads: 0
i post up my current code, so u could let me know on how i will be able to set the milliseconds.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim StrNested(4) As String Dim dtmEnd As Date, dtmstart As Date, dtmTotalTime As Date ----------------------------------------------------------------------------------- Private Sub cmdSQL_Click() dtmstart = Time Text2.Text = Format(dtmstart, "hh:mm:ss") On Error Resume Next Adodc1.RecordSource = txtSQL.Text Adodc1.Refresh dtmEnd = Time Text3.Text = Format(dtmEnd, "hh:mm:ss") dtmTotalTime = dtmEnd - dtmstart Text1.Text = Format(dtmTotalTime, "hh:mm:ss") End Sub ---------------------------------------------------------------------------------- Private Sub Combo1_Click() Label1.Caption = Combo1.List(Combo1.ListIndex) txtSQL.Text = StrNested(Combo1.ListIndex) txtSQL.Enabled = False End Sub ------------------------------------------------------------------------------- Private Sub Form_Load() dtmstart = Empty dtmEnd = Empty Text1.Text = "00:00:00:00" StrNested(0) = "SELECT pdN.ProductID, pdN.ProductName, spN.CompanyName, spN.ContactName FROM dbo.ProductsNew pdN INNER JOIN dbo.SuppliersNew spN ON pdN.SupplierId = spN.SupplierId" StrNested(1) = "SELECT ProductID, ProductName, CompanyName, ContactName FROM dbo.ProductsNew JOIN dbo.SuppliersNew ON ProductsNew.SupplierId = SuppliersNew.SupplierId OPTION (LOOP JOIN)" StrNested(2) = "SELECT ProductID, ProductName, CompanyName, ContactName From dbo.ProductsNew, dbo.SuppliersNew WHERE ProductsNew.SupplierId = SuppliersNew.SupplierId" StrNested(3) = "SELECT ProductID, ProductName, CompanyName, ContactName From ProductsNew Join SuppliersNew ON ProductsNew.SupplierId = SuppliersNew.SupplierId OPTION (MERGE JOIN)" StrNested(4) = "SELECT * From Suppliers WHERE SupplierID >=20" Combo1.AddItem "Nested Loop" Combo1.AddItem "Nested Loop(with Option) " Combo1.AddItem "Hash Join" Combo1.AddItem "Merge Join" Combo1.AddItem "NEW" End Sub
•
•
Join Date: Jul 2004
Posts: 5
Reputation:
Solved Threads: 0
i've read the thread u posted, and it seems like u've been using the GetSystemTime APi, function. i've tried implementing it, but the problem now is, how can i calculate the time difference. i managed to get both the start n end time. but it seems like, it is impossible to get the time difference. i've read somewhere that, GetSystemTime doesn't return value.
hope u can help me
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Declare Sub GetLocalTime Lib "kernel32.dll" (lpSystemTime As SYSTEMTIME) Private Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type Dim gtime As SYSTEMTIME Dim gtime2 As SYSTEMTIME --------------------------------------------------------------------------------- Private Sub cmdSQL_Click() GetLocalTime gtime Text2.Text = gtime.wHour & ":" & gtime.wMinute & ":" & gtime.wSecond & ":" & gtime.wMilliseconds On Error Resume Next Adodc1.RecordSource = txtSQL.Text Adodc1.Refresh GetLocalTime gtime2 Text3.Text = gtime2.wHour & ":" & gtime2.wMinute & ":" & gtime2.wSecond & ":" & gtime2.wMilliseconds 'i wish to display the result of the time difference here Text1.Text = dtmTotalTime End Sub
hope u can help me
![]() |
Similar Threads
- retrieving a single cell of data from a MySQL database (PHP)
- How to store data in data grid to database by single mouse click in Asp.net (ASP.NET)
- copy data from excel to vb database (Visual Basic 4 / 5 / 6)
- Inserting Data into Access Database (Java)
- Posting form data to an Oracle database (JavaScript / DHTML / AJAX)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: How Grid works with code
- Next Thread: Macro for deleting Page & Section breaks
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






