Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame
Table of Contents
- Code Details
- Steps to install the application
This document will show you how to create a Master/Detail form in Visual Basic, those of you who have worked in Access may already have used Master/Detail form (Sub forms). Visual Basic programmers always felt handicapped by the fact that there are no Sub-Forms in Visual Basic. This document will show you how this can be achieved in Visual Basic, you will also learn how to use RDO. In the next article we will show you how to create a Master/Detail form using the relatively newer technology known as ActiveX Data Objects (ADO). Although you can use an Access database with this article, we have included the SQL script which will generate all the required tables for this articles, you need to have atleast SQL Server 6.5 in order to use the code.
2. CODE DETAILSThe detail form in this program is the grid controls. When the form first loads, the m_Resv member is assigned to CdataObjects. CdataObjects gets initialized, and the ODBC and SQL Server database connections are made. Then the FillControl procedure is called, and it processes the SQL statement. The procedure fills the cboHotel combo box with a list of the hotel names. When the FillControl procedure sets the first item in the list as the selected item, the cboHotel_Click event is performed.
The cboHotel_Click event uses the combo box's selected items as part of the where criteria of the SQL statement. This event calls the FillGrid procedure twice. Once is to fill the grdRoomInfo grid, and the other is to fill the grdResv grid.
3. STEPS TO INSTALL THE APPLICATION
- Create a database in the SQL Server, follow the steps below if you don't know how to create a database in the SQL Server:
- Open your SQL Server Enterprise Manager and click on the new device option in the left pane, create a device with the name of "Hotel" and assign 5 MB space to the device.
- Click on the new database option in the left pane and select the newly created device "Hotel", write a name for your database in the "Database name" option, you can name it as "dbHotel".
- Open your SQL query tool and run the following files one by one, these will create the tables and insert data into these tables, these files are provided with the application.
- Run the files in the sequence given below:
- Once, the database is created, create a SQL Server DSN named as "dsnmdf" and point it towards the database (dbHotel).
- Open the application in the Visual Basic and open the file "CdataObj.cls" and look for the class_initialize routine, you will find the following line in the class code:
- Save the changes and run the application by pressing F5.
'Open the connection Set m_con = m_env.OpenConnection dsName:="dsnmdf", _ Connect:="UID=sa;pwd=")
Change the DSN name to the name of the DSN you created, provide the correct User ID and password of you SQL Server in the connect string.
Contact us for any help regarding the application, our email address is: email@example.com
This application is not intended for experienced VB users, it is meant only to demonstrate the VB6 usage to the new VB programmers. This code was provided to help the new programmers catch up with the fast growing technology. This code is a public property and we completely disown this code once it is submitted to any internet site. The users are allowed to copy and paste the code in their own applications.