473,509 Members | 3,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I get my new form inmediately after form2.showdialog()?

12 New Member
Hi,

I am writing an application in VB2008 with several forms. From Form1 I open a new form with me.hide() and then form2.showdialog(). The system works but in form2 the application runs without screendisplay until the program waits for a user input. So first all databases are processed. Meanwhile no screen is visible for the user. Sometimes this takes about 5 seconds. I would like the user to see the build up screen directly. How can I improve this ?
Feb 24 '09 #1
9 2019
OuTCasT
374 Contributor
How have u bound ur database to the program ?
Feb 24 '09 #2
Alfredo73
12 New Member
Public connectionstring As String = "Data Source=.\SQLEXPRESS;AttachDBFilename=d:\databases\ dtbs.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
Public myconnection As New SqlConnection(connectionstring)
Public sqlcommando As New SqlCommand()

and in the sub:
sqlcommando.Connection = myconnection
sqlcommando.CommandText = "SELECT * FROM Accounts where AccountNr = '" + AccountNrTextBox.Text + "'"
myconnection.Open()
Dim myReader As SqlDataReader
myReader = sqlcommando.ExecuteReader()
Feb 24 '09 #3
OuTCasT
374 Contributor
So u are saying that when u click to on a button to show form2 like form2.show and u hide the form1 with me.hide. Then the connection is executed and then it take like 5 seconds to load the form2 where the information from the database will be displayed ?
Feb 25 '09 #4
Alfredo73
12 New Member
Hi OuTCasT, thanks for your reply. Yes, when the program executes Form2 and even if the first line of the load_form2 says label1.text="Whatever", it first executes all other commands (which takes up to 5 seconds) before it shows Form2. (might it be any setting that says dont show the form before everything is finished?)
Feb 25 '09 #5
OuTCasT
374 Contributor
How have u bound ur data to your controls on the Form2 ??
Like the textboxes etc ?

It would be better to fill a dataset with the data instead of loading it straight to the form and then editing the dataset with the information you need and submitting the changed dataset back to the database
Feb 25 '09 #6
Alfredo73
12 New Member
No, nothing is bound in the design. In the class I give the orders like label1.text=myreader("AccountNr"). The tables are small (only 10 lines at the moment), 4 tables in the database.
Feb 25 '09 #7
OuTCasT
374 Contributor
Expand|Select|Wrap|Line Numbers
  1. Dim sqlcon As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=pd;Integrated Security=True")
  2.     'Commands and adapter for the Employee masterfile
  3.     Dim sqlEmployeeCommand As SqlCommand
  4.     Dim sqlEmployeeAdapter As SqlDataAdapter
  5.     Dim sqlEmployeeDataTable As DataTable
  6.     'Currency Managers for Commands above
  7.     Dim sqlEmployeeManager As CurrencyManager
  8.  
  9. 'lblPaymentPeriod.Text = strPaymentPeriod
  10.         sqlEmployeeCommand = New SqlCommand("SELECT * FROM EmployeeDetails order by EmployeeID", sqlcon)
  11.         sqlEmployeeAdapter = New SqlDataAdapter(sqlEmployeeCommand)
  12.         sqlEmployeeDataTable = New DataTable
  13.         sqlEmployeeAdapter.Fill(sqlEmployeeDataTable)
  14.  
  15. ' Fill Table with EmployeeDetails
  16.         lblInitials1.DataBindings.Add("text", sqlEmployeeDataTable, "Employeeinitials", True)
  17.         lblEmployeeName1.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeSurname", True)
  18.         lblPaymentPeriod.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePaymentType", True)
  19.         ' lblEmployeePreviousNormalStatus.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePreviousNormalStatus", True)
  20.         txtEmployeeCode.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeID", True)
  21.         txtSurname.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeSurname", True)
  22.         txtInitials.DataBindings.Add("Text", sqlEmployeeDataTable, "EmployeeInitials", True)
  23.         txtFirstNames.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeFirstName", True)
  24.         cbTitle.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeTitle", True)
  25.         txtNickName.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeNickName", True)
  26.         txtPhysAddress1.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePhysicalAddress1", True)
  27.         txtPhysAddress2.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePhysicalAddress2", True)
  28.         txtPhysAddress3.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePhysicalAddress3", True)
  29.         txtPhysPCode.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePhysicalPostalCode", True)
  30.         cbGroup.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeGroup", True)
  31.         cbGender.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeGender", True)
  32.         cbLanguage.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeLanguage", True)
  33.         cbMaritalStatus.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeMaritalStatus", True)
  34.         txtTelHome.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeTelHome", True)
  35.         txtCellNo.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeCellNo", True)
  36.         txtTelWork.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeTelWork", True)
  37.         txtWorkExt.DataBindings.Add("text", sqlEmployeeDataTable, "employeeWorkExt", True)
  38.         txtRoomNo.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeRoomNo", True)
  39.         txtEmailAddress.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeEmailAddress", True)
  40.         txtPostalAdd1.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePostalAddress1", True)
  41.         txtPostalAdd2.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePostalAddress2", True)
  42.         txtPostalAdd3.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePostalAddress3", True)
  43.         txtPCode.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePostalCode", True)
  44.         txtID.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeIdNumber", True)
  45.         txtPassport.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePassportNumber", True)
  46.         cbNature.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeNature", True)
  47.         txtTaxNo.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeTaxNumber", True)
  48.         cbEmployeeUifCountry.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeUifCountry", True)
  49.         sqlEmployeeManager = DirectCast(Me.BindingContext(sqlEmployeeDataTable), CurrencyManager)
This will work much faster.
Feb 25 '09 #8
Alfredo73
12 New Member
Thanks, I am gonna try it and will come back to U.
Feb 25 '09 #9
OuTCasT
374 Contributor
Let me knw if it worked for you. I have alot of records in my database and this method is pretty fast.

I can show u how to navigate through the rows and to update the database with the new dataset when ur done.
Feb 25 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2162
by: Tonya | last post by:
Hi, Does anyone have any example of how i can manage forms in my application?? I want to be able to reference my form instances that are currently open from other forms. why cant i open...
4
1976
by: Jason Huang | last post by:
Hi, Thanks for help in advance! In Form1, I "New" a Form2 and ShowDialog the Form2, it's OK. My intention is passing a value from Form2 to Form1. However, in Form2, I shouldn't "New" a Form1,...
39
3010
by: jcrouse | last post by:
I am using the following code to get a background image for my form Private Sub mnuBgroundImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuBgroundImage.Clic If...
6
1988
by: bole2cant | last post by:
The error I get is: Cannot access a disposed Object named "Form2". Object name "Form2". Here is the sequence which gives the error. Start program. Form1 comes up and has a button to choose...
11
1657
by: Steve Cutting | last post by:
Hi all, Using the toolbox I added a tooltip provider to my form, and set the text for each of my buttons using the properties window. When I first show the form using .showdialog the tooltips...
37
2055
by: Geoff Jones | last post by:
Hi Suppose I have two forms: Form1 and Form2. I create and show an instance of Form2 in the code of Form1 e.g. Dim myForm2 = New Form2 myForm2.Show() How do I tell myForm2 that Form1 is...
6
1764
by: Dennis | last post by:
I have a form that I show as a Dialog but before I show it, I reset the form's location. I have the StartPostion set to Manual. If I have ControlBox set to True, all works ok but if I set the...
6
1611
by: pamelafluente | last post by:
Hi guys I am puzzed (???) with a probably stupid problem (VB2003). I must be doing something dumb ... I want to open a owned form (must *not* be mdi child) over an Mdi Container, when the Mdi...
8
2548
by: AshParr | last post by:
Hi all, I have 2 forms, "Form1" & "Form2", i have a button that currently opens form2 from form1 and then hides itself: Form2 form2 = new Form2(); form2.show; this.Visible = False; and...
0
7347
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.