Professional Documents
Culture Documents
Objectives
In this lab, students will complete the following objectives.
Lab Diagram
During your session you will have access to the following lab configuration.
Vlab-PC1
Vlab-PC2
To start simply click on the named Workstation from the device list (located on
the left hand side of the screen) and click Power on in the tools bar. In some
cases the devices may power on automatically.
During the boot up process an activity indicator will be displayed in the name
tab.
BlackPowered Of
OrangeWorking on your request
GreenReady to access
If the remote console is not displayed automatically in the main window (or
popup) click the Connect icon located in the tools bar to start your session.
COMP230_Wk 7_Database_Lab
If the remote console does not appear please try the following option.
Switch between the HTML 5 and Java client versions in the tools bar.
In the event this does not resolve your connectivity problems please visit our
Help/Support pages for additional resolution options.
COMP230_Wk 7_Database_Lab
COMP230_Wk 7_Database_Lab
Line 11 contains the SQL Query String named sqlStr. This is the line you will
have to modify to properly query the Computer database. The current SQL Query
SELECT * FROM Computers will select all fields from the database table
Computers.
Lines 12 and 13 uses a string named dataSource to specify the Microsoft
Driver and the name and location of the local database: Computers.accdb.
Line 14 Creates the ADODB.Connection object while line 15 opens the
connection to the database.
Line 16 Creates the ADODB.Recordset object while line 17 provides access to
the records using the SQL Query String and the Connection object. Line 18
moves the objRecordSet pointer to the first record.
COMP230_Wk 7_Database_Lab
Lines 2024 display the Database fieldnames as column headers. Note the
use of & to concatenate (add) string values together and _ which is the VBScript
line continuation character.
Lines 2537 are a Do Until loop that sequences through the database looking
for records that match the SQL Query String. The objRecordSet.EOF method
checks to see if we have reached the last record in the database. This is required
because reading past the end of a database will cause an error. recordStr is a
string variable initially set to . recordStr is used to create a multi-line string
that contains the column headers and records that match the SQL query. The
WScript.Echo recordStr statement in line 40 displays the column headers and
records to the console or desktop windows depending on whether cscript or
wscript is used to run the program.
Lines 38 and 39 close the database connections made by the
ADODB.Connection and ADODB.Recordset objects.
The function pad(byVal strText, ByVal len) in lines 4446 are used to format
the field values with added spaces so the tab positions will line up correctly.
COMP230_Wk 7_Database_Lab
3) Modify lines 2024 to display the correct field headers for the fields being
displayed.
4) Modify the Do Until loop body to include only the fields being displayed. Use
the pad( ) function as needed to make the header and field values line up.
5) Run your program from a command window using wscript
ComputerReplace.vbs to verify correct formatting and query results.
COMP230_Wk 7_Database_Lab
6) This query should generate eight records displayed in order by room number.
If you have any errors, do not get the correct results, or your columns are misaligned, modify your program as required until you get the correct output.
Copy and paste your ComputerReplace.vbs program sourcecode from NotePad++ and the
desktop window from your Run into the spaces provided in your lab-report document.
Answer the questions about the Replacement SQL Query in the lab-report document.
COMP230_Wk 7_Database_Lab
3) Modify lines 2024 to display the correct field headers for the fields being
displayed.
4) Modify the Do Until loop body to include only the fields being displayed. Use
the pad( ) function as needed to make the header and field values line up.
5) Run your program from a command window using wscript
ComputerUpgrade.vbs to verify correct formatting and query results.
6) This query should generate 16 records displayed in order by OS_Type. If you
have any errors, do not get the correct results, or your columns are mis-aligned;
modify your program as required until you get the correct output.
Copy and paste your ComputerUpgrade.vbs program sourcecode from NotePad++ and the
desktop window from your Run into the spaces provided in your lab-report document.
Answer the questions about the Upgrade SQL Query in the lab-report document.
COMP230_Wk 7_Database_Lab