Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting label text before connecting to db

Status
Not open for further replies.

JGALEY

IS-IT--Management
May 21, 2003
105
US
I have what may be a newbie question: I am using a label to show status messages. Things like, click an update button, a db update happens, and then the label.text is set to "update complete."

I want to set the label text BEFORE a long query runs to say something like "Processing, please wait..."

The problem is that any me.label.text = statement I put before opening the connection and running a query seems to be ignored. I can set the label text after the query finishes, but not before. A simple example is below:

Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click

Me.label.text = "Processing, please wait..."

Dim cn As New SqlConnection(Application("cnString"))
Dim cmd As New SqlCommand

cmd.CommandText = "Stored_Procedure"
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandTimeout = 2000 'long running query

cmd.Connection = cn
cn.Open()
cmd.ExecuteNonQuery()

cn.Close()

Me.label.Text = "Process complete."

End Sub

What am I missing, here? Thanks in advance!

Jason
 
Hi Jason,

I have what may be a newbie answer :)

The Me.label.text = "Processing, please wait..." isn't being ignored. It is being run but the page isn't updated until the Sub Procedure has completed.

Now, being a complete newb myself I don't know how to do this but I found an article that may help...


Also, you may want the btn_click sub to redirect to a new page that would do the processing with a Please Wait... label already there.

Just some suggestions...

LL
 
Thanks, LL, that is very helpful! :)

Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top