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 ?
9 2019
How have u bound ur database to the program ?
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()
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 ?
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?)
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
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.
- Dim sqlcon As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=pd;Integrated Security=True")
-
'Commands and adapter for the Employee masterfile
-
Dim sqlEmployeeCommand As SqlCommand
-
Dim sqlEmployeeAdapter As SqlDataAdapter
-
Dim sqlEmployeeDataTable As DataTable
-
'Currency Managers for Commands above
-
Dim sqlEmployeeManager As CurrencyManager
-
-
'lblPaymentPeriod.Text = strPaymentPeriod
-
sqlEmployeeCommand = New SqlCommand("SELECT * FROM EmployeeDetails order by EmployeeID", sqlcon)
-
sqlEmployeeAdapter = New SqlDataAdapter(sqlEmployeeCommand)
-
sqlEmployeeDataTable = New DataTable
-
sqlEmployeeAdapter.Fill(sqlEmployeeDataTable)
-
-
' Fill Table with EmployeeDetails
-
lblInitials1.DataBindings.Add("text", sqlEmployeeDataTable, "Employeeinitials", True)
-
lblEmployeeName1.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeSurname", True)
-
lblPaymentPeriod.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePaymentType", True)
-
' lblEmployeePreviousNormalStatus.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePreviousNormalStatus", True)
-
txtEmployeeCode.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeID", True)
-
txtSurname.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeSurname", True)
-
txtInitials.DataBindings.Add("Text", sqlEmployeeDataTable, "EmployeeInitials", True)
-
txtFirstNames.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeFirstName", True)
-
cbTitle.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeTitle", True)
-
txtNickName.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeNickName", True)
-
txtPhysAddress1.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePhysicalAddress1", True)
-
txtPhysAddress2.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePhysicalAddress2", True)
-
txtPhysAddress3.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePhysicalAddress3", True)
-
txtPhysPCode.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePhysicalPostalCode", True)
-
cbGroup.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeGroup", True)
-
cbGender.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeGender", True)
-
cbLanguage.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeLanguage", True)
-
cbMaritalStatus.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeMaritalStatus", True)
-
txtTelHome.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeTelHome", True)
-
txtCellNo.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeCellNo", True)
-
txtTelWork.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeTelWork", True)
-
txtWorkExt.DataBindings.Add("text", sqlEmployeeDataTable, "employeeWorkExt", True)
-
txtRoomNo.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeRoomNo", True)
-
txtEmailAddress.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeEmailAddress", True)
-
txtPostalAdd1.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePostalAddress1", True)
-
txtPostalAdd2.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePostalAddress2", True)
-
txtPostalAdd3.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePostalAddress3", True)
-
txtPCode.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePostalCode", True)
-
txtID.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeIdNumber", True)
-
txtPassport.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeePassportNumber", True)
-
cbNature.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeNature", True)
-
txtTaxNo.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeTaxNumber", True)
-
cbEmployeeUifCountry.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeUifCountry", True)
-
sqlEmployeeManager = DirectCast(Me.BindingContext(sqlEmployeeDataTable), CurrencyManager)
This will work much faster.
Thanks, I am gonna try it and will come back to U.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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,...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |