473,785 Members | 2,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.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 ?
Feb 24 '09 #1
9 2034
OuTCasT
374 Contributor
How have u bound ur database to the program ?
Feb 24 '09 #2
Alfredo73
12 New Member
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()
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="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?)
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=myr eader("AccountN r"). 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
2192
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??
4
1992
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.
39
3057
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
6
2006
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...
11
1682
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 ??
37
2089
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".
6
1773
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...
6
1624
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
8
2557
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:
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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,...
1
10093
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8976
agi2029
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...
1
7500
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 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...
0
5381
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
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
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.