Hi,
I am writing an application in VB2008 with several forms. From Form1 I open a new form with me.hide() and then form2.showdialo g(). 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 2035
How have u bound ur database to the program ?
Public connectionstrin g As String = "Data Source=.\SQLEXP RESS;AttachDBFi lename=d:\datab ases\dtbs.mdf;I ntegrated Security=True;C onnect Timeout=30;User Instance=True"
Public myconnection As New SqlConnection(c onnectionstring )
Public sqlcommando As New SqlCommand() and in the sub:
sqlcommando.Con nection = myconnection
sqlcommando.Com mandText = "SELECT * FROM Accounts where AccountNr = '" + AccountNrTextBo x.Text + "'"
myconnection.Op en()
Dim myReader As SqlDataReader
myReader = sqlcommando.Exe cuteReader()
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="Wh atever", 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=myr eader("AccountN r"). 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 and close forms as easily as in VB6??
|
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, 'cuz it will open a new Form1,
the new Form1 will get the value. And the original Form1 get nothing!
What do I need to do to let the ORIGINAL Form1 get the target value?
Any help will be highly appreciated.
|
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 OpenFileDialog1.ShowDialog() = DialogResult.OK The
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName
Me.BackgroundImage = Image.FromFile(OpenFileDialog1.FileName
sr.Close(
End I
End Su
|
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 Form2.
Go to Form2. Close Form2 when done. Now back on Form1.
Click button to go back to Form2. The error/exception comes up.
I originally got this error when using Me.Close(), so I changed it to Me.Hide() and everything was fine. Except now when...
|
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 work. However
if I close and re-open the form the tooltips are no longer displayed.
Am I missing something obvious or is this a bug ??
| |
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 its parent? That is, when I look at
either "Parent" or "ParentForm" in Form2, they both show "Nothing".
|
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 form's Controlbox to
False in the Design Properties window then run my app, the bottom part of the
form doesn't show.
Why is this happening? I can reset the form's controlbox property to False
in runtime code just before I show the form and all...
|
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 container starts.
I have a small demo program made of: Form1, Form2 (empty) and a
"StartProgram" class
which contain the following code. The startup object is set to be: Sub
Main
|
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 then the same on form2 to get back to my 1st form:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |