TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Scott McGlothlin
NA
34
0
Event activities have to wait for try/catch
Jul 27 2008 8:49 PM
Hello,
My problem is, hopefully, a simple one. I have a label and picturebox that need to be visible when a button_click event occurs. The event includes a try/catch statement (for a SQL stored procedure) and that is what these items are for (to show the user that the process is running). The problem is that these items won't display until the try/catch is completed. I've tried moving them within the event code, using a delegate, goto statement etc... and the behaviour is the same. Any ideas would be much appreciated!
Here is the code:
private void button1_Click(object sender, EventArgs e)
{
label9.Visible = true; // show "Vendor Contract Uploading" label
pictureBox2.Visible = true; // show progressbar.gif
button1.Visible = false; // hide "Execute Vendor Contract Upload" button
try
{
String vendorNo = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); // get Vendor_No
SqlConnection conn = new SqlConnection(appString.ToString()); // SQL connection string from app settings
SqlCommand command = new SqlCommand("A_P_VENDOR_CONTRACT", conn); // stored procedure
command.CommandTimeout = 5000;
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@VENDOR_NO", SqlDbType.NVarChar).Value = vendorNo; // SP parameter
conn.Open();
int rows = command.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Upload Completed!"); // operation completed message
button3.Visible = true; // show "Upload .XLS File" button again
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Reply
Answers (
2
)
books
Int.ToString