Question Want to show execution time to the user before values comes to the datagrid?

dawoodkhan

New member
Joined
Dec 23, 2009
Messages
2
Location
Delhi
Programming Experience
Beginner
Hi All,

I am a new bee to vb.net and would be requiring a help here, can any one give an example that how should i do it.... thanks for your support

Windows Application
Front End: Vb.net
Backend: Oracle 10g

I am executing the sql query to fetch values and showing it in my datagrid..and when i do that it works perfectly fine...and problem is that it takes 10 min for my datagrid to fill...so in between i want to show the execution time to the user in another form till my query processing completes..

My Code:
Dim oradb As String = "Data Source=zorb;User Id=baady;Password=zacky;"
Dim conn As New OracleConnection(oradb) ' VB.NET

Try



conn.Open()


Dim cmd As New OracleCommand
cmd.Connection = conn

Dim sql As String = "Select * from QAtable where START_DT >= TO_DATE('12/18/2009','MM/DD/YYYY') order by DT_JOB_ID desc NULLS LAST"

cmd = New OracleCommand(sql, conn)
cmd.CommandType = CommandType.Text


da = New OracleDataAdapter(cmd)
cb = New OracleCommandBuilder(da)
ds = New DataSet()

da.Fill(ds)

DataGridView1.DataSource = ds.Tables(0)
Dim cm As CurrencyManager = BindingContext(DataGridView1.DataSource, DataGridView1.DataMember)
Dim dv As DataView = cm.List
dv.AllowNew = False



conn.Close()


Catch ex As Exception
MessageBox.Show(ex.Message())
Finally
conn.Dispose()
End Try


Please quick help is required
:rolleyes:
 
While its true that you cant tell how long the query is going to take, its possible to give your user and idea of the time lapsed/remaining.

You can try using the progress bar control.
You then set its 'max' property to your query recordcount.
As you iterate through the records increase the progress bars 'value' property. Here's an example; ('Rs' is an ADODB recordset)

VB.NET:
ProgressBar1.Max = Rs.RecordCount - 1

        For P = 0 To .RecordCount - 1
           ProgressBar1.Value = P

            'some process here
            Rs.MoveNext

        Next P
 
Form2 gets hanged during the runtime of my query

While its true that you cant tell how long the query is going to take, its possible to give your user and idea of the time lapsed/remaining.

You can try using the progress bar control.
You then set its 'max' property to your query recordcount.
As you iterate through the records increase the progress bars 'value' property. Here's an example; ('Rs' is an ADODB recordset)

VB.NET:
ProgressBar1.Max = Rs.RecordCount - 1

        For P = 0 To .RecordCount - 1
           ProgressBar1.Value = P

            'some process here
            Rs.MoveNext

        Next P

Thanks Alander for this suggestion....
but My problem is that if i show progress bar or execution time then My Form gets hanged till the recordset appears to my datagrid...

What i want is....that
When i click [Execute] Button then Form2 appears with with a message or execution time....till the recordset appears in the datagrid.... without hanging..
Currently i am able to the show message and execution time on form2 but it gets hanged after appearing...thats why user cant see the running time in the form......Do we have a solution for this?


Would be a great help...Thanks....:D
 
Back
Top