diff --git a/2542.pdf b/2542.pdf
new file mode 100644
index 0000000..e65d4fc
Binary files /dev/null and b/2542.pdf differ
diff --git a/2543.pdf b/2543.pdf
new file mode 100644
index 0000000..e06cb03
Binary files /dev/null and b/2543.pdf differ
diff --git a/2551.pdf b/2551.pdf
new file mode 100644
index 0000000..d584f97
Binary files /dev/null and b/2551.pdf differ
diff --git a/9781590595237.jpg b/9781590595237.jpg
new file mode 100644
index 0000000..eda27c1
Binary files /dev/null and b/9781590595237.jpg differ
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..2a1eac9
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,27 @@
+Freeware License, some rights reserved
+
+Copyright (c) 2006 Rick Dobson
+
+Permission is hereby granted, free of charge, to anyone obtaining a copy
+of this software and associated documentation files (the "Software"),
+to work with the Software within the limits of freeware distribution and fair use.
+This includes the rights to use, copy, and modify the Software for personal use.
+Users are also allowed and encouraged to submit corrections and modifications
+to the Software for the benefit of other users.
+
+It is not allowed to reuse, modify, or redistribute the Software for
+commercial use in any way, or for a user’s educational materials such as books
+or blog articles without prior permission from the copyright holder.
+
+The above copyright notice and this permission notice need to be included
+in all copies or substantial portions of the software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8b883e9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,15 @@
+#Apress Source Code
+
+This repository accompanies [*Beginning SQL Server 2005 Express Database Applications with Visual Basic Express and Visual Web Developer Express*](http://www.apress.com/9781590595237) by Rick Dobson (Apress, 2006).
+
+![Cover image](9781590595237.jpg)
+
+Download the files as a zip using the green button, or clone the repository to your machine using Git.
+
+##Releases
+
+Release v1.0 corresponds to the code in the published book, without corrections or updates.
+
+##Contributions
+
+See the file Contributing.md for more information on how you can contribute to this repository.
diff --git a/SamplesForChapter02/Chapter02/ListColumnValues.bat b/SamplesForChapter02/Chapter02/ListColumnValues.bat
new file mode 100644
index 0000000..58e6d64
--- /dev/null
+++ b/SamplesForChapter02/Chapter02/ListColumnValues.bat
@@ -0,0 +1 @@
+sqlcmd -S .\sqlexpress -v DBName = "Northwind" CName = "CompanyName" TName = "Shippers" -i c:\prosseapps\chapter02\ListColumnValues.sql -o c:\prosseapps\chapter02\ColumnValuesOut.rpt
\ No newline at end of file
diff --git a/SamplesForChapter02/Chapter02/ListColumnValues.sql b/SamplesForChapter02/Chapter02/ListColumnValues.sql
new file mode 100644
index 0000000..b2b040d
--- /dev/null
+++ b/SamplesForChapter02/Chapter02/ListColumnValues.sql
@@ -0,0 +1,4 @@
+USE $(DBName)
+GO
+SELECT $(CName) FROM $(TName)
+GO
\ No newline at end of file
diff --git a/SamplesForChapter02/Chapter02/ListColumnValues2.bat b/SamplesForChapter02/Chapter02/ListColumnValues2.bat
new file mode 100644
index 0000000..c2e23c3
--- /dev/null
+++ b/SamplesForChapter02/Chapter02/ListColumnValues2.bat
@@ -0,0 +1,2 @@
+sqlcmd -S .\sqlexpress -v DBName = "Northwind" CName = "CompanyName" TName = "Shippers" -i c:\prosseapps\chapter02\ListColumnValues.sql -o c:\prosseapps\chapter02\ColumnValuesOut.rpt
+sqlcmd -S .\sqlexpress -v DBName = "Northwind" CName = "CompanyName" TName = "Customers" -i c:\prosseapps\chapter02\ListColumnValues.sql >> c:\prosseapps\chapter02\ColumnValuesOut.rpt
\ No newline at end of file
diff --git a/SamplesForChapter02/Chapter02/SQLQuery1_f0218.sql b/SamplesForChapter02/Chapter02/SQLQuery1_f0218.sql
new file mode 100644
index 0000000..bea5dd3
--- /dev/null
+++ b/SamplesForChapter02/Chapter02/SQLQuery1_f0218.sql
@@ -0,0 +1,4 @@
+USE AdventureWorks
+SELECT TOP 3 SalesPersonID, SalesYTD, SalesLastYear
+FROM Sales.SalesPerson
+ORDER BY SalesYTD DESC
\ No newline at end of file
diff --git a/SamplesForChapter02/Chapter02/SQLQuery1_f0220.sql b/SamplesForChapter02/Chapter02/SQLQuery1_f0220.sql
new file mode 100644
index 0000000..844c867
--- /dev/null
+++ b/SamplesForChapter02/Chapter02/SQLQuery1_f0220.sql
@@ -0,0 +1,16 @@
+USE ProSSEApps
+
+--Original copied T-SQL FROM vContactName
+SELECT TOP (100) PERCENT dbo.Customer.CustomerName, dbo.CustomerContact.ContactName, dbo.CustomerContact.EmailAddr
+FROM dbo.Customer INNER JOIN
+ dbo.CustomerContact ON dbo.Customer.CustomerID = dbo.CustomerContact.CustomerID
+WHERE (PATINDEX('%Church%', dbo.Customer.CustomerName) > 0)
+ORDER BY dbo.CustomerContact.ContactName DESC
+
+--Edited and re-formatted T-SQL FROM vContactName
+SELECT TOP (100) PERCENT dbo.Customer.CustomerName,
+ dbo.CustomerContact.ContactName, dbo.CustomerContact.EmailAddr
+FROM dbo.Customer INNER JOIN dbo.CustomerContact
+ ON dbo.Customer.CustomerID = dbo.CustomerContact.CustomerID
+WHERE (PATINDEX('%Church%', dbo.Customer.CustomerName) = 0)
+ORDER BY dbo.CustomerContact.ContactName DESC
\ No newline at end of file
diff --git a/SamplesForChapter02/Chapter02/SQLQuery1_f0222.sql b/SamplesForChapter02/Chapter02/SQLQuery1_f0222.sql
new file mode 100644
index 0000000..c950cd6
Binary files /dev/null and b/SamplesForChapter02/Chapter02/SQLQuery1_f0222.sql differ
diff --git a/SamplesForChapter02/Chapter02/SQLQuery2_f0219.sql b/SamplesForChapter02/Chapter02/SQLQuery2_f0219.sql
new file mode 100644
index 0000000..661cc07
--- /dev/null
+++ b/SamplesForChapter02/Chapter02/SQLQuery2_f0219.sql
@@ -0,0 +1,7 @@
+USE AdventureWorks
+
+SELECT COUNT(SalesPersonID) AS 'Sales person'
+FROM Sales.SalesPerson
+
+SELECT COUNT(EmployeeID) AS 'Employees'
+FROM HumanResources.Employee
\ No newline at end of file
diff --git a/SamplesForChapter02/Chapter02/saved_data.txt b/SamplesForChapter02/Chapter02/saved_data.txt
new file mode 100644
index 0000000..726b07a
--- /dev/null
+++ b/SamplesForChapter02/Chapter02/saved_data.txt
@@ -0,0 +1,11 @@
+Changed database context to 'AdventureWorks'.
+Sales person
+------------
+ 17
+
+(1 rows affected)
+Employees
+-----------
+ 290
+
+(1 rows affected)
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/CopyDB_1aFiles.bat b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/CopyDB_1aFiles.bat
new file mode 100644
index 0000000..83ed990
--- /dev/null
+++ b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/CopyDB_1aFiles.bat
@@ -0,0 +1,10 @@
+REM Erase old database and log files
+cd c:\prosseapps\chapter03\
+ERASE Database_1a*.*
+
+REM Copy new database and log files to new folder
+REM and to .bak files in the same folder
+cd c:\program files\microsoft sql server\mssql.1\mssql\data\
+copy Database_1a*.* c:\prosseapps\chapter03\
+copy Database_1a.mdf Database_1a.bak
+copy Database_1a_log.ldf Database_1a_log.bak
\ No newline at end of file
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/Database_SP.mdf b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/Database_SP.mdf
new file mode 100644
index 0000000..214b344
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/Database_SP.mdf differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/Database_SP_log.ldf b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/Database_SP_log.ldf
new file mode 100644
index 0000000..29966d2
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/Database_SP_log.ldf differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB.mdf b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB.mdf
new file mode 100644
index 0000000..918e777
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB.mdf differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB1.mdf b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB1.mdf
new file mode 100644
index 0000000..efb1ca3
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB1.mdf differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB1_log.LDF b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB1_log.LDF
new file mode 100644
index 0000000..ed32617
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB1_log.LDF differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB2.mdf b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB2.mdf
new file mode 100644
index 0000000..937e915
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB2.mdf differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB2_log.LDF b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB2_log.LDF
new file mode 100644
index 0000000..4e9f384
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB2_log.LDF differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB3.mdf b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB3.mdf
new file mode 100644
index 0000000..b9dc3f6
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB3.mdf differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB3_log.LDF b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB3_log.LDF
new file mode 100644
index 0000000..08e6f1f
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB3_log.LDF differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB_log.LDF b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB_log.LDF
new file mode 100644
index 0000000..fce24bb
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/NewDB_log.LDF differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/ProSSEAppsCh04.mdf b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/ProSSEAppsCh04.mdf
new file mode 100644
index 0000000..c83da73
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/ProSSEAppsCh04.mdf differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/ProSSEAppsCh04_log.LDF b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/ProSSEAppsCh04_log.LDF
new file mode 100644
index 0000000..bf205fe
Binary files /dev/null and b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/ProSSEAppsCh04_log.LDF differ
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/RecoverDB_1aFiles.bat b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/RecoverDB_1aFiles.bat
new file mode 100644
index 0000000..740bea1
--- /dev/null
+++ b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/RecoverDB_1aFiles.bat
@@ -0,0 +1,4 @@
+REM Rename backup files as database and log files
+cd c:\program files\microsoft sql server\mssql.1\mssql\data\
+rename Database_1a.bak Database_1a.mdf
+rename Database_1a_log.bak Database_1a_log.ldf
\ No newline at end of file
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery1_f0301.sql b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery1_f0301.sql
new file mode 100644
index 0000000..919212d
--- /dev/null
+++ b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery1_f0301.sql
@@ -0,0 +1,4 @@
+USE master
+GO
+
+EXEC sp_helpdb
\ No newline at end of file
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery1_f0302.sql b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery1_f0302.sql
new file mode 100644
index 0000000..10acfa2
--- /dev/null
+++ b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery1_f0302.sql
@@ -0,0 +1,4 @@
+USE master
+GO
+
+EXEC sp_helpdb @dbname = 'Northwind'
\ No newline at end of file
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery2_f0303_f0304.sql b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery2_f0303_f0304.sql
new file mode 100644
index 0000000..51024c0
--- /dev/null
+++ b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery2_f0303_f0304.sql
@@ -0,0 +1,54 @@
+--List database names and is_auto_close_on values
+--on server instance
+USE master
+GO
+
+SELECT name, is_auto_close_on
+FROM sys.databases
+
+--Modify and restore autoclode database-level option
+--for the Northwind database
+USE master
+SELECT name, is_auto_close_on
+FROM sys.databases
+WHERE name = 'Northwind'
+GO
+sp_dboption 'Northwind', 'autoclose', 'FALSE'
+GO
+SELECT name, is_auto_close_on
+FROM sys.databases
+WHERE name = 'Northwind'
+GO
+sp_dboption 'Northwind', 'autoclose', 'True'
+GO
+SELECT name, is_auto_close_on
+FROM sys.databases
+WHERE name = 'Northwind'
+GO
+
+
+--List name and object_id from the sys.tables view for
+--@TBLName and matching name, column_id, and object_id
+--from the sys.columns view
+USE master
+GO
+
+DECLARE @DBName nvarchar(128)
+DECLARE @TBLName nvarchar(128)
+SET @DBName = N'Northwind'
+SET @TBLName = N'Shippers'
+
+SELECT name
+FROM sys.databases
+WHERE name = @DBName
+USE Northwind
+SELECT name, object_id
+FROM sys.tables
+WHERE name = @TBLName
+SELECT name, column_id, object_id
+FROM sys.columns
+WHERE object_id IN
+ (SELECT object_id
+ FROM sys.tables
+ WHERE name = @TBLName)
+
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery4_f0306_f0307_f0308.sql b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery4_f0306_f0307_f0308.sql
new file mode 100644
index 0000000..d00f8ed
--- /dev/null
+++ b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery4_f0306_f0307_f0308.sql
@@ -0,0 +1,35 @@
+--Just specify database name
+EXEC sp_helpdb model
+CREATE DATABASE Database_2
+EXEC sp_helpdb Database_2
+DROP DATABASE Database_2
+
+--Specify database name and primary
+--database file specification
+CREATE DATABASE Database_2
+ON
+(NAME = Database_2_dat,
+ FILENAME = 'c:\prosseapps\chapter03\database_2.mdf',
+ SIZE = 2MB,
+ MAXSIZE = 20,
+ FILEGROWTH = 10%)
+EXEC sp_helpdb Database_2
+DROP DATABASE Database_2
+
+--Specify database and log file specifications
+CREATE DATABASE Database_2
+ON PRIMARY
+(NAME = Database_2_dat,
+ FILENAME = 'c:\prosseapps\chapter03\database_2dat.mdf',
+ SIZE = 2MB,
+ MAXSIZE = 20,
+ FILEGROWTH = 10%)
+LOG ON
+(NAME = Database_2_log,
+ FILENAME = 'c:\prosseapps\chapter03\database_2log.ldf',
+ SIZE = 4MB,
+ MAXSIZE = 10MB,
+ FILEGROWTH = 20%)
+EXEC sp_helpdb Database_2
+DROP DATABASE Database_2
+
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery5_f0310_f0311.sql b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery5_f0310_f0311.sql
new file mode 100644
index 0000000..961cde6
--- /dev/null
+++ b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery5_f0310_f0311.sql
@@ -0,0 +1,48 @@
+--Copy database and log files for Database_1a from
+--c:\program files\microsoft sql server\mssql.1\mssql\data\
+--to c:\prosseapps\chapter03\ and make .bak files for .mdf and .ldf
+--in c:\program files\microsoft sql server\mssql.1\mssql\data\
+xp_cmdshell 'c:\prosseapps\chapter03\copydb_1afiles'
+GO
+--Look at databaes before adding a new one
+--Notice paths for database and log files of
+--Database_1a
+SELECT name, database_id FROM sys.databases
+EXEC sp_helpdb @dbname = N'Database_1a'
+GO
+--Create a new database (Database_1b) based on the
+--copied database and log files from Database_1a,
+--which was created originally as Database_1
+CREATE DATABASE Database_1b
+ON PRIMARY (FILENAME = 'c:\prosseapps\chapter03\Database_1a.mdf')
+FOR ATTACH
+GO
+--See what happened after CREATE DATABASE...FOR ATTACH
+SELECT name, database_id FROM sys.databases
+EXEC sp_helpdb @dbname = N'Database_1b'
+GO
+--Drop Database_1b and delete unused log file
+DROP DATABASE Database_1b
+GO
+xp_cmdshell 'erase c:\prosseapps\chapter03\Database_1a_log.ldf'
+GO
+
+--See what happened to Database_1a after
+--dropping Database_1b
+EXEC sp_helpdb @dbname = N'Database_1a'
+
+--Now drop Database_1a and rename .bak files
+DROP DATABASE Database_1a
+GO
+xp_cmdshell 'c:\prosseapps\chapter03\recoverdb_1afiles'
+GO
+--Re-create Database_1a
+CREATE DATABASE Database_1a
+ON (FILENAME =
+'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Database_1a.mdf')
+FOR ATTACH
+GO
+SELECT name, database_id FROM sys.databases
+EXEC sp_helpdb @dbname = N'Database_1a'
+GO
+
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery6_f0312.sql b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery6_f0312.sql
new file mode 100644
index 0000000..eb47a1b
--- /dev/null
+++ b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery6_f0312.sql
@@ -0,0 +1,28 @@
+--repeat with FOR ATTACH sample with references to both
+--database and log files
+
+--Copy files
+xp_cmdshell 'c:\prosseapps\chapter03\copydb_1afiles'
+GO
+
+--Attach copied files
+CREATE DATABASE Database_1b
+ON PRIMARY (FILENAME = 'c:\prosseapps\chapter03\Database_1a.mdf')
+LOG ON (FILENAME = 'c:\prosseapps\chapter03\Database_1a_log.ldf')
+FOR ATTACH
+GO
+
+--Monitor results
+SELECT name, database_id FROM sys.databases
+EXEC sp_helpdb @dbname = N'Database_1b'
+GO
+
+--Clean up
+DROP DATABASE Database_1b
+GO
+xp_cmdshell 'erase "c:\program files\microsoft sql server\mssql.1\mssql\data\Database_1a*.bak"'
+GO
+EXEC sp_helpdb @dbname = N'Database_1a'
+GO
+
+
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery7_f0313_f0314_f0315.sql b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery7_f0313_f0314_f0315.sql
new file mode 100644
index 0000000..639913f
--- /dev/null
+++ b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery7_f0313_f0314_f0315.sql
@@ -0,0 +1,63 @@
+--Create Database_2
+CREATE DATABASE Database_2
+ON PRIMARY
+(NAME = Database_2_dat,
+ FILENAME = 'c:\prosseapps\chapter03\database_2dat.mdf',
+ SIZE = 2MB,
+ MAXSIZE = 20,
+ FILEGROWTH = 10%)
+LOG ON
+(NAME = Database_2_log,
+ FILENAME = 'c:\prosseapps\chapter03\database_2log.ldf',
+ SIZE = 4MB,
+ MAXSIZE = 10MB,
+ FILEGROWTH = 20%)
+GO
+
+--Show database's autoclose setting; copy one database
+--file; then erase copy
+SELECT name, database_id, is_auto_close_on
+FROM sys.databases WHERE name = 'Database_2'
+DECLARE @str1 nvarchar(90)
+SET @str1 = 'copy c:\prosseapps\chapter03\database_2dat.mdf ' +
+ 'c:\prosseapps\chapter03\database_2dat.bak'
+EXEC master..xp_cmdshell @str1
+SET @str1 = 'erase ' +
+ 'c:\prosseapps\chapter03\database_2dat.bak'
+EXEC master..xp_cmdshell @str1
+GO
+
+
+--Detach database; then attach
+EXEC sp_detach_db @dbname = N'Database_2'
+GO
+--Show database is gone, but its files remain
+SELECT name
+FROM sys.databases WHERE name = 'Database_2'
+DECLARE @str1 nvarchar(90)
+SET @str1 = 'dir ' +
+ 'c:\prosseapps\chapter03\database_2*.*'
+EXEC master..xp_cmdshell @str1
+GO
+
+--Create a new Database_2 by attaching files
+CREATE DATABASE Database_2
+ON PRIMARY (FILENAME = 'c:\prosseapps\chapter03\Database_2dat.mdf')
+LOG ON (FILENAME = 'c:\prosseapps\chapter03\Database_2log.ldf')
+FOR ATTACH
+GO
+
+--Show database's autoclose setting
+SELECT name, database_id, is_auto_close_on
+FROM sys.databases WHERE name = 'Database_2'
+GO
+
+--With a database created via FOR ATTACH clause copy does not work
+DECLARE @str1 nvarchar(90)
+SET @str1 = 'copy c:\prosseapps\chapter03\database_2dat.mdf ' +
+ 'c:\prosseapps\chapter03\database_2dat.bak'
+EXEC master..xp_cmdshell @str1
+GO
+
+--Clean up
+DROP DATABASE Database_2
\ No newline at end of file
diff --git a/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery8_f0316_f0317.sql b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery8_f0316_f0317.sql
new file mode 100644
index 0000000..ca07e47
--- /dev/null
+++ b/SamplesForChapter03/Chapter03/RevisedScriptsFigures/SQLQuery8_f0316_f0317.sql
@@ -0,0 +1,147 @@
+--Copy original Northwind files for
+--NWCopy database
+DECLARE @str1 nvarchar(128)
+SET @str1 = 'copy "c:\Program Files\Microsoft SQL Server\' +
+ 'MSSQL.1\MSSQL\DATA\northwnd.mdf" ' +
+ 'c:\prosseapps\chapter03'
+EXEC master..xp_cmdshell @str1
+SET @str1 = 'copy "c:\Program Files\Microsoft SQL Server\' +
+ 'MSSQL.1\MSSQL\DATA\northwnd.ldf" ' +
+ 'c:\prosseapps\chapter03'
+EXEC master..xp_cmdshell @str1
+
+--Create NWCopy from copied Northwind files
+CREATE DATABASE NWCopy
+ON PRIMARY (FILENAME = 'c:\prosseapps\chapter03\northwnd.mdf')
+LOG ON (FILENAME = 'c:\prosseapps\chapter03\northwnd.ldf')
+FOR ATTACH
+GO
+
+--Verify NWCopy database by checking its files
+--and performing a SELECT statement from Shippers
+EXEC sp_helpdb NWCopy
+SELECT * FROM NWCopy..Shippers
+
+--Show recovery model property settings for databases
+SELECT name, recovery_model, recovery_model_desc
+FROM sys.databases
+
+--Change recovery model for NWCopy TO full
+ALTER DATABASE NWCopy
+SET RECOVERY full
+GO
+
+--Verify change
+SELECT name, recovery_model, recovery_model_desc
+FROM sys.databases
+WHERE name = 'NWCopy'
+
+--Change recovery model for NWCopy TO simple
+ALTER DATABASE NWCopy
+SET RECOVERY simple
+GO
+
+--Verify change
+SELECT name, recovery_model, recovery_model_desc
+FROM sys.databases
+WHERE name = 'NWCopy'
+GO
+
+--Full data backup and restore sample
+USE master
+EXEC sp_addumpdevice 'disk', NWCopyBK_1,
+ 'c:\prosseapps\chapter03\NWCopyBK_1.bak'
+BACKUP DATABASE NWCopy TO NWCopyBK_1
+GO
+
+SELECT * FROM NWCopy..Shippers
+GO
+WAITFOR DELAY '00:00:01'
+GO
+xp_cmdshell 'erase c:\prosseapps\chapter03\northwnd.mdf'
+GO
+
+RESTORE DATABASE NWCopy FROM NWCopyBK_1
+GO
+SELECT * FROM NWCopy..Shippers
+GO
+
+--Differential backup and restore code samples
+BACKUP DATABASE NWCopy
+TO NWCopyBK_1
+WITH INIT
+GO
+
+INSERT INTO NWCopy..Shippers
+ (CompanyName, Phone)
+ VALUES ('CAB, Inc.', '(123) 456-7890')
+GO
+
+BACKUP DATABASE NWCopy
+TO NWCopyBK_1
+WITH DIFFERENTIAL
+GO
+
+INSERT INTO NWCopy..Shippers
+ (CompanyName, Phone)
+ VALUES ('CAB Does It', '(456) -789-0123')
+GO
+
+BACKUP DATABASE NWCopy
+TO NWCopyBK_1
+WITH DIFFERENTIAL
+GO
+
+
+RESTORE DATABASE NWCopy
+FROM NWCopyBK_1
+WITH NORECOVERY
+GO
+
+RESTORE DATABASE NWCopy
+FROM NWCopyBK_1
+WITH FILE = 2, RECOVERY
+GO
+
+SELECT * FROM NWCopy..Shippers
+GO
+
+
+RESTORE DATABASE NWCopy
+FROM NWCopyBK_1
+WITH NORECOVERY
+GO
+
+RESTORE DATABASE NWCopy
+FROM NWCopyBK_1
+WITH FILE = 3, RECOVERY
+GO
+
+SELECT * FROM NWCopy..Shippers
+GO
+
+xp_cmdshell 'erase c:\prosseapps\chapter03\northwnd.mdf'
+GO
+
+RESTORE DATABASE NWCopy
+FROM NWCopyBK_1
+WITH NORECOVERY
+GO
+
+RESTORE DATABASE NWCopy
+FROM NWCopyBK_1
+WITH FILE = 2, RECOVERY
+GO
+
+SELECT * FROM NWCopy..Shippers
+GO
+
+--Clean up
+DROP DATABASE NWCopy
+GO
+EXEC sp_dropdevice @logicalname = 'NWCopyBK_1'
+GO
+xp_cmdshell 'erase c:\prosseapps\chapter03\NWCopyBK_1.bak'
+GO
+
+
diff --git a/SamplesForChapter04/Chapter04/Ch04CheckPKStudentGrades.sql b/SamplesForChapter04/Chapter04/Ch04CheckPKStudentGrades.sql
new file mode 100644
index 0000000..ae24a2b
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04CheckPKStudentGrades.sql
@@ -0,0 +1,29 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'ClassGrades')
+ DROP TABLE ClassGrades
+GO
+
+
+CREATE TABLE ClassGrades(
+ ClassID int,
+ StudentID int,
+ GradeLetter varchar(2),
+ Constraint PK_ClassGrades
+ PRIMARY KEY(ClassID, StudentID),
+ Constraint CK_GradeRange_ClassID
+ CHECK (LEFT(UPPER(GradeLetter),1)
+ LIKE '[A-F]' AND ClassID < 1000)
+)
+GO
+
+INSERT ClassGrades VALUES(1, 1, 'C+')
+INSERT ClassGrades VALUES(1, 2, 'A+')
+INSERT ClassGrades VALUES(1, 3, 'V-')
+INSERT ClassGrades VALUES(1001, 1, 'A')
+INSERT ClassGrades VALUES(999, 2, 'A')
+GO
+
+SELECT * FROM ClassGrades
diff --git a/SamplesForChapter04/Chapter04/Ch04CheckTooShort.sql b/SamplesForChapter04/Chapter04/Ch04CheckTooShort.sql
new file mode 100644
index 0000000..a5f9b82
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04CheckTooShort.sql
@@ -0,0 +1,26 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ int1 int IDENTITY PRIMARY KEY,
+ vch1 varchar(5)
+ CHECK (LEN(vch1) > 0),
+ vch2 varchar(5)
+ CONSTRAINT CK_LEN_TOO_SHORT
+ CHECK (LEN(vch2) > 0)
+)
+GO
+
+INSERT T (vch1, vch2) VALUES('a','b')
+INSERT T (vch1, vch2) VALUES('','b')
+INSERT T (vch1, vch2) VALUES('a','')
+INSERT T DEFAULT VALUES
+GO
+
+SELECT * FROM T
+
diff --git a/SamplesForChapter04/Chapter04/Ch04CheckTooShortNotNull.sql b/SamplesForChapter04/Chapter04/Ch04CheckTooShortNotNull.sql
new file mode 100644
index 0000000..8051777
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04CheckTooShortNotNull.sql
@@ -0,0 +1,28 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ int1 int IDENTITY PRIMARY KEY,
+ vch1 varchar(5)
+ CHECK (LEN(vch1) > 0)
+ NOT NULL,
+ vch2 varchar(5)
+ CONSTRAINT CK_LEN_TOO_SHORT
+ CHECK (LEN(vch2) > 0)
+ NOT NULL
+)
+GO
+
+INSERT T (vch1, vch2) VALUES('a','b')
+INSERT T (vch1, vch2) VALUES('','b')
+INSERT T (vch1, vch2) VALUES('a','')
+INSERT T DEFAULT VALUES
+GO
+
+SELECT * FROM T
+
diff --git a/SamplesForChapter04/Chapter04/Ch04CheckZipPattern.sql b/SamplesForChapter04/Chapter04/Ch04CheckZipPattern.sql
new file mode 100644
index 0000000..683b0a2
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04CheckZipPattern.sql
@@ -0,0 +1,26 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ int1 int IDENTITY PRIMARY KEY,
+ psc1 varchar(5)
+ CHECK (LEN(psc1) = 5 AND
+ psc1 LIKE
+ '[0-9][0-9][0-9][0-9][0-9]')
+ NOT NULL
+)
+GO
+
+INSERT T (psc1) VALUES('40222')
+INSERT T (psc1) VALUES('4022')
+INSERT T (psc1) VALUES('r0222')
+INSERT T DEFAULT VALUES
+GO
+
+SELECT * FROM T
+GO
diff --git a/SamplesForChapter04/Chapter04/Ch04CreateRecover.sql b/SamplesForChapter04/Chapter04/Ch04CreateRecover.sql
new file mode 100644
index 0000000..d85256e
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04CreateRecover.sql
@@ -0,0 +1,22 @@
+USE ProSSEAppsCh04
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ BEGIN
+ PRINT 'T already.'
+ DROP TABLE T_old
+ EXEC sp_rename 'T', 'T_old'
+ END
+ELSE PRINT 'No T already.'
+
+CREATE TABLE T (
+ c1 bigint,
+ c2 nvarchar(max)
+)
+
+
+INSERT T
+SELECT * FROM T_old
+
+SELECT c1, RIGHT(C2,2) 'Right 2 of c2' FROM T
+
diff --git a/SamplesForChapter04/Chapter04/Ch04Decimal.sql b/SamplesForChapter04/Chapter04/Ch04Decimal.sql
new file mode 100644
index 0000000..8d857b1
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04Decimal.sql
@@ -0,0 +1,8 @@
+SET NOCOUNT ON
+DECLARE @dec1 decimal(38,0)
+SET @dec1 = CAST(POWER(10,9) as decimal(38,0))
+SELECT @dec1 * @dec1 * @dec1 * @dec1 * 10 AS 'Large Decimal value',
+ FLOOR(LOG10(@dec1 * @dec1 * @dec1 * @dec1 * 10)
+ + 1) AS 'Number of digits'
+
+
diff --git a/SamplesForChapter04/Chapter04/Ch04FKClassesClassGrades.sql b/SamplesForChapter04/Chapter04/Ch04FKClassesClassGrades.sql
new file mode 100644
index 0000000..5d4803b
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04FKClassesClassGrades.sql
@@ -0,0 +1,101 @@
+USE ProSSEAppsCh04
+GO
+
+--Must drop referencing table before
+--the referenced table
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'ClassGrades')
+ DROP TABLE ClassGrades
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'Classes')
+ DROP TABLE Classes
+GO
+
+CREATE TABLE Classes(
+ ClassID int Primary Key,
+ ClassTitle varchar(50)
+)
+GO
+
+CREATE TABLE ClassGrades(
+ ClassID int REFERENCES Classes(ClassID)
+ ON UPDATE CASCADE,
+ StudentID int,
+ GradeLetter varchar(2),
+ Constraint PK_ClassGrades
+ PRIMARY KEY(ClassID, StudentID)
+)
+GO
+
+--Must insert Classes before attempting
+--to insert class grades
+INSERT Classes VALUES(1,
+ 'Learning SQL Server Express')
+INSERT Classes VALUES(999,
+ 'Biographies of Jesus Christ')
+GO
+
+INSERT ClassGrades VALUES(1, 1, 'C+')
+INSERT ClassGrades VALUES(1, 2, 'A+')
+INSERT ClassGrades VALUES(999, 2, 'A')
+GO
+
+--INSERT fails because ClassID 998
+--does not exist in Classes
+INSERT ClassGrades VALUES(998, 1, 'B')
+GO
+
+--Change of ClassTitle works
+SELECT CG.StudentID, C.ClassTitle, CG.GradeLetter
+FROM Classes C, ClassGrades CG
+WHERE C.ClassID = CG.ClassID
+GO
+
+UPDATE Classes
+SET ClassTitle = 'The Life of Jesus Christ'
+WHERE ClassID = 999
+GO
+
+SELECT CG.StudentID, C.ClassTitle, CG.GradeLetter
+FROM Classes C, ClassGrades CG
+WHERE C.ClassID = CG.ClassID
+GO
+
+--Change to ClassID works too
+SELECT * FROM Classes
+GO
+
+UPDATE Classes
+SET ClassID = 998
+WHERE ClassID = 999
+GO
+
+SELECT * FROM Classes
+GO
+
+SELECT CG.StudentID, C.ClassTitle, CG.GradeLetter
+FROM Classes C, ClassGrades CG
+WHERE C.ClassID = CG.ClassID
+GO
+
+
+--Update succeeds because of ON UPDATE
+--setting but DELETE fails because of
+--no ON DELETE setting
+UPDATE Classes
+SET ClassID = 999
+WHERE ClassID = 998
+GO
+
+DELETE
+FROM Classes
+WHERE ClassID = 999
+GO
+
+UPDATE Classes
+SET ClassID = 998
+WHERE ClassID = 999
+GO
+
diff --git a/SamplesForChapter04/Chapter04/Ch04FKMany-to-many.sql b/SamplesForChapter04/Chapter04/Ch04FKMany-to-many.sql
new file mode 100644
index 0000000..410b9c5
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04FKMany-to-many.sql
@@ -0,0 +1,105 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'ClassGrades')
+ DROP TABLE ClassGrades
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'Students')
+ DROP TABLE Students
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'Classes')
+ DROP TABLE Classes
+GO
+
+CREATE TABLE Students(
+ StudentID int Primary Key,
+ FirstName nvarchar(30),
+ LastName nvarchar(50),
+ FullName AS (FirstName + ' ' + LastName)
+)
+GO
+
+CREATE TABLE Classes(
+ ClassID int Primary Key,
+ ClassTitle varchar(50)
+)
+GO
+
+CREATE TABLE ClassGrades(
+ ClassID int,
+ StudentID int,
+ GradeLetter varchar(2),
+ Constraint PK_ClassGrades
+ PRIMARY KEY(ClassID, StudentID),
+ Constraint FK_Classes_ClassID
+ FOREIGN KEY(ClassID)
+ REFERENCES Classes(ClassID) ON UPDATE CASCADE,
+ Constraint FK_Students_StudentID
+ FOREIGN KEY(StudentID)
+ REFERENCES Students(StudentID) ON UPDATE CASCADE
+)
+GO
+
+
+--Insert classes rows
+INSERT Classes VALUES(1,
+ 'Learning SQL Server Express')
+INSERT Classes VALUES(999,
+ 'Biographies of Jesus Christ')
+GO
+
+--Insert Students rows
+INSERT Students VALUES(1, 'Poor', 'DBA')
+INSERT Students VALUES(2, 'Better', 'DBA')
+GO
+
+--Insert ClassGrades rows
+INSERT ClassGrades VALUES(1, 1, 'C+')
+INSERT ClassGrades VALUES(1, 2, 'A+')
+INSERT ClassGrades VALUES(999, 2, 'A')
+GO
+
+--Show table values after initial population
+SELECT S.FullName, C.ClassTitle, CG.GradeLetter
+FROM Classes C, ClassGrades CG, Students S
+WHERE C.ClassID = CG.ClassID AND
+ S.StudentID = CG.StudentID
+GO
+
+--Update ClassID and ClassTitle
+SELECT * FROM Classes
+GO
+
+UPDATE Classes
+SET ClassID = 998,
+ ClassTitle = 'The Life of Jesus Christ'
+WHERE ClassID = 999
+GO
+
+SELECT * FROM Classes
+GO
+
+SELECT S.FullName, C.ClassTitle, CG.GradeLetter
+FROM Classes C, ClassGrades CG, Students S
+WHERE C.ClassID = CG.ClassID AND
+ S.StudentID = CG.StudentID
+GO
+
+--Update LastName of student
+UPDATE Students
+SET LastName = 'DBA-Minister'
+WHERE StudentID = 2
+GO
+
+SELECT S.FullName, C.ClassTitle, CG.GradeLetter
+FROM Classes C, ClassGrades CG, Students S
+WHERE C.ClassID = CG.ClassID AND
+ S.StudentID = CG.StudentID
+GO
+
+
diff --git a/SamplesForChapter04/Chapter04/Ch04Float.sql b/SamplesForChapter04/Chapter04/Ch04Float.sql
new file mode 100644
index 0000000..3bcdb14
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04Float.sql
@@ -0,0 +1,6 @@
+SET NOCOUNT ON
+DECLARE @float1 float
+SET @float1 = CAST(POWER(10,9) as float)
+SELECT @float1 * @float1 * @float1 * @float1 * 100 AS 'Large Float value',
+ FLOOR(LOG10(@float1 * @float1 * @float1 * @float1 * 100)
+ + 1) AS 'Number of digits'
diff --git a/SamplesForChapter04/Chapter04/Ch04FloatDecimal.sql b/SamplesForChapter04/Chapter04/Ch04FloatDecimal.sql
new file mode 100644
index 0000000..2e0a8f6
Binary files /dev/null and b/SamplesForChapter04/Chapter04/Ch04FloatDecimal.sql differ
diff --git a/SamplesForChapter04/Chapter04/Ch04InsertToVarchar.sql b/SamplesForChapter04/Chapter04/Ch04InsertToVarchar.sql
new file mode 100644
index 0000000..91c643e
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04InsertToVarchar.sql
@@ -0,0 +1,24 @@
+--Designate any database available to you
+USE ProSSEAppsCh04
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ c1 int,
+ c2 varchar(8000)
+)
+GO
+
+DECLARE @v1 varchar(max)
+
+SET @v1 = REPLICATE('A',7999) + 'B'
+INSERT T VALUES (1, @v1)
+SELECT RIGHT(c2,2) 'Right 2 of c2' FROM T
+
+SET @v1 = @v1 + 'B'
+INSERT T VALUES (2, @v1)
+SELECT RIGHT(c2,2) 'Right 2 of c2' FROM T
+
diff --git a/SamplesForChapter04/Chapter04/Ch04InsertToVarcharMax.sql b/SamplesForChapter04/Chapter04/Ch04InsertToVarcharMax.sql
new file mode 100644
index 0000000..aafd79b
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04InsertToVarcharMax.sql
@@ -0,0 +1,22 @@
+USE ProSSEAppsCh04
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ c1 int,
+ c2 varchar(max)
+)
+GO
+
+DECLARE @v1 varchar(max)
+
+SET @v1 = REPLICATE('A',7999) + 'B'
+INSERT T VALUES (1, @v1)
+SELECT RIGHT(c2,2) 'Right 2 of c2' FROM T
+
+SET @v1 = @v1 + 'B'
+INSERT T VALUES (2, @v1)
+SELECT RIGHT(c2,2) 'Right 2 of c2' FROM T
diff --git a/SamplesForChapter04/Chapter04/Ch04InsertWithMissingValues.sql b/SamplesForChapter04/Chapter04/Ch04InsertWithMissingValues.sql
new file mode 100644
index 0000000..bb88c32
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04InsertWithMissingValues.sql
@@ -0,0 +1,50 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ int1 int,
+ bit1 bit,
+ varchar1 varchar(3),
+ dec1 dec(5,2),
+ cmp1 AS (int1 + bit1)
+)
+GO
+
+SET NOCOUNT ON
+INSERT T (int1, bit1) VALUES (1, 0)
+INSERT T (int1, varchar1) VALUES (2, 'abc')
+INSERT T (int1, dec1) VALUES (3, 5.25)
+INSERT T (bit1, dec1) VALUES (1, 9.75)
+GO
+
+--All columns for all rows
+SELECT * FROM T
+GO
+
+--Count all rows
+SELECT COUNT(*) 'Rows in T'
+FROM T
+
+--Count int1 values (implicitly non-null)
+SELECT COUNT(int1) 'int1 values in T'
+FROM T
+
+--Count non-null bit1 values
+SELECT COUNT(*) 'Count of non-null bit1'
+FROM T
+WHERE bit1 IS NOT NULL
+
+--Count null bit1 values
+SELECT COUNT(*) 'Count of null bit1'
+FROM T
+WHERE bit1 IS NULL
+
+--Average of dec1 values
+SELECT CAST(AVG(dec1) AS dec(5,2)) 'Avg of dec1'
+FROM T
+WHERE dec1 IS NOT NULL
diff --git a/SamplesForChapter04/Chapter04/Ch04IntChar.sql b/SamplesForChapter04/Chapter04/Ch04IntChar.sql
new file mode 100644
index 0000000..3d62146
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04IntChar.sql
@@ -0,0 +1,15 @@
+--Designate any database available to you;
+--You can create ProSSEAppsCh04 with a
+--statement such as: CREATE DATABASE ProSSEAPPSCh04
+USE ProSSEAppsCh04
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+
+CREATE TABLE T (
+ c1 int,
+ c2 char(49),
+ c3 char(8000)
+
+)
diff --git a/SamplesForChapter04/Chapter04/Ch04IntNchar.sql b/SamplesForChapter04/Chapter04/Ch04IntNchar.sql
new file mode 100644
index 0000000..7d61a2d
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04IntNchar.sql
@@ -0,0 +1,13 @@
+--Designate any database available to you
+USE ProSSEAppsCh04
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+
+CREATE TABLE T (
+ c1 int,
+ c2 nchar(24),
+ c3 nchar(4000)
+
+)
diff --git a/SamplesForChapter04/Chapter04/Ch04IntVarchar.sql b/SamplesForChapter04/Chapter04/Ch04IntVarchar.sql
new file mode 100644
index 0000000..8d37164
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04IntVarchar.sql
@@ -0,0 +1,12 @@
+--Designate any database available to you
+USE ProSSEAppsCh04
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+
+CREATE TABLE T (
+ c1 int,
+ c3 varchar(60),
+ c2 varchar(8000)
+)
diff --git a/SamplesForChapter04/Chapter04/Ch04NoBit1Nulls.sql b/SamplesForChapter04/Chapter04/Ch04NoBit1Nulls.sql
new file mode 100644
index 0000000..d63b989
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04NoBit1Nulls.sql
@@ -0,0 +1,28 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ int1 int,
+ bit1 bit NOT NULL,
+ varchar1 varchar(3),
+ dec1 dec(5,2),
+ cmp1 AS (int1 + bit1)
+)
+GO
+
+
+SET NOCOUNT ON
+INSERT T (int1, bit1) VALUES (1, 0)
+INSERT T (int1, varchar1) VALUES (2, 'abc')
+INSERT T (int1, dec1) VALUES (3, 5.25)
+INSERT T (bit1, dec1) VALUES (1, 9.75)
+GO
+
+
+SELECT * FROM T
+GO
diff --git a/SamplesForChapter04/Chapter04/Ch04NullToZero.sql b/SamplesForChapter04/Chapter04/Ch04NullToZero.sql
new file mode 100644
index 0000000..9b92b23
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04NullToZero.sql
@@ -0,0 +1,28 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ int1 int,
+ bit1 bit NOT NULL DEFAULT 0,
+ varchar1 varchar(3),
+ dec1 dec(5,2),
+ cmp1 AS (int1 + bit1)
+)
+GO
+
+
+SET NOCOUNT ON
+INSERT T (int1, bit1) VALUES (1, 0)
+INSERT T (int1, varchar1) VALUES (2, 'abc')
+INSERT T (int1, dec1) VALUES (3, 5.25)
+INSERT T (bit1, dec1) VALUES (1, 9.75)
+GO
+
+
+SELECT * FROM T
+GO
diff --git a/SamplesForChapter04/Chapter04/Ch04PKStudentGrades.sql b/SamplesForChapter04/Chapter04/Ch04PKStudentGrades.sql
new file mode 100644
index 0000000..fd86bdd
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04PKStudentGrades.sql
@@ -0,0 +1,25 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'ClassGrades')
+ DROP TABLE ClassGrades
+GO
+
+
+CREATE TABLE ClassGrades(
+ ClassID int,
+ StudentID int,
+ GradeLetter varchar(2),
+ Constraint PK_ClassGrades
+ PRIMARY KEY(ClassID, StudentID)
+)
+GO
+
+INSERT ClassGrades VALUES(1,1,'A')
+INSERT ClassGrades VALUES(1,2,'B-')
+INSERT ClassGrades (ClassID, GradeLetter)
+ VALUES(1,'C-')
+GO
+
+SELECT * FROM ClassGrades
diff --git a/SamplesForChapter04/Chapter04/Ch04UsingIDENTITY.sql b/SamplesForChapter04/Chapter04/Ch04UsingIDENTITY.sql
new file mode 100644
index 0000000..8644c88
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04UsingIDENTITY.sql
@@ -0,0 +1,25 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ int1 int IDENTITY PRIMARY KEY,
+ bit1 bit NOT NULL DEFAULT 0
+)
+GO
+
+--IDENTITY property grows column value from
+--a seed value by an increment value from a
+--default of IDENTITY(seed, increment)
+SET NOCOUNT ON
+INSERT T (bit1) VALUES (1)
+INSERT T (bit1) VALUES (0)
+INSERT T DEFAULT VALUES
+INSERT T (int1, bit1) VALUES (4,1)
+GO
+
+SELECT * FROM T
diff --git a/SamplesForChapter04/Chapter04/Ch04UsingPrimaryKey.sql b/SamplesForChapter04/Chapter04/Ch04UsingPrimaryKey.sql
new file mode 100644
index 0000000..de8bdb2
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04UsingPrimaryKey.sql
@@ -0,0 +1,26 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ int1 int PRIMARY KEY,
+ bit1 bit NOT NULL DEFAULT 0
+)
+GO
+
+--Row inserts fail for missing primary key
+--and duplicate primary key values
+SET NOCOUNT ON
+INSERT T (int1, bit1) VALUES (1, 1)
+INSERT T (int1, bit1) VALUES (2, 0)
+INSERT T (int1) VALUES (3)
+INSERT T (bit1) VALUES (1)
+INSERT T (int1, bit1) VALUES (3,1)
+GO
+
+SELECT * FROM T
+
diff --git a/SamplesForChapter04/Chapter04/Ch04WhoWhenDefaults.sql b/SamplesForChapter04/Chapter04/Ch04WhoWhenDefaults.sql
new file mode 100644
index 0000000..0b5d5fe
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04WhoWhenDefaults.sql
@@ -0,0 +1,41 @@
+USE ProSSEAppsCh04
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'T')
+ DROP TABLE T
+GO
+
+CREATE TABLE T (
+ int1 int,
+ bit1 bit NOT NULL DEFAULT 0,
+ rvr1 timestamp,
+ usr1 nvarchar(128) DEFAULT USER,
+ createtime datetime DEFAULT CURRENT_TIMESTAMP
+)
+GO
+
+SET NOCOUNT ON
+INSERT T (int1) VALUES (1)
+WAITFOR DELAY '00:00:01'
+INSERT T (int1, bit1) VALUES (2, 0)
+WAITFOR DELAY '00:00:01'
+INSERT T (int1, bit1) VALUES (3, 1)
+GO
+
+SELECT int1, bit1, usr1,
+ CONVERT(int, rvr1) 'Timestamp as int',
+ createtime
+FROM T
+GO
+
+UPDATE T
+set bit1 = 1
+WHERE int1 = 2
+GO
+
+SELECT int1, bit1, usr1,
+ CONVERT(int, rvr1) 'Timestamp as int',
+ createtime
+FROM T
+GO
diff --git a/SamplesForChapter04/Chapter04/Ch04Xml.sql b/SamplesForChapter04/Chapter04/Ch04Xml.sql
new file mode 100644
index 0000000..d5ff79b
--- /dev/null
+++ b/SamplesForChapter04/Chapter04/Ch04Xml.sql
@@ -0,0 +1,12 @@
+DECLARE @xdata xml
+SET @xdata = 'Rick' +
+ 'Virginia'
+SELECT @xdata AS 'xml data'
+
+SET @xdata = 'Rick' +
+ 'Virginia'
+SELECT @xdata AS 'xml data'
+
+SET @xdata = 'Rick' +
+ 'Virginia'
+SELECT @xdata AS 'xml data'
diff --git a/SamplesForChapter04/Chapter04/Database_1.mdf b/SamplesForChapter04/Chapter04/Database_1.mdf
new file mode 100644
index 0000000..abf5027
Binary files /dev/null and b/SamplesForChapter04/Chapter04/Database_1.mdf differ
diff --git a/SamplesForChapter04/Chapter04/Database_1_log.ldf b/SamplesForChapter04/Chapter04/Database_1_log.ldf
new file mode 100644
index 0000000..b448bb1
Binary files /dev/null and b/SamplesForChapter04/Chapter04/Database_1_log.ldf differ
diff --git a/SamplesForChapter05/Chapter05/CalculatingComputedListItems.sql b/SamplesForChapter05/Chapter05/CalculatingComputedListItems.sql
new file mode 100644
index 0000000..26e4471
--- /dev/null
+++ b/SamplesForChapter05/Chapter05/CalculatingComputedListItems.sql
@@ -0,0 +1,40 @@
+USE AdventureWorks
+GO
+
+--Computated value with numbers in list
+SELECT TOP 3 SalesOrderID, OrderQty, UnitPrice,
+ (OrderQty*UnitPrice) 'Line total before discount',
+ LineTotal
+FROM Sales.SalesOrderDetail
+
+--Conversion with CAST function for computated value
+--with numbers in list
+SELECT TOP 3 SalesOrderID, OrderQty, UnitPrice,
+ CAST((OrderQty*UnitPrice) AS dec(10,2))
+ 'Line total before discount',
+ LineTotal
+FROM Sales.SalesOrderDetail
+
+--Conversion with CONVERT function for computated value
+--with numbers in list
+SELECT TOP 3 SalesOrderID, OrderQty, UnitPrice,
+ CONVERT(dec(10,2),OrderQty*UnitPrice)
+ 'Line total before discount',
+ LineTotal
+FROM Sales.SalesOrderDetail
+
+--Computated value with characters in list without
+--editing extra blank space
+SELECT TOP 3 FirstName, MiddleName, LastName,
+ FirstName + ' ' + ISNULL(MiddleName, '')
+ + ' ' + LastName 'Full name'
+FROM Person.Contact
+
+--Computated value with characters in list with
+--editing extra blank space
+SELECT TOP 3 FirstName, MiddleName, LastName,
+ REPLACE(FirstName + ' ' + ISNULL(MiddleName, '')
+ + ' ' + LastName, ' ', ' ') 'Full name'
+FROM Person.Contact
+
+
diff --git a/SamplesForChapter05/Chapter05/CurrentDatabaseOrDifferentDatabase.sql b/SamplesForChapter05/Chapter05/CurrentDatabaseOrDifferentDatabase.sql
new file mode 100644
index 0000000..ce72e33
--- /dev/null
+++ b/SamplesForChapter05/Chapter05/CurrentDatabaseOrDifferentDatabase.sql
@@ -0,0 +1,28 @@
+USE AdventureWorks
+GO
+
+SELECT TOP 5 SalesOrderID 'Order ID',
+ CONVERT(varchar,OrderDate,101) 'Order date'
+FROM Sales.SalesOrderHeader
+
+SELECT TOP 5 OrderID 'Order ID',
+ CONVERT(varchar,OrderDate,101) 'Order date'
+FROM Northwind.dbo.Orders
+
+USE Northwind
+GO
+
+SELECT TOP 5 OrderID 'Order ID',
+ CONVERT(varchar,OrderDate,101) 'Order date'
+FROM Orders
+
+SELECT TOP 5 SalesOrderID 'Order ID',
+ CONVERT(varchar,OrderDate,101) 'Order date'
+FROM AdventureWorks.Sales.SalesOrderHeader
+
+USE AdventureWorks
+GO
+
+SELECT TOP 3 SalesPersonID, FirstName, LastName,
+ CAST(SalesYTD AS dec(12,2)) 'YTD Sales'
+FROM Sales.vSalesPerson
diff --git a/SamplesForChapter05/Chapter05/DisplayingDatetimeValues.sql b/SamplesForChapter05/Chapter05/DisplayingDatetimeValues.sql
new file mode 100644
index 0000000..626e4a0
--- /dev/null
+++ b/SamplesForChapter05/Chapter05/DisplayingDatetimeValues.sql
@@ -0,0 +1,38 @@
+USE AdventureWorks
+GO
+
+--Datetime values are numbers that you can
+--display as characters
+SELECT TOP 1 SalesOrderID, OrderDate,
+ OrderDate + 9 'OrderDate + 9',
+ OrderDate + .5 'OrderDate + .5'
+FROM Sales.SalesOrderHeader
+
+--Computed values with the CONVERT function for a
+--datetime-to-varchar representation of a date
+SELECT TOP 1 SalesOrderID, OrderDate,
+ CONVERT(varchar,OrderDate,100) 'Mmm dd yyyy hh:mmdp',
+ CONVERT(varchar,OrderDate,101) 'mm/dd/yyyy',
+ CONVERT(varchar,OrderDate,103) 'dd/mm/yyyy'
+FROM Sales.SalesOrderHeader
+
+
+--Computed values with the CONVERT function for a
+--datetime-to-varchar representation of a time
+--or date and time
+SELECT TOP 1 GETDATE() 'Default',
+ CONVERT(varchar,GETDATE(),108) 'hh:mm:ss',
+ CONVERT(varchar,GETDATE(),114) 'hh:mm:ss:mmm',
+ CONVERT(varchar,GETDATE(),113) 'dd Mmm yyyy hh:mm:ss:mmm'
+
+--Tdoay, one month from now, and days between
+--via DATEDIFF function
+DECLARE @thisdate datetime, @nextmonth datetime
+SET @thisdate = GETDATE()
+SET @nextmonth = DATEADD(m, 1, GETDATE())
+SELECT CONVERT(varchar, @thisdate, 101) 'Today',
+ CONVERT(varchar, @nextmonth, 101) 'One month from today',
+ DATEDIFF(d, @thisdate, @nextmonth) 'Days between'
+
+
+
diff --git a/SamplesForChapter05/Chapter05/ExactAndApproximateCharacterMatches.sql b/SamplesForChapter05/Chapter05/ExactAndApproximateCharacterMatches.sql
new file mode 100644
index 0000000..085849b
--- /dev/null
+++ b/SamplesForChapter05/Chapter05/ExactAndApproximateCharacterMatches.sql
@@ -0,0 +1,50 @@
+USE Adventureworks
+GO
+
+--Select contacts with a specific last name
+SELECT FirstName, LastName, EmailAddress, Phone
+FROM Person.Contact
+WHERE LastName = 'Blanco'
+
+--Select contacts whose last name starts with
+--b using LIKE operator and wildcard
+SELECT FirstName, LastName, EmailAddress, Phone
+FROM Person.Contact
+WHERE LastName LIKE 'b%'
+
+--Select contacts whose last name starts with
+--a specific letter using LIKE operator and wildcard
+DECLARE @alpha nchar(1)
+SET @alpha = 'b'
+SELECT FirstName, LastName, EmailAddress, Phone
+FROM Person.Contact
+WHERE LastName LIKE @alpha + '%'
+
+--Select contacts whose last name starts and
+--ends with specific letters using LIKE
+--operator and wildcards
+DECLARE @alpha nchar(1), @endalpha nchar(1)
+SET @alpha = 'c'
+SET @endalpha = 'o'
+SELECT FirstName, LastName, EmailAddress, Phone
+FROM Person.Contact
+WHERE LastName LIKE @alpha + '%' + @endalpha
+
+--Select contacts whose last name contains a string
+--of characters using LIKE operator and wildcard
+DECLARE @alpha nvarchar(10)
+SET @alpha = 'bell'
+SELECT FirstName, LastName, EmailAddress, Phone, @alpha
+FROM Person.Contact
+WHERE LastName LIKE '%' + @alpha + '%'
+
+--Select contacts with specific LastName and
+--whose Phone contains a specific country code
+DECLARE @alpha1 nvarchar(30), @alpha2 nvarchar(10)
+SET @alpha1 = 'Blanco'
+SET @alpha2 = '%(11)%'
+SELECT FirstName, LastName, EmailAddress, Phone
+FROM Person.Contact
+WHERE LastName = @alpha1 AND
+ Phone LIKE @alpha2
+
diff --git a/SamplesForChapter05/Chapter05/FilteringForValuesInARange.sql b/SamplesForChapter05/Chapter05/FilteringForValuesInARange.sql
new file mode 100644
index 0000000..21d3c55
--- /dev/null
+++ b/SamplesForChapter05/Chapter05/FilteringForValuesInARange.sql
@@ -0,0 +1,62 @@
+USE AdventureWorks
+GO
+
+--Using comparison operators in a WHERE clause
+SELECT DISTINCT SalesQuota FROM Sales.SalesPerson
+
+SELECT SalesPersonID, SalesQuota,
+ CAST(SalesYTD AS dec(12,2)) 'Sales this year' ,
+ CAST(SalesLastYear AS dec(12,2)) 'Sales last year'
+FROM Sales.SalesPerson
+WHERE SalesQuota <=250000
+
+SELECT SalesPersonID, SalesQuota,
+ CAST(SalesYTD AS dec(12,2)) 'Sales this year' ,
+ CAST(SalesLastYear AS dec(12,2)) 'Sales last year'
+FROM Sales.SalesPerson
+WHERE SalesQuota >250000
+
+SELECT SalesPersonID, SalesQuota,
+ CAST(SalesYTD AS dec(12,2)) 'Sales this year' ,
+ CAST(SalesLastYear AS dec(12,2)) 'Sales last year'
+FROM Sales.SalesPerson
+WHERE SalesQuota IS NULL
+
+--Using the BETWEEN operator in a WHERE clause
+SELECT SalesPersonID, SalesQuota,
+ CAST(SalesYTD AS dec(12,2)) 'Sales this year' ,
+ CAST(SalesLastYear AS dec(12,2)) 'Sales last year'
+FROM Sales.SalesPerson
+WHERE SalesYTD BETWEEN 200000 AND 650000
+
+SELECT Count(*) 'SalesYTD outside BETWEEN'
+FROM Sales.SalesPerson
+WHERE SalesYTD NOT BETWEEN 200000 AND 650000
+
+SELECT SalesPersonID, SalesQuota,
+ CAST(SalesYTD AS dec(12,2)) 'Sales this year' ,
+ CAST(SalesLastYear AS dec(12,2)) 'Sales last year'
+FROM Sales.vSalesPerson
+WHERE SalesYTD BETWEEN 200000 AND 650000 OR
+ SalesYTD > 5000000
+
+
+--Using IN operator in a WHERE clause
+SELECT COUNT(*)
+FROM Sales.SalesPerson
+WHERE SalesQuota IN(250000, 300000)
+
+SELECT COUNT(*)
+FROM Sales.SalesPerson
+WHERE SalesQuota NOT IN(250000, 300000)
+
+SELECT SalesPersonID, CountryRegionName
+FROM Sales.vSalesPerson
+WHERE CountryRegionName IN ('United States', 'Canada')
+
+SELECT SalesPersonID, CountryRegionName
+FROM Sales.vSalesPerson
+WHERE CountryRegionName NOT IN ('United States', 'Canada')
+
+
+
diff --git a/SamplesForChapter05/Chapter05/GroupingAndAggregating.sql b/SamplesForChapter05/Chapter05/GroupingAndAggregating.sql
new file mode 100644
index 0000000..4e3c2e7
--- /dev/null
+++ b/SamplesForChapter05/Chapter05/GroupingAndAggregating.sql
@@ -0,0 +1,73 @@
+USE AdventureWorks
+GO
+
+--List unique TerritoryName values with
+--either DISTINCT or GROUP BY
+SELECT DISTINCT TerritoryName
+FROM Sales.VSalesPerson
+
+SELECT TerritoryName
+FROM Sales.VSalesPerson
+GROUP BY TerritoryName
+GO
+
+--Group TerritoryName values within
+--TerritoryGroup values
+SELECT TerritoryGroup, TerritoryName
+FROM Sales.VSalesPerson
+GROUP BY TerritoryGroup, TerritoryName
+GO
+
+--Compute a count within a group
+SELECT TerritoryGroup, TerritoryName, COUNT(*) 'Sales persons'
+FROM Sales.VSalesPerson
+GROUP BY TerritoryGroup, TerritoryName
+GO
+
+--Territory counting by removing null values
+--and ordering TerritoryName within TerritoryGroup
+SELECT TerritoryGroup, TerritoryName, COUNT(*) 'Sales persons'
+FROM Sales.VSalesPerson
+GROUP BY TerritoryGroup, TerritoryName
+HAVING TerritoryGroup IS NOT NULL
+ORDER BY TerritoryGroup, TerritoryName
+GO
+
+--Compute row count, sum of a calculated column and
+--a data column by territory ID
+SELECT TerritoryID, COUNT(*) 'Persons/territory',
+ CAST(SUM(SalesYTD*CommissionPct) AS dec(12,2)) 'Commissions',
+ SUM(Bonus) 'Bonuses',
+ CAST(SUM(SalesYTD*CommissionPct) +
+ SUM(Bonus) AS dec(12,2)) 'Cs + Bs'
+FROM Sales.SalesPerson
+WHERE TerritoryID IS NOT NULL
+GROUP BY TerritoryID
+GO
+
+--Number of items ordered and sum of prices for items
+--ordered by sales order ID
+SELECT TOP 5 SalesOrderID, COUNT(OrderQty) 'Items ordered',
+ CAST(SUM(LineTotal) AS dec(12,2)) 'Price of items ordered'
+FROM Sales.SalesOrderDetail
+GROUP BY SalesOrderID
+
+
+--Number of items ordered and price of items ordered for
+--above average sales orders
+DECLARE @totsales dec(12,2), @numofsales int
+SET @totsales = (SELECT SUM(LineTotal) FROM Sales.SalesOrderDetail)
+SET @numofsales = (SELECT COUNT(SalesOrderID) FROM Sales.SalesOrderHeader)
+SELECT @totsales 'Total sales revenue',
+ @numofsales 'Number of sales',
+ @totsales/@numofsales 'Average revenue/sale'
+
+
+SELECT TOP 5 SalesOrderID, COUNT(OrderQty) 'Items ordered',
+ SUM(LineTotal) 'Price of items ordered'
+FROM Sales.SalesOrderDetail
+GROUP BY SalesOrderID
+HAVING SUM(LineTotal) > @totsales/@numofsales
+GO
+
+
diff --git a/SamplesForChapter05/Chapter05/OPENROWSETAndLinkedServers.sql b/SamplesForChapter05/Chapter05/OPENROWSETAndLinkedServers.sql
new file mode 100644
index 0000000..0266fbc
--- /dev/null
+++ b/SamplesForChapter05/Chapter05/OPENROWSETAndLinkedServers.sql
@@ -0,0 +1,65 @@
+USE AdventureWorks
+GO
+
+--Demo of the OPENROWSET function
+SELECT a.*
+FROM OPENROWSET('SQLNCLI','instance_name';'userid';'userid_password',
+ 'SELECT *
+ FROM Northwind.dbo.Shippers') AS a
+GO
+
+--utility system stored procedures for working
+--with linked servers
+EXEC sp_linkedservers
+EXEC sp_helplinkedsrvlogin 'MyLinkedServer'
+
+--Specify a default database context on the local computer
+USE master
+GO
+
+--Drop default login for linked server and linked server
+EXEC sp_droplinkedsrvlogin 'MyLinkedServer', NULL
+EXEC sp_dropserver 'MyLinkedServer'
+GO
+
+--Create a new linked server to the local default
+--SQL Server instance
+EXEC sp_addlinkedserver
+ @server='MyLinkedServer',
+ @srvproduct= N'',
+ @provider='SQLNCLI',
+ @datasrc='Cab233a'
+GO
+
+--Perform a query with four-partname for
+--the Shippers table in the Northwind database on
+--the linked server
+SELECT * FROM MyLinkedServer.Northwind.dbo.Shippers
+GO
+
+
+--Drop default login for linked server and linked server
+EXEC sp_droplinkedsrvlogin 'MyLinkedServer', NULL
+EXEC sp_dropserver 'MyLinkedServer'
+GO
+
+--Add linked server for a remote computer
+EXEC sp_addlinkedserver
+ @server='MyLinkedServer',
+ @srvproduct= N'',
+ @provider='SQLNCLI',
+ @datasrc='CCS1'
+GO
+
+--Specify a login for linked server which any
+--user on the local computer can use
+EXEC sp_addlinkedsrvlogin 'MyLinkedServer', 'false',
+ NULL, 'sa', 'password'
+GO
+
+--Perform a query with four-partname for
+--the Shippers table in the Northwind database on
+--the linked server
+SELECT * FROM MyLinkedServer.Northwind.dbo.Shippers
+GO
+
diff --git a/SamplesForChapter05/Chapter05/ReturningTopValues.sql b/SamplesForChapter05/Chapter05/ReturningTopValues.sql
new file mode 100644
index 0000000..0f862a3
--- /dev/null
+++ b/SamplesForChapter05/Chapter05/ReturningTopValues.sql
@@ -0,0 +1,46 @@
+USE AdventureWorks
+GO
+
+--TOP keyword can get a fixed number of rows from the top
+--of a result set
+SELECT TOP 5 ProductSubcategoryID, ProductCategoryID,
+ Name 'Subcategory name'
+FROM Production.ProductSubcategory
+
+--TOP keyword can take an argument to specify
+--how many rows to return; for example, 6 in this case
+DECLARE @n int
+SET @n = 6
+SELECT TOP (@n) ProductSubcategoryID, ProductCategoryID,
+ Name 'Subcategory name'
+FROM Production.ProductSubcategory
+
+
+--TOP keyword can also get a fixed percent of rows to return
+SELECT TOP 20 PERCENT ProductSubcategoryID, ProductCategoryID, Name 'Subcategory name'
+FROM Production.ProductSubcategory
+
+--TOP keyword also takes a argument for PERCENT;
+--the number of row for a percent rounds up to the next integer
+--if percent does not precisely return an integer
+--11 percent of 37 is 4.07, and it returns 5 rows
+--10 and 9 percent of 37 are 3.70 and 3.33; both return 4 rows
+--8 percent of 37 is 2.96, and it returns 3 rows
+DECLARE @n int
+SET @n = 11
+SELECT TOP (@n) PERCENT ProductSubcategoryID, ProductCategoryID,
+ Name 'Subcategory name'
+FROM Production.ProductSubcategory
+SET @n = 10
+SELECT TOP (@n) PERCENT ProductSubcategoryID, ProductCategoryID,
+ Name 'Subcategory name'
+FROM Production.ProductSubcategory
+SET @n = 9
+SELECT TOP (@n) PERCENT ProductSubcategoryID, ProductCategoryID,
+ Name 'Subcategory name'
+FROM Production.ProductSubcategory
+SET @n = 8
+SELECT TOP (@n) PERCENT ProductSubcategoryID, ProductCategoryID,
+ Name 'Subcategory name'
+FROM Production.ProductSubcategory
+
diff --git a/SamplesForChapter05/Chapter05/SaveSolutions.txt b/SamplesForChapter05/Chapter05/SaveSolutions.txt
new file mode 100644
index 0000000..2646319
--- /dev/null
+++ b/SamplesForChapter05/Chapter05/SaveSolutions.txt
@@ -0,0 +1,887 @@
+WITH SubTotalRownumbers (st, rn)
+AS (
+SELECT SubTotal, ROW_NUMBER() OVER(ORDER BY SubTotal) 'RN'
+FROM Sales.SalesOrderHeader
+)
+SELECT st 'SubTotal'
+FROM SubTotalRownumbers
+WHERE rn = 1
+
+
+
+
+
+
+USE AdventureWorks
+GO
+
+
+DECLARE @int1 int
+SET @int1 = 3
+
+SELECT @int1 % 2
+
+
+
+
+USE AdventureWorks
+GO
+
+--Create function to count the number of customers
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'FN' AND schema_id = 1
+ AND name = 'ufnCntCustomers')
+ DROP FUNCTION dbo.ufnCntCustomers
+GO
+
+
+CREATE FUNCTION dbo.ufnCntCustomers()
+RETURNS int
+AS
+BEGIN
+ RETURN (SELECT COUNT(*) FROM Sales.Customer)
+END
+GO
+
+--Invoke the function to count customers
+SELECT dbo.ufnCntCustomers() '# of Customers'
+GO
+
+
+--Create function to determine if a
+--number (@n) is odd
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'FN' AND schema_id = 1
+ AND name = 'ufnIsOdd')
+ DROP FUNCTION dbo.ufnIsOdd
+GO
+
+CREATE FUNCTION dbo.ufnIsOdd (@n AS int)
+RETURNS bit
+AS
+BEGIN
+ RETURN (@n % 2)
+END
+GO
+
+--Use ufnIsOdd function
+DECLARE @numb int
+SET @numb = 6
+SELECT @numb 'Number', dbo.ufnIsOdd (@numb) 'Is_odd = 1'
+SET @numb = 7
+SELECT @numb 'Number', dbo.ufnIsOdd (@numb) 'Is_odd = 1'
+
+--SELECT COUNT(SubTotal) FROM Sales.SalesOrderHeader
+DECLARE @VAL int
+SET @VAL = (SELECT COUNT(SubTotal) FROM Sales.SalesOrderHeader)
+PRINT @VAL
+IF (SELECT dbo.ufnIsOdd (@VAL)) = 1
+BEGIN
+ WITH SubTotalRownumbers (st, rn)
+ AS (
+ SELECT SubTotal, ROW_NUMBER() OVER(ORDER BY SubTotal) 'RN'
+ FROM Sales.SalesOrderHeader
+ )
+ SELECT st 'SubTotal'
+ FROM SubTotalRownumbers
+ WHERE rn = @VAL/2 + 1
+ END
+else
+ print 'even'
+
+--Drop ufnIsOdd function
+DROP FUNCTION dbo.ufnCntCustomers
+GO
+
+--Drop ufnIsOdd function
+DROP FUNCTION dbo.ufnIsOdd
+GO
+
+
+
+
+USE AdventureWorks
+GO
+
+
+SELECT OBJECT_id('ufnListAllSalesPersons')
+
+
+SELECT * FROM sys.objects WHERE name = 'ufnListAllSalesPersons'
+
+SELECT * FROM sys.objects
+WHERE type = 'FN' OR type = '%F%'
+
+sp_rename 'ufnIsOdd', 'ufnIsOddchanged'
+
+sp_rename 'ufnIsOddchanged', 'ufnIsOdd'
+
+SELECT SalesPersonID, FirstName, LastName, TerritoryName, Phone
+FROM Sales.vSalesPerson
+
+
+
+
+
+USE AdventureWorks
+GO
+
+
+--Create function to list all sales persons
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'IF' AND schema_id = 1
+ AND name = 'ufnListAllSalesPersons')
+ DROP FUNCTION dbo.ufnListAllSalesPersons
+GO
+
+CREATE FUNCTION dbo.ufnListAllSalesPersons()
+RETURNS TABLE
+AS
+RETURN (
+ SELECT SalesPersonID, FirstName, LastName, TerritoryName, Phone
+ FROM Sales.vSalesPerson)
+GO
+
+--Invoke the function to list all sales persons
+SELECT * FROM dbo.ufnListAllSalesPersons()
+
+--Drop inline function
+DROP FUNCTION dbo.ufnListAllSalesPersons
+
+
+
+
+
+USE AdventureWorks
+GO
+
+--Create function to list sales persons from a territory
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'IF' AND schema_id = 1
+ AND name = 'ufnListSalesPersonsInTerritory')
+ DROP FUNCTION dbo.ufnListSalesPersonsInTerritory
+GO
+
+CREATE FUNCTION
+ dbo.ufnListSalesPersonsInTerritory(@t AS nvarchar(50))
+RETURNS TABLE
+AS
+RETURN (
+ SELECT SalesPersonID, FirstName, LastName,
+ TerritoryName, Phone
+ FROM Sales.vSalesPerson
+ WHERE TerritoryName = @t)
+GO
+
+--Invoke the function to list sales persons for a territory
+DECLARE @t as nvarchar(50)
+SET @t = 'Canada'
+SELECT * FROM dbo.ufnListSalesPersonsInTerritory(@t)
+
+--Drop inline function
+DROP FUNCTION dbo.ufnListSalesPersonsInTerritory
+
+
+
+
+
+USE AdventureWorks
+GO
+
+--Make stored proc in default schema
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalePersonNamePhoneEmail')
+ DROP PROCEDURE usp_SalePersonNamePhoneEmail
+GO
+
+CREATE PROCEDURE usp_SalePersonNamePhoneEmail
+AS
+SELECT s.TerritoryID, c.LastName, c.Phone, c.EmailAddress
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+GO
+
+--Invoke stored proc
+EXEC usp_SalePersonNamePhoneEmail
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalePersonNamePhoneEmail
+GO
+
+--For display in book
+--Make stored proc in default schema
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalePersonNamePhoneEmail')
+ DROP PROCEDURE usp_SalePersonNamePhoneEmail
+GO
+
+CREATE PROCEDURE usp_SalePersonNamePhoneEmail
+AS
+SELECT s.TerritoryID,
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ CAST(c.Phone AS nvarchar(19)) 'Phone',
+ CAST(c.EmailAddress AS nvarchar(28)) 'EmailAddress'
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+GO
+
+--Invoke stored proc
+EXEC usp_SalePersonNamePhoneEmail
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalePersonNamePhoneEmail
+GO
+
+
+--Searches for usp_ProductCategoryCountSubcategory in
+--any schema and drops stored proc in Production schema
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_ProductCategoryCountSubcategory')
+ DROP PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+GO
+
+--Create a stored proc with two result sets
+CREATE PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+AS
+
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+ORDER BY ProductCategoryID
+
+SELECT ProductCategoryID, COUNT(*) 'No. Subcategories'
+FROM Production.ProductSubcategory
+GROUP BY ProductCategoryID
+ORDER BY ProductCategoryID
+GO
+
+--Invoke stored proc
+EXEC Production.usp_ProductCategoryCountSubcategory
+GO
+
+--Drop stored proc
+DROP PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+GO
+
+--For display in book
+--Searches for usp_ProductCategoryCountSubcategory in
+--any schema and drops stored proc in Production schema
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_ProductCategoryCountSubcategory')
+ DROP PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+GO
+
+--Create a stored proc with two result sets
+CREATE PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+AS
+
+SELECT ProductCategoryID, CAST(Name AS nvarchar(11)) 'Name'
+FROM Production.ProductCategory
+ORDER BY ProductCategoryID
+
+SELECT ProductCategoryID, COUNT(*) 'No. Subcategories'
+FROM Production.ProductSubcategory
+GROUP BY ProductCategoryID
+ORDER BY ProductCategoryID
+GO
+
+--Invoke stored proc
+EXEC Production.usp_ProductCategoryCountSubcategory
+GO
+
+--Drop stored proc
+DROP PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+GO
+
+
+
+
+
+USE AdventureWorks
+GO
+
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalePersonInATerritory')
+ DROP PROCEDURE usp_SalePersonInATerritory
+GO
+
+--Create a stored proc with an input parameter
+CREATE PROCEDURE usp_SalePersonInATerritory
+@TID int
+AS
+SELECT s.TerritoryID, c.LastName, c.Phone
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+WHERE s.TerritoryID = @TID
+GO
+
+--Run the stored proc with two different
+--parameter values
+EXEC usp_SalePersonInATerritory 1
+GO
+EXEC usp_SalePersonInATerritory 2
+GO
+
+--Failing to input a parameter can cause a failure
+--EXEC usp_SalePersonInATerritory
+--GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalePersonInATerritory
+GO
+
+--For display in book
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalePersonInATerritory')
+ DROP PROCEDURE usp_SalePersonInATerritory
+GO
+
+--Create a stored proc with an input parameter
+CREATE PROCEDURE usp_SalePersonInATerritory
+@TID int
+AS
+SELECT s.TerritoryID,
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ CAST(c.Phone AS nvarchar(19)) 'Phone'
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+WHERE s.TerritoryID = @TID
+GO
+
+--Run the stored proc with two different
+--parameter values
+EXEC usp_SalePersonInATerritory 1
+GO
+EXEC usp_SalePersonInATerritory 2
+GO
+
+--Failing to input a parameter can cause a failure
+--EXEC usp_SalePersonInATerritory
+--GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalePersonInATerritory
+GO
+
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalePersonInATerritory')
+ DROP PROCEDURE usp_SalePersonInATerritory
+GO
+
+--Create a stored proc with an input parameter and
+--a non-null default value
+CREATE PROCEDURE usp_SalePersonInATerritory
+@TID int = 2
+AS
+SELECT s.TerritoryID, c.LastName, c.Phone
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+WHERE s.TerritoryID = @TID
+GO
+
+--Run the stored proc with two different
+--parameter values
+EXEC usp_SalePersonInATerritory 1
+GO
+
+--Failing to input a parameter can causeS
+--usp_SalePersonInATerritory to use defaul
+--parameter value
+EXEC usp_SalePersonInATerritory
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalePersonInATerritory
+GO
+
+--For display in book
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalePersonInATerritory')
+ DROP PROCEDURE usp_SalePersonInATerritory
+GO
+
+--Create a stored proc with an input parameter and
+--a non-null default value
+CREATE PROCEDURE usp_SalePersonInATerritory
+@TID int = 2
+AS
+SELECT s.TerritoryID,
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ CAST(c.Phone AS nvarchar(19)) 'Phone'
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+WHERE s.TerritoryID = @TID
+GO
+
+--Run the stored proc with two different
+--parameter values
+EXEC usp_SalePersonInATerritory 1
+GO
+
+--Failing to input a parameter can causeS
+--usp_SalePersonInATerritory to use defaul
+--parameter value
+EXEC usp_SalePersonInATerritory
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalePersonInATerritory
+GO
+
+
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalePersonInATerritoryOrNot')
+ DROP PROCEDURE usp_SalePersonInATerritoryOrNot
+GO
+
+--Create a stored proc with an input parameter,
+--default value assignment, and IF statement
+CREATE PROCEDURE usp_SalePersonInATerritoryOrNot
+@TID int = NULL
+AS
+IF @TID IS NOT NULL
+ SELECT s.TerritoryID, c.LastName, c.Phone
+ FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ ON s.SalesPersonID = e.EmployeeID
+ JOIN Person.Contact c
+ ON c.ContactID = e.ContactID
+ WHERE s.TerritoryID = @TID
+ELSE
+ SELECT s.TerritoryID, c.LastName, c.Phone
+ FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ ON s.SalesPersonID = e.EmployeeID
+ JOIN Person.Contact c
+ ON c.ContactID = e.ContactID
+ WHERE s.TerritoryID IS NULL
+GO
+
+--Run the stored proc with three different
+--parameter values, including NULL
+EXEC usp_SalePersonInATerritoryOrNot 1
+GO
+EXEC usp_SalePersonInATerritoryOrNot 2
+GO
+EXEC usp_SalePersonInATerritoryOrNot
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalePersonInATerritoryOrNot
+GO
+
+--For display in book
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalePersonInATerritoryOrNot')
+ DROP PROCEDURE usp_SalePersonInATerritoryOrNot
+GO
+
+--Create a stored proc with an input parameter,
+--default value assignment, and IF statement
+CREATE PROCEDURE usp_SalePersonInATerritoryOrNot
+@TID int = NULL
+AS
+IF @TID IS NOT NULL
+ SELECT s.TerritoryID,
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ CAST(c.Phone AS nvarchar(19)) 'Phone'
+ FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ ON s.SalesPersonID = e.EmployeeID
+ JOIN Person.Contact c
+ ON c.ContactID = e.ContactID
+ WHERE s.TerritoryID = @TID
+ELSE
+ SELECT s.TerritoryID,
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ CAST(c.Phone AS nvarchar(19)) 'Phone'
+ FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ ON s.SalesPersonID = e.EmployeeID
+ JOIN Person.Contact c
+ ON c.ContactID = e.ContactID
+ WHERE s.TerritoryID IS NULL
+GO
+
+--Run the stored proc with three different
+--parameter values, including NULL
+EXEC usp_SalePersonInATerritoryOrNot 1
+GO
+EXEC usp_SalePersonInATerritoryOrNot 2
+GO
+EXEC usp_SalePersonInATerritoryOrNot
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalePersonInATerritoryOrNot
+GO
+
+
+--Create function to determine if a
+--number (@n) is odd
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'FN' AND schema_id = 1
+ AND name = 'ufnIsOdd')
+ DROP FUNCTION dbo.ufnIsOdd
+GO
+
+CREATE FUNCTION dbo.ufnIsOdd (@n int = 5)
+RETURNS bit
+AS
+BEGIN
+ RETURN (@n % 2)
+END
+GO
+
+--Use ufnIsOdd function
+DECLARE @numb int
+
+--Input a null value returns null instead of
+--using default parameter
+SELECT dbo.ufnIsOdd (@numb) 'Is_odd = 1'
+
+--To tap default parameter value, you must
+--explicitly reference default value with the
+--default keyword
+SELECT dbo.ufnIsOdd (DEFAULT) 'Is_odd = 1'
+
+--Drop ufnIsOdd function
+DROP FUNCTION dbo.ufnIsOdd
+GO
+
+
+
+
+USE AdventureWorks
+GO
+
+--Create view with SubTotal values from
+--Sales.SalesOrderHeader table and row numbers
+IF EXISTS(SELECT *
+ FROM sys.views
+ WHERE name = 'STRow_Numbers' AND
+ schema_id = 1)
+ DROP VIEW dbo.STRow_Numbers
+GO
+
+CREATE VIEW dbo.STRow_Numbers
+AS
+SELECT SubTotal, Row_Number() OVER (ORDER BY SubTotal) rn
+FROM Sales.SalesOrderHeader
+GO
+
+
+--Create a view that returns the minimum and maximum
+--Subtotal values as output parameters
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_MinMaxSubTotal')
+ DROP PROCEDURE usp_MinMaxSubTotal
+GO
+
+--Create a stored proc with an input parameter
+CREATE PROCEDURE usp_MinMaxSubTotal
+@minSubTotal money OUTPUT,
+@maxSubTotal money OUTPUT
+AS
+SET @minSubTotal =
+ (SELECT TOP 1 SubTotal
+ FROM dbo.STRow_Numbers ORDER BY rn)
+SET @maxSubTotal =
+ (SELECT TOP 1 SubTotal
+ FROM dbo.STRow_Numbers ORDER BY rn DESC)
+GO
+
+--Invoke usp_MinMaxSubTotal to retrieve maximum and
+--minimum SubTotal values
+DECLARE @lclmin money, @lclmax money
+EXEC usp_MinMaxSubTotal @minSubTotal = @lclmin OUTPUT,
+ @maxSubTotal = @lclmax OUTPUT
+
+SELECT @lclmin 'Min. SubTotal', @lclmax 'Min. SubTotal'
+GO
+
+--Create FN user-defined function to determin
+--if a number is odd or even
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'FN' AND schema_id = 1
+ AND name = 'ufnIsOdd')
+ DROP FUNCTION dbo.ufnIsOdd
+GO
+
+CREATE FUNCTION dbo.ufnIsOdd (@n int)
+RETURNS bit
+AS
+BEGIN
+ RETURN (@n % 2)
+END
+GO
+
+
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_MedianSubTotal')
+ DROP PROCEDURE usp_MedianSubTotal
+GO
+
+--Create a stored proc with an input parameter
+CREATE PROCEDURE usp_MedianSubTotal
+@MedianVal money OUTPUT
+AS
+
+DECLARE @rnval int
+DECLARE @midup money, @middown money
+
+--Compute near middle row
+SET @rnval = ((SELECT COUNT(*) FROM dbo.STRow_Numbers)/2)
+PRINT @rnval;
+
+IF dbo.ufnIsOdd
+ ((SELECT COUNT(*)
+ FROM dbo.STRow_Numbers)) = 1
+ --get mediam for odd count
+ SET @MedianVal = (SELECT SubTotal
+ FROM dbo.STRow_Numbers
+ WHERE rn = @rnval + 1)
+ELSE
+BEGIN
+ --compute mediam for even count
+ SET @midup =
+ (SELECT SubTotal
+ FROM dbo.STRow_Numbers
+ WHERE rn = @rnval)
+ SET @middown =
+ (SELECT SubTotal
+ FROM dbo.STRow_Numbers
+ WHERE rn = (SELECT @rnval + 1))
+ SET @MedianVal =
+ (SELECT (@midup + @middown)/2)
+END
+GO
+
+--Invoke usp_MedianSubTotal to retrieve median SubTotal value
+DECLARE @MedValue money
+EXEC usp_MedianSubTotal @MedianVal = @MedValue OUTPUT
+
+SELECT @MedValue
+
+
+
+DROP PROCEDURE usp_MinMaxSubTotal
+DROP PROCEDURE usp_MedianSubTotal
+DROP FUNCTION dbo.ufnIsOdd
+DROP VIEW dbo.STRow_Numbers
+
+
+
+
+
+USE AdventureWorks
+GO
+
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalesPersonReport')
+ DROP PROCEDURE usp_SalesPersonReport
+GO
+
+CREATE PROC usp_SalesPersonReport
+@BestSalesPerson nvarchar(150) OUTPUT
+AS
+
+SET @BestSalesPerson = (SELECT REPLACE(FirstName + ' ' +
+ ISNULL(MiddleName, '') + ' ' + LastName, ' ', ' ')
+ FROM Sales.VSalesPerson
+ WHERE SalesYTD =
+ (SELECT MAX(SalesYTD) FROM Sales.VSalesPerson))
+
+SELECT SalesPersonID, FirstName, MiddleName,
+ LastName, SalesYTD
+FROM Sales.VSalesPerson
+
+IF (SELECT SalesYTD
+ FROM Sales.VSalesPerson
+ WHERE SalesYTD = (SELECT MAX(SalesYTD)
+ FROM Sales.VSalesPerson)) >
+ (SELECT SalesLastYear
+ FROM Sales.VSalesPerson
+ WHERE SalesYTD =
+ (SELECT MAX(SalesYTD)
+ FROM Sales.VSalesPerson))
+ RETURN 1
+ELSE
+ RETURN 0
+GO
+
+
+DECLARE @BestName nvarchar(150), @rsval int
+EXEC @rsval = usp_SalesPersonReport
+ @BestSalesPerson = @BestName OUTPUT
+
+IF @rsval = 1
+ SELECT @BestName 'Best sales person is:',
+ 'Yes' 'Exceeded last year:'
+ELSE
+ SELECT @BestName 'Best sales person is:',
+ 'No' 'Exceeded last year:'
+
+DROP PROCEDURE usp_SalesPersonReport
+
+
+
+USE ProSSEAppsCh07
+GO
+
+--Create a new view after dropping previously\
+--existing version of view
+IF EXISTS(SELECT *
+ FROM sys.views
+ WHERE name = 'StudentGrades' AND
+ schema_id = 1)
+ DROP VIEW dbo.StudentGrades
+GO
+
+CREATE VIEW dbo.StudentGrades
+AS
+SELECT s.StudentID, s.FirstName, s.LastName, s.Fullname,
+ c.ClassID, c.ClassTitle, cg.Gradeletter
+FROM Classes c JOIN ClassGrades cg
+ON c.ClassID = cg.ClassID
+JOIN Students S
+ON s.StudentID = cg.StudentID
+GO
+
+
+--SELECT from view before adding a new class
+SELECT DISTINCT ClassID, ClassTitle
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+--INSERT new class through view
+INSERT dbo.StudentGrades (ClassID, ClassTitle)
+ VALUES (2, 'Learning Visual Basic Express for DBAs')
+GO
+
+--SELECT from view after adding a new class
+SELECT DISTINCT ClassID, ClassTitle
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+--Verify new row is there by querying the Classes table
+SELECT ClassID, ClassTitle
+FROM Classes
+GO
+
+--Attempt to insert generates an error because modification
+--affects multiple base tables
+INSERT dbo.StudentGrades (ClassID, StudentID, Gradeletter)
+ VALUES(2, 1, 'B')
+INSERT dbo.StudentGrades (ClassID, StudentID, Gradeletter)
+ VALUES(2, 2, 'A')
+GO
+
+--Remedy by inserting directly into a base table
+INSERT ClassGrades (ClassID, StudentID, Gradeletter)
+ VALUES(2, 1, 'B')
+INSERT ClassGrades (ClassID, StudentID, Gradeletter)
+ VALUES(2, 2, 'A')
+GO
+
+--SELECT from view after adding a new class
+SELECT DISTINCT ClassID, ClassTitle
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+--SELECT from view before updating LastName
+SELECT StudentID, FullName, ClassTitle, GradeLetter
+FROM dbo.StudentGrades
+ORDER BY StudentID, ClassID
+
+--Update LastName of student
+UPDATE dbo.StudentGrades
+SET LastName = 'DBA-Minister'
+WHERE StudentID = 2
+GO
+
+
+--SELECT from view after updating last name
+SELECT StudentID, FullName, ClassTitle, GradeLetter
+FROM dbo.StudentGrades
+ORDER BY StudentID, ClassID
+
+
+
+--SELECT from view before updating LastName
+SELECT StudentID,
+ CAST(FullName AS nvarchar(19)) 'FullName',
+ CAST(ClassTitle AS nvarchar(38)) 'ClassTitle',
+ GradeLetter
+FROM dbo.StudentGrades
+ORDER BY StudentID, ClassID
+
+--Update LastName of student
+UPDATE dbo.StudentGrades
+SET LastName = 'DBA-Minister'
+WHERE StudentID = 2
+GO
+
+
+--SELECT from view after updating last name
+SELECT StudentID,
+ CAST(FullName AS nvarchar(19)) 'FullName',
+ CAST(ClassTitle AS nvarchar(38)) 'ClassTitle',
+ GradeLetter
+FROM dbo.StudentGrades
+ORDER BY StudentID, ClassID
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SamplesForChapter05/Chapter05/SpecifyingSELECTListItems.sql b/SamplesForChapter05/Chapter05/SpecifyingSELECTListItems.sql
new file mode 100644
index 0000000..5040d33
--- /dev/null
+++ b/SamplesForChapter05/Chapter05/SpecifyingSELECTListItems.sql
@@ -0,0 +1,31 @@
+USE AdventureWorks
+GO
+
+--Shows use of alias for a column name
+--in the Production.ProductCategory table
+SELECT ProductCategoryID, Name 'Category name'
+FROM Production.ProductCategory
+
+--Shows use of alias for a column name
+--in the Production.ProductSubcategory table;
+--output could be confusing without alias
+SELECT ProductSubcategoryID, ProductCategoryID,
+ Name 'Subcategory name'
+FROM Production.ProductSubcategory
+
+--An example of an expression in a list
+DECLARE @intvar int
+SET @intvar = 1
+SELECT ProductCategoryID, Name 'Category name',
+ @intvar 'Local variable'
+FROM Production.ProductCategory
+
+--An example of a aggregate function in a list
+SELECT Count(*)
+FROM Production.ProductSubcategory
+
+--DISTINCT keyword removes duplicate rows from output;
+--the following SELECT statement returns just 4 rows
+SELECT DISTINCT ProductCategoryID
+FROM Production.ProductSubcategory
+
diff --git a/SamplesForChapter06/Chapter06/CrossJoins.sql b/SamplesForChapter06/Chapter06/CrossJoins.sql
new file mode 100644
index 0000000..d1a6aa3
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/CrossJoins.sql
@@ -0,0 +1,54 @@
+USE AdventureWorks
+GO
+
+--Turn off messages for rows affected
+SET NOCOUNT ON
+
+--Create CJTable
+IF EXISTS(SELECT name FROM sys.tables WHERE name = 'CJTable')
+ DROP TABLE CJTable
+CREATE TABLE CJTable(
+myint int
+)
+
+--Insert two rows to CJTable
+DECLARE @int1 int
+SET @int1 = 2
+INSERT CJTable VALUES(@int1)
+SET @int1 = 4
+INSERT CJTable VALUES(@int1)
+
+--Count rows in joined result set
+SELECT COUNT(SalesPersonID) 'Count of joined rows after adding 2 rows'
+FROM Sales.SalesPerson CROSS JOIN dbo.CJTable
+
+--Cross Join SalesPerson with CJTable and count rows
+--in joined result set
+SELECT TOP 5 SalesPersonID, SalesQuota, MAX(myint) 'MAX(myint)',
+ MIN(myint) 'MIN(myint)'
+FROM Sales.SalesPerson CROSS JOIN dbo.CJTable
+GROUP BY SalesPersonID, SalesQuota
+ORDER BY SalesPersonID
+
+
+
+--Insert another row in CJTable
+SET @int1 = 8
+INSERT CJTable VALUES(@int1)
+
+--Count rows in joined result set
+SELECT COUNT(SalesPersonID) 'Count of joined rows after adding 3 rows'
+FROM Sales.SalesPerson CROSS JOIN dbo.CJTable
+
+--Cross Join SalesPerson with CJTable and count rows
+--in joined result set
+SELECT TOP 5 SalesPersonID, SalesQuota, MAX(myint) 'MAX(myint)',
+ MIN(myint) 'MIN(myint)'
+FROM Sales.SalesPerson CROSS JOIN dbo.CJTable
+GROUP BY SalesPersonID, SalesQuota
+ORDER BY SalesPersonID
+
+--Cleanup by dropping CJTable and restoring display of messages
+--about rows affected
+DROP TABLE CJTable
+SET NOCOUNT OFF
diff --git a/SamplesForChapter06/Chapter06/InnerJoins.sql b/SamplesForChapter06/Chapter06/InnerJoins.sql
new file mode 100644
index 0000000..534063d
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/InnerJoins.sql
@@ -0,0 +1,34 @@
+USE AdventureWorks
+GO
+
+--List foreign key value
+SELECT TOP 5 ProductSubcategoryID, ProductCategoryID,
+ Name 'Subcategory name'
+FROM Production.ProductSubcategory
+ORDER BY ProductSubcategoryID
+
+--List column value from table at which a foreign key points
+SELECT TOP 5 ProductSubcategoryID,
+ Production.ProductCategory.Name 'Category name',
+ Production.ProductSubcategory.Name 'Subcategory name'
+FROM Production.ProductCategory, Production.ProductSubcategory
+WHERE Production.ProductCategory.ProductCategoryID =
+ Production.ProductSubcategory.ProductCategoryID
+ORDER BY Production.ProductSubcategory.ProductSubcategoryID
+
+--List lookup values using table alias qualifiers
+SELECT TOP 5 ProductSubcategoryID, c.Name 'Category name',
+ sc.Name 'Subcategory name'
+FROM Production.ProductCategory c, Production.ProductSubcategory sc
+WHERE c.ProductCategoryID = sc.ProductCategoryID
+ORDER BY sc.ProductSubcategoryID
+
+--List lookup values using JOIN in FROM clause
+SELECT TOP 5 sc.ProductSubcategoryID, c.Name 'Category name',
+ sc.Name 'Subcategory name'
+FROM Production.ProductCategory c
+ JOIN Production.ProductSubcategory sc
+ON c.ProductCategoryID = sc.ProductCategoryID
+ORDER BY sc.ProductSubcategoryID
+
+
diff --git a/SamplesForChapter06/Chapter06/MoreThanTwoJoins.sql b/SamplesForChapter06/Chapter06/MoreThanTwoJoins.sql
new file mode 100644
index 0000000..fa7d163
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/MoreThanTwoJoins.sql
@@ -0,0 +1,43 @@
+USE AdventureWorks
+GO
+
+--Two-table join: Sales.SalesPerson and HumanResources.Employee
+SELECT s.SalesPersonID, s.SalesQuota, e.ContactID
+FROM Sales.SalesPerson s JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+
+--Three-table join: Sales.SalesPerson, HumanResources.Employee,
+--and Person.Contact
+SELECT s.SalesPersonID, s.SalesQuota, c.LastName
+FROM Sales.SalesPerson s JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c ON e.ContactID = c.ContactID
+
+--Four-table join: Sales.SalesPerson, HumanResources.Employee,
+--Person.Contact, and Sales.SalesTerritory; Left Join forces in
+--three presons with null TerritoryID values
+SELECT t.Name 'Territory name', s.SalesPersonID, s.SalesQuota, c.LastName
+FROM Sales.SalesPerson s JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c ON e.ContactID = c.ContactID
+LEFT JOIN Sales.SalesTerritory t ON s.TerritoryID = t.TerritoryID
+ORDER BY s.TerritoryID
+
+--SalesYTD, SalesLastYear, and Percent change by Territory name
+SELECT t.Name 'Territory name',
+ SUM(s.SalesYTD) 'YTD Sales',
+ SUM(s.SalesLastYear) 'Sales last year',
+ CAST(((SUM(s.SalesYTD) - SUM(s.SalesLastYear))/
+ SUM(s.SalesLastYear))*100
+ AS DEC(12,2)) 'Percent change'
+FROM Sales.SalesPerson s JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c ON e.ContactID = c.ContactID
+JOIN Sales.SalesTerritory t ON s.TerritoryID = t.TerritoryID
+GROUP BY t.Name
+ORDER BY t.Name
+
+
+
+
+
diff --git a/SamplesForChapter06/Chapter06/OrderByClauseSamples.sql b/SamplesForChapter06/Chapter06/OrderByClauseSamples.sql
new file mode 100644
index 0000000..5ad2788
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/OrderByClauseSamples.sql
@@ -0,0 +1,50 @@
+USE AdventureWorks
+GO
+
+--Display two ProductCategory columns in
+--unspecified order, by ascending ProductCategoryID
+--order, by descending ProductCategoryID
+--order, by descending Name order
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+ORDER BY ProductCategoryID
+
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+ORDER BY ProductCategoryID DESC
+
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+ORDER BY Name DESC
+GO
+
+--Not sorting and sorting on two columns; trailing
+--TerritoryGroup by DESC moves null column values
+--to the bottom
+SELECT TerritoryGroup, FirstName, LastName, Phone
+FROM Sales.vSalesPerson
+
+
+SELECT TerritoryGroup, FirstName, LastName, Phone
+FROM Sales.vSalesPerson
+ORDER BY TerritoryGroup, LastName
+GO
+
+--Select the bottom two SubTotal column values
+--without and with ties
+SELECT TOP 2 SalesOrderID, SubTotal
+FROM Sales.SalesOrderHeader
+ORDER BY Subtotal ASC
+
+SELECT TOP 2 WITH TIES SalesOrderID, SubTotal
+FROM Sales.SalesOrderHeader
+ORDER BY Subtotal ASC
+
+--SELECT the top two SubTotal column values
+SELECT TOP 2 SalesOrderID, SubTotal
+FROM Sales.SalesOrderHeader
+ORDER BY Subtotal DESC
+
diff --git a/SamplesForChapter06/Chapter06/OuterJoins.sql b/SamplesForChapter06/Chapter06/OuterJoins.sql
new file mode 100644
index 0000000..579af6b
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/OuterJoins.sql
@@ -0,0 +1,59 @@
+USE AdventureWorks
+GO
+
+--Count of Null SubcategoryID values in Product table
+--Count of Non-null SubcategoryID values in Product table
+SELECT Count(*) 'Null SubcategoryID values in Product'
+FROM Production.Product
+WHERE ProductSubcategoryID IS NULL
+
+SELECT Count(*) 'Non-null SubcategoryID values in Product'
+FROM Production.Product
+WHERE ProductSubcategoryID IS NOT NULL
+
+--Join all rows from Product table to matching rows in the
+--ProductSubcategory table based on ProductSubcategoryID
+SELECT TOP 5 ProductID, p.Name 'Product name', sc.Name 'Subcategory name'
+FROM Production.ProductSubcategory sc RIGHT JOIN Production.Product p
+ON sc.ProductSubcategoryID = p.ProductSubcategoryID
+ORDER BY ProductID
+
+--Join matching rows from Product table to all rows in the
+--ProductSubcategory table based on ProductSubcategoryID
+SELECT TOP 5 ProductID, p.Name 'Product name', sc.Name 'Subcategory name'
+FROM Production.ProductSubcategory sc LEFT JOIN Production.Product p
+ON sc.ProductSubcategoryID = p.ProductSubcategoryID
+ORDER BY ProductID
+
+--Count rows with null values for sc.Name in righ join of
+--ProductSubcategory and ProductCategory tables based on their
+--ProductSubcategoryID column values
+SELECT COUNT(ProductID)
+FROM Production.ProductSubcategory sc RIGHT JOIN Production.Product p
+ON sc.ProductSubcategoryID = p.ProductSubcategoryID
+WHERE sc.Name IS NULL
+
+--Join all rows from Product table to rows in the
+--ProductSubcategory table based on ProductSubcategoryID;
+--Sort in descending order based on ProductID
+SELECT TOP 5 ProductID, p.Name 'Product name', sc.Name 'Subcategory name'
+FROM Production.ProductSubcategory sc RIGHT JOIN Production.Product p
+ON sc.ProductSubcategoryID = p.ProductSubcategoryID
+ORDER BY ProductID DESC
+
+--Count rows with non-null values for sc.Name in left join of
+--ProductSubcategory and Product tables based on their
+--ProductSubcategoryID column values
+SELECT COUNT(p.ProductID) 'Product rows with non-null ProductSubcategoryID'
+FROM Production.ProductSubcategory sc LEFT JOIN Production.Product p
+ON sc.ProductSubcategoryID = p.ProductSubcategoryID
+
+--Count of products per ProductSubcategory
+SELECT sc.ProductSubcategoryID, COUNT(p.ProductID) 'Count of products'
+FROM Production.ProductSubcategory sc LEFT JOIN Production.Product p
+ON sc.ProductSubcategoryID = p.ProductSubcategoryID
+GROUP BY sc.ProductSubcategoryID
+ORDER BY sc.ProductSubcategoryID
+
+
+
diff --git a/SamplesForChapter06/Chapter06/RankingRows.sql b/SamplesForChapter06/Chapter06/RankingRows.sql
new file mode 100644
index 0000000..787ab18
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/RankingRows.sql
@@ -0,0 +1,48 @@
+USE AdventureWorks
+GO
+
+--Rows numbered and ordered by SalesYTD
+SELECT FirstName + ' ' + LastName 'Name', SalesYTD, SalesQuota,
+ TerritoryGroup,
+ ROW_NUMBER() OVER(ORDER BY SalesYTD DESC) AS 'RowNumber'
+FROM Sales.vSalesPerson
+
+--Rows numbered and ordered by SalesYTD within
+--TerritoryGroup partitions
+SELECT FirstName + ' ' + LastName 'Name', SalesYTD, SalesQuota,
+ TerritoryGroup,
+ ROW_NUMBER() OVER(PARTITION BY TerritoryGroup
+ ORDER BY SalesYTD DESC) AS 'RowNumber'
+FROM Sales.vSalesPerson
+
+--Rows ranked and ordered by SalesQuota
+--from both the RANK and DENSE_RANK functions
+SELECT FirstName + ' ' + LastName 'Name', SalesYTD, SalesQuota,
+ TerritoryGroup,
+ RANK() OVER(ORDER BY SalesQuota DESC) AS 'Rank',
+ Dense_RANK() OVER(ORDER BY SalesQuota DESC ) AS 'Dense Rank'
+FROM Sales.vSalesPerson
+
+--Rows dense ranked and ordered by SalesYTD within SalesQuota
+SELECT FirstName + ' ' + LastName 'Name', SalesYTD, SalesQuota,
+ TerritoryGroup,
+ Dense_RANK() OVER(ORDER BY SalesQuota DESC,
+ SalesYTD DESC) AS 'Dense Rank'
+FROM Sales.vSalesPerson
+
+
+--Rows partitioned by TerritoryGroup as well as dense ranked
+--and ordered by SalesYTD within SalesQuota
+SELECT FirstName + ' ' + LastName 'Name', SalesYTD, SalesQuota,
+ TerritoryGroup,
+ Dense_RANK() OVER(PARTITION BY TerritoryGroup
+ ORDER BY SalesQuota DESC, SalesYTD DESC) AS 'Dense Rank'
+FROM Sales.vSalesPerson
+
+
+--Rows grouped into quintiles and ordered by SalesYTD
+SELECT FirstName + ' ' + LastName 'Name', SalesYTD, SalesQuota,
+ TerritoryGroup,
+ NTILE(5) OVER(ORDER BY SalesYTD DESC) AS 'NTILE'
+FROM Sales.vSalesPerson
+
diff --git a/SamplesForChapter06/Chapter06/SELECTINTOSamples.sql b/SamplesForChapter06/Chapter06/SELECTINTOSamples.sql
new file mode 100644
index 0000000..ce14273
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/SELECTINTOSamples.sql
@@ -0,0 +1,122 @@
+USE AdventureWorks
+GO
+
+SET NOCOUNT ON
+
+--Copy ProductCategory data to MyCopy
+SELECT *
+INTO MyCopy
+FROM Production.ProductCategory
+
+--Copied data are the same, but have different native sort order
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+
+SELECT ProductCategoryID, Name
+FROM MyCopy
+
+--Data types are the same
+SELECT c.name 'Column name', t.name 'Data type name',
+ c.max_length, c.precision, c.scale,
+ c.is_nullable 'nullable', c.is_identity 'identity'
+FROM sys.columns c
+JOIN sys.types t
+ON c.user_type_id = t.user_type_id
+WHERE object_id = OBJECT_ID('Production.ProductCategory')
+
+SELECT c.name 'Column name', t.name 'Data type name',
+ c.max_length, c.precision, c.scale,
+ c.is_nullable 'nullable', c.is_identity 'identity'
+FROM sys.columns c
+JOIN sys.types t
+ON c.user_type_id = t.user_type_id
+WHERE object_id = OBJECT_ID('MyCopy')
+
+--Indexes are not copied, or created, along with the data
+SELECT name 'Type name', type_desc 'Type description', is_primary_key
+FROM sys.indexes
+WHERE object_id = OBJECT_ID('Production.ProductCategory')
+
+SELECT name 'Type name', type_desc 'Type description', is_primary_key
+FROM sys.indexes
+WHERE object_id = OBJECT_ID('MyCopy')
+
+--output for display in the book
+SELECT ProductCategoryID, CAST(Name AS nvarchar(11)) 'Name'
+FROM Production.ProductCategory
+
+SELECT ProductCategoryID, CAST(Name AS nvarchar(11)) 'Name'
+FROM MyCopy
+
+
+SELECT cast(c.name AS nvarchar(18)) 'Column name',
+ CAST(t.name AS nvarchar(17)) 'Data type name',
+ c.max_length, c.precision, c.scale,
+ c.is_nullable 'nullable', c.is_identity 'identity'
+FROM sys.columns c
+JOIN sys.types t
+ON c.user_type_id = t.user_type_id
+WHERE object_id = OBJECT_ID('Production.ProductCategory')
+
+SELECT cast(c.name AS nvarchar(18)) 'Column name',
+ CAST(t.name AS nvarchar(17)) 'Data type name',
+ c.max_length, c.precision, c.scale,
+ c.is_nullable 'nullable', c.is_identity 'identity'
+FROM sys.columns c
+JOIN sys.types t
+ON c.user_type_id = t.user_type_id
+WHERE object_id = OBJECT_ID('MyCopy')
+
+
+SELECT CAST(name AS nvarchar(37)) 'Type name',
+ CAST(type_desc AS nvarchar(13)) 'Type description', is_primary_key
+FROM sys.indexes
+WHERE object_id = OBJECT_ID('Production.ProductCategory')
+
+SELECT CAST(name AS nvarchar(37)) 'Type name',
+ CAST(type_desc AS nvarchar(13)) 'Type description', is_primary_key
+FROM sys.indexes
+WHERE object_id = OBJECT_ID('MyCopy')
+
+--Clean up
+DROP TABLE MyCopy
+SET NOCOUNT OFF
+
+
+
+SET NOCOUNT ON
+
+--Copy some, but not all, rows
+SELECT *
+INTO MyCopy
+FROM Production.ProductCategory
+WHERE ProductCategoryID > 2
+GO
+
+--Show copied rows
+SELECT ProductCategoryID, Name
+FROM MyCopy
+GO
+
+--Try to copy two more rows to the same table
+SELECT *
+INTO MyCopy
+FROM Production.ProductCategory
+WHERE ProductCategoryID <= 2
+GO
+
+--Confirm table has not changed
+SELECT ProductCategoryID, Name
+FROM MyCopy
+GO
+
+--output for display in the book
+SELECT ProductCategoryID, CAST(Name AS nvarchar(11)) 'Name'
+FROM MyCopy
+GO
+
+--Clean up
+DROP TABLE MyCopy
+SET NOCOUNT OFF
+
+
diff --git a/SamplesForChapter06/Chapter06/SelfJoins.sql b/SamplesForChapter06/Chapter06/SelfJoins.sql
new file mode 100644
index 0000000..ea4e9ca
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/SelfJoins.sql
@@ -0,0 +1,58 @@
+USE AdventureWorks
+GO
+
+--Create this view before running the following samples
+CREATE VIEW dbo.vEmployeeDeptID
+AS
+SELECT HumanResources.Employee.EmployeeID 'EmployeeID',
+ HumanResources.Employee.ManagerID 'ManagerID',
+ HumanResources.EmployeeDepartmentHistory.DepartmentID
+FROM HumanResources.EmployeeDepartmentHistory INNER JOIN
+ HumanResources.Employee
+ ON HumanResources.EmployeeDepartmentHistory.EmployeeID =
+ HumanResources.Employee.EmployeeID
+WHERE HumanResources.EmployeeDepartmentHistory.EndDate IS NULL
+
+--List of Employees by department and the managers to whom they report
+SELECT e2.DepartmentID, e2.ManagerID, e2.EmployeeID
+FROM dbo.vEmployeeDeptID e1 JOIN dbo.vEmployeeDeptID e2
+ON e1.EmployeeID = e2.ManagerID
+ORDER BY e2.DepartmentID, e2.ManagerID
+
+--List of managers for each department
+SELECT DISTINCT e2.DepartmentID, e2.ManagerID
+FROM dbo.vEmployeeDeptID e1 JOIN dbo.vEmployeeDeptID e2
+ON e1.EmployeeID = e2.ManagerID
+ORDER BY e2.DepartmentID, e2.ManagerID
+
+--List of managers outside departments
+SELECT DISTINCT e2.DepartmentID, e2.ManagerID
+FROM dbo.vEmployeeDeptID e1 JOIN dbo.vEmployeeDeptID e2
+ON e1.EmployeeID = e2.ManagerID AND e2.DepartmentID != e1.DepartmentID
+ORDER BY e2.DepartmentID, e2.ManagerID
+
+--List of managers within each department
+SELECT DISTINCT e2.DepartmentID, e2.ManagerID
+FROM dbo.vEmployeeDeptID e1 JOIN dbo.vEmployeeDeptID e2
+ON e1.EmployeeID = e2.ManagerID AND e2.DepartmentID = e1.DepartmentID
+ORDER BY e2.DepartmentID, e2.ManagerID
+
+--List of direct reports to top-level manager who are from
+--other departments
+SELECT DISTINCT e2.DepartmentID, e2.ManagerID, e2.EmployeeID
+FROM dbo.vEmployeeDeptID e1 JOIN dbo.vEmployeeDeptID e2
+ON e1.EmployeeID = e2.ManagerID AND e2.DepartmentID != e1.DepartmentID
+WHERE e1.ManagerID IS NULL
+ORDER BY e2.DepartmentID
+
+
+--list of direct reports to top-level manager who are from
+--the same department
+SELECT e2.DepartmentID, e2.ManagerID, e2.EmployeeID
+FROM dbo.vEmployeeDeptID e1 JOIN dbo.vEmployeeDeptID e2
+ON e1.EmployeeID = e2.ManagerID AND e2.DepartmentID = e1.DepartmentID
+WHERE e1.ManagerID IS NULL
+ORDER BY e2.DepartmentID
+
+
+
diff --git a/SamplesForChapter06/Chapter06/Subqueries.sql b/SamplesForChapter06/Chapter06/Subqueries.sql
new file mode 100644
index 0000000..7447565
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/Subqueries.sql
@@ -0,0 +1,135 @@
+USE AdventureWorks
+GO
+
+
+--For lineitems with an OrderQty of > 12, display average
+--LineTotal for and calculate difference from
+--average for top 10 orders; uncorrelated subquery in list
+SELECT TOP 10 sd1.SalesOrderID 'OrderID', p.Name, sd1.OrderQty,
+ sd1.LineTotal,
+ (SELECT AVG(sd2.Linetotal) FROM sales.SalesOrderDetail sd2
+ WHERE sd2.OrderQty > 12) 'Avg. > 12',
+ LineTotal - (SELECT AVG(Linetotal)
+ FROM sales.SalesOrderDetail sd2
+ WHERE OrderQty > 12) 'Diff. from Avg.'
+FROM Sales.SalesOrderDetail sd1
+JOIN Production.Product p
+ON sd1.ProductID = p.ProductID
+WHERE OrderQty > 12
+ORDER BY LineTotal DESC
+
+--For first twenty-nine orders, display SalesOrderID, ProductID, LineTotal
+--and SubTotal for order; correlated subquery returns order
+--SubTotal values
+SELECT TOP 29 sd.SalesOrderID, sd. ProductID, sd.LineTotal,
+ (SELECT sh.SubTotal FROM sales.SalesOrderHeader sh
+ WHERE sh.SalesOrderID = sd.SalesOrderID) 'SubTotal'
+FROM Sales.SalesOrderDetail sd
+
+--Return above average sales persons; subsquery in
+--WHERE clause with comparison operator
+SELECT s.SalesPersonID,
+ REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') + ' '
+ + c.LastName, ' ', ' ') 'Sales person name',
+ s.SalesYTD
+FROM Sales.SalesPerson s
+JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+WHERE SalesYTD > (SELECT AVG(ss.SalesYTD) FROM Sales.SalesPerson ss)
+ORDER BY s.SalesYTD DESC
+
+--Return the contact info for stores from any of the
+--top 3 sales territories
+SELECT cu.TerritoryID, cu.CustomerID, s.Name,
+ REPLACE(co.FirstName + ' ' + ISNULL(co.MiddleName, '') + ' '
+ + co.LastName, ' ', ' ') 'Store contact',
+ co.Phone
+FROM Sales.Customer cu
+JOIN Sales.Store s
+ON cu.CustomerID = s.CustomerID
+JOIN Sales.StoreContact sc
+ON sc.CustomerID = s.CustomerID
+JOIN Person.Contact co
+ON co.ContactID = sc.ContactID
+WHERE cu.TerritoryID IN (SELECT TOP 3 TerritoryID
+ FROM Sales.SalesPerson
+ GROUP BY TerritoryID
+ ORDER BY SUM(SalesYTD) DESC)
+ORDER BY cu.TerritoryID, cu.CustomerID
+
+--Return count of customers by State/Province within
+--Country/Region; subquery in WHREE clause with IN operator
+--and responding to user input
+DECLARE @alpha AS nvarchar(25)
+SET @alpha = 'A'
+
+SELECT cr.Name 'Country/Region', sp.Name 'State/Province',
+ COUNT(*) 'Customer Count'
+FROM Sales.Customer c
+JOIN Sales.CustomerAddress ca
+ON c.CustomerID = ca.CustomerID
+JOIN Person.Address a
+on a.AddressID = ca.AddressID
+JOIN Person.StateProvince sp
+ON a.StateProvinceID = sp.StateProvinceID
+JOIN Person.CountryRegion cr
+ON cr.CountryRegionCode = sp.CountryRegionCode
+WHERE cr.Name IN (SELECT sq.Name
+ FROM Person.CountryRegion sq
+ WHERE sq.Name LIKE @alpha + '%')
+GROUP BY cr.Name, sp.Name
+ORDER BY COUNT(*) DESC
+
+
+--Return count of customers by territory name within
+--Country/Region; subquery in WHREE clause with IN operator
+--and responding to user input
+DECLARE @alpha AS nvarchar(25)
+SET @alpha = 'U'
+
+SELECT cr.Name 'Country/Region', st.Name 'Territory',
+ COUNT(*) 'Customer Count'
+FROM Sales.Customer c
+JOIN Sales.SalesTerritory st
+ON c.TerritoryID = st.TerritoryID
+JOIN Person.CountryRegion cr
+ON st.CountryRegionCode = cr.CountryRegionCode
+WHERE cr.Name IN (SELECT sq.Name
+ FROM Person.CountryRegion sq
+ WHERE sq.Name LIKE @alpha + '%')
+GROUP BY cr.Name, st.Name
+ORDER BY cr.Name, st.Name
+
+--For book display
+DECLARE @alpha AS nvarchar(25)
+SET @alpha = 'U'
+
+SELECT CAST(cr.Name AS nvarchar(14)) 'Country/Region',
+ CAST(st.Name AS nvarchar(14)) 'Territory',
+ COUNT(*) 'Customer Count'
+FROM Sales.Customer c
+JOIN Sales.SalesTerritory st
+ON c.TerritoryID = st.TerritoryID
+JOIN Person.CountryRegion cr
+ON st.CountryRegionCode = cr.CountryRegionCode
+WHERE cr.Name IN (SELECT sq.Name
+ FROM Person.CountryRegion sq
+ WHERE sq.Name LIKE @alpha + '%')
+GROUP BY cr.Name, st.Name
+ORDER BY cr.Name, st.Name
+
+--Correlated subquery returns rows from sd1 where
+--sd1.LineTotal is greater than average Linetotal for
+--current ProductID in sd1; correlated subquery recomputes
+--a new average LineTotal value for each new row in sd1
+SELECT SalesOrderID, ProductID, LineTotal
+FROM Sales.SalesOrderDetail sd1
+WHERE sd1.LineTotal >
+ (SELECT AVG (sd2.LineTotal)
+ FROM Sales.SalesOrderDetail sd2
+ WHERE sd2.ProductID = sd1.ProductID)
+ORDER BY SalesOrderID, ProductID
+
+
diff --git a/SamplesForChapter06/Chapter06/UsingCTEs.sql b/SamplesForChapter06/Chapter06/UsingCTEs.sql
new file mode 100644
index 0000000..9647378
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/UsingCTEs.sql
@@ -0,0 +1,273 @@
+USE AdventureWorks
+GO
+
+--Use column value from a table pointed at by a foreign key
+WITH ProductItemPrices AS
+(
+SELECT ProductID, AVG(LineTotal) 'AvgPrice'
+FROM Sales.SalesOrderDetail
+GROUP BY ProductID
+)
+
+SELECT p.Name, pp.AvgPrice
+FROM ProductItemPrices pp
+JOIN
+Production.Product p
+ON
+pp.ProductID = p.ProductID
+ORDER BY p.Name
+
+SELECT * FROM ProductItemPrices
+GO
+
+--Display rows from SalesOrderDetail table with a LineTotal
+--value greater than the average for all Linetotal values with
+--the same ProductID value
+WITH ProductItemPrices AS
+(
+SELECT ProductID, AVG(LineTotal) 'AvgPrice'
+FROM Sales.SalesOrderDetail
+GROUP BY ProductID
+)
+
+SELECT TOP 29 sd.SalesOrderID, sd.ProductID, sd.LineTotal, pp.AvgPrice
+FROM Sales.SalesOrderDetail sd
+JOIN
+ProductItemPrices pp
+ON pp.ProductID = sd.ProductID
+WHERE sd.LineTotal > pp.AvgPrice
+ORDER BY sd.SalesOrderID, sd.ProductID
+
+
+--Return EmployeeID along with first and last name of employees
+--not reporting to any other employee
+SELECT e.EmployeeID, c.FirstName, c.LastName
+FROM HumanResources.Employee e
+JOIN Person.Contact c
+ON e.ContactID = c.ContactID
+where ManagerID IS NULL
+
+--Specify top level EmployeeID for direct reports
+DECLARE @TopEmp as int
+SET @TopEmp = 109;
+
+--Names and departments for direct reports to
+--EmployeeID = @TopEmp; calculate employee name
+WITH Empcte(empid, empname, mgrid, dName, lvl)
+AS
+(
+
+ -- Anchor row
+ SELECT e.EmployeeID,
+ REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') +
+ ' ' + c.LastName, ' ', ' ') 'Employee name',
+ e.ManagerID, dn.Name, 0
+ FROM Person.Contact c
+ JOIN HumanResources.Employee e
+ ON e.ContactID = c.ContactID
+ JOIN HumanResources.EmployeeDepartmentHistory d
+ ON d.EmployeeID = e.EmployeeID
+ JOIN HumanResources.Department dn
+ ON dn.DepartmentID = d.DepartmentID
+ WHERE e.EmployeeID = @TopEmp
+ UNION ALL
+
+ -- Recursive rows
+
+ SELECT e.EmployeeID,
+ REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') +
+ ' ' + c.LastName, ' ', ' ') 'Employee name',
+ e.ManagerID, dn.Name, a.lvl+1
+ FROM (Person.Contact c
+ JOIN HumanResources.Employee e
+ ON e.ContactID = c.ContactID
+ JOIN HumanResources.EmployeeDepartmentHistory d
+ ON d.EmployeeID = e.EmployeeID
+ JOIN HumanResources.Department dn
+ ON dn.DepartmentID = d.DepartmentID)
+ JOIN Empcte a
+ ON e.ManagerID = a.empid)
+
+--Order and display result set from CTE
+SELECT *
+FROM Empcte
+WHERE lvl <= 1
+ORDER BY lvl, mgrid, empid
+
+--Alternate statement using MAXRECURSION;
+--must position immediately after Empcte to work
+
+SELECT *
+FROM Empcte
+OPTION (MAXRECURSION 1)
+
+
+--For display in book
+DECLARE @TopEmp as int
+SET @TopEmp = 109;
+
+--Names and departments for direct reports to
+--EmployeeID = @TopEmp; calculate employee name
+WITH Empcte(empid, empname, mgrid, dName, lvl)
+AS
+(
+
+ -- Anchor row
+ SELECT e.EmployeeID,
+ CAST(REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') +
+ ' ' + c.LastName, ' ', ' ') AS nvarchar(20)) 'Employee name',
+ e.ManagerID,
+ CAST(dn.Name AS nvarchar(20)), 0
+ FROM Person.Contact c
+ JOIN HumanResources.Employee e
+ ON e.ContactID = c.ContactID
+ JOIN HumanResources.EmployeeDepartmentHistory d
+ ON d.EmployeeID = e.EmployeeID
+ JOIN HumanResources.Department dn
+ ON dn.DepartmentID = d.DepartmentID
+ WHERE e.EmployeeID = @TopEmp
+ UNION ALL
+
+ -- Recursive rows
+
+ SELECT e.EmployeeID,
+ CAST(REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') +
+ ' ' + c.LastName, ' ', ' ') AS nvarchar(20)) 'Employee name',
+ e.ManagerID,
+ CAST(dn.Name AS nvarchar(20)), a.lvl+1
+ FROM (Person.Contact c
+ JOIN HumanResources.Employee e
+ ON e.ContactID = c.ContactID
+ JOIN HumanResources.EmployeeDepartmentHistory d
+ ON d.EmployeeID = e.EmployeeID
+ JOIN HumanResources.Department dn
+ ON dn.DepartmentID = d.DepartmentID)
+ JOIN Empcte a
+ ON e.ManagerID = a.empid)
+
+--Order and display result set from CTE
+SELECT *
+FROM Empcte
+WHERE lvl <= 1
+ORDER BY lvl, mgrid, empid
+
+--Alternate statement using MAXRECURSION;
+--must position immediately after Empcte to work
+SELECT *
+FROM Empcte
+OPTION (MAXRECURSION 1)
+
+
+--Specify top level EmployeeID for direct reports; decode
+--mgrid column value from CTE
+DECLARE @TopEmp as int
+SET @TopEmp = 12;
+
+--Names and departments for direct reports to
+--EmployeeID = @TopEmp; calculate employee name
+WITH Empcte(empid, empname, mgrid, dName, lvl)
+AS
+(
+
+ -- Anchor row
+ SELECT e.EmployeeID,
+ REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') +
+ ' ' + c.LastName, ' ', ' ') 'Employee name',
+ e.ManagerID, dn.Name, 0
+ FROM Person.Contact c
+ JOIN HumanResources.Employee e
+ ON e.ContactID = c.ContactID
+ JOIN HumanResources.EmployeeDepartmentHistory d
+ ON d.EmployeeID = e.EmployeeID
+ JOIN HumanResources.Department dn
+ ON dn.DepartmentID = d.DepartmentID
+ WHERE e.EmployeeID = @TopEmp
+ UNION ALL
+
+ -- Recursive rows
+
+ SELECT e.EmployeeID,
+ REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') +
+ ' ' + c.LastName, ' ', ' ') 'Employee name',
+ e.ManagerID, dn.Name, a.lvl+1
+ FROM (Person.Contact c
+ JOIN HumanResources.Employee e
+ ON e.ContactID = c.ContactID
+ JOIN HumanResources.EmployeeDepartmentHistory d
+ ON d.EmployeeID = e.EmployeeID
+ JOIN HumanResources.Department dn
+ ON dn.DepartmentID = d.DepartmentID)
+ JOIN Empcte a
+ ON e.ManagerID = a.empid)
+
+--Calculate employee name corresponding to mgrid
+SELECT empid, empname, mgrid,
+ REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') + ' '
+ + c.LastName, ' ', ' ')
+ 'Manager''s name', dName, lvl
+FROM Empcte ecte
+JOIN HumanResources.Employee e
+ON ecte.mgrid = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+ORDER BY lvl, mgrid, dname, empid
+
+
+--For book display
+--Specify top level EmployeeID for direct reports; decode
+--mgrid column value from CTE
+DECLARE @TopEmp as int
+SET @TopEmp = 12;
+
+--Names and departments for direct reports to
+--EmployeeID = @TopEmp; calculate employee name
+WITH Empcte(empid, empname, mgrid, dName, lvl)
+AS
+(
+
+ -- Anchor row
+ SELECT e.EmployeeID,
+ CAST(REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') +
+ ' ' + c.LastName, ' ', ' ') AS nvarchar(20)) 'Employee name',
+ e.ManagerID,
+ CAST(dn.Name AS nvarchar(20)), 0
+ FROM Person.Contact c
+ JOIN HumanResources.Employee e
+ ON e.ContactID = c.ContactID
+ JOIN HumanResources.EmployeeDepartmentHistory d
+ ON d.EmployeeID = e.EmployeeID
+ JOIN HumanResources.Department dn
+ ON dn.DepartmentID = d.DepartmentID
+ WHERE e.EmployeeID = @TopEmp
+ UNION ALL
+
+ -- Recursive rows
+
+ SELECT e.EmployeeID,
+ CAST(REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') +
+ ' ' + c.LastName, ' ', ' ') AS nvarchar(20)) 'Employee name',
+ e.ManagerID,
+ CAST(dn.Name AS nvarchar(20)), a.lvl+1
+ FROM (Person.Contact c
+ JOIN HumanResources.Employee e
+ ON e.ContactID = c.ContactID
+ JOIN HumanResources.EmployeeDepartmentHistory d
+ ON d.EmployeeID = e.EmployeeID
+ JOIN HumanResources.Department dn
+ ON dn.DepartmentID = d.DepartmentID)
+ JOIN Empcte a
+ ON e.ManagerID = a.empid)
+
+--Calculate employee name corresponding to mgrid
+SELECT empid, empname, mgrid,
+ CAST(REPLACE(c.FirstName + ' ' + ISNULL(c.MiddleName, '') + ' '
+ + c.LastName, ' ', ' ') AS nvarchar(18))
+ 'Manager''s name', dName, lvl
+FROM Empcte ecte
+JOIN HumanResources.Employee e
+ON ecte.mgrid = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+ORDER BY lvl, mgrid, empid
+
+
diff --git a/SamplesForChapter06/Chapter06/UsingPIVOTUNPIVOT.sql b/SamplesForChapter06/Chapter06/UsingPIVOTUNPIVOT.sql
new file mode 100644
index 0000000..939dd21
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/UsingPIVOTUNPIVOT.sql
@@ -0,0 +1,136 @@
+USE Adventureworks
+GO
+
+SELECT ShiftID, Name
+FROM HumanResources.Shift
+
+SELECT EmployeeID, ShiftID, Name
+FROM HumanResources.Employee, HumanResources.Department
+WHERE Employee.DepartmentID = Department.DepartmentID
+
+--Compute the number of employees by
+--department name and shift
+SELECT Name, [1] AS 'Day', [2] AS 'Evening',
+ [3] AS 'Night'
+FROM
+(SELECT e.EmployeeID, edh.ShiftID, d.Name
+FROM HumanResources.Employee e
+JOIN HumanResources.EmployeeDepartmentHistory edh
+ON e.EmployeeID = edh.EmployeeID
+JOIN HumanResources.Department d
+ON edh.DepartmentID = d.DepartmentID) st
+PIVOT
+(
+COUNT (EmployeeID)
+FOR ShiftID IN
+( [1], [2], [3])
+) AS spvt
+ORDER BY Name
+
+--For display in book
+SELECT Name, [1] AS 'Day', [2] AS 'Evening',
+ [3] AS 'Night'
+FROM
+(SELECT e.EmployeeID, edh.ShiftID, CAST(d.Name AS nvarchar(26)) 'Name'
+FROM HumanResources.Employee e
+JOIN HumanResources.EmployeeDepartmentHistory edh
+ON e.EmployeeID = edh.EmployeeID
+JOIN HumanResources.Department d
+ON edh.DepartmentID = d.DepartmentID) st
+PIVOT
+(
+COUNT (EmployeeID)
+FOR ShiftID IN
+( [1], [2], [3])
+) AS spvt
+ORDER BY Name
+
+
+IF EXISTS(SELECT name FROM sys.tables WHERE name = 'pvt')
+DROP TABLE pvt
+GO
+
+--Create a table that saves the result of a pivot with employee
+--names instead of numbers for column values
+SELECT VName, [164] 'Mikael Q Sandberg', [198] 'Arvind B Rao',
+ [223] 'Linda P Meisner', [231] 'Fukiko J Ogisu'
+INTO pvt
+FROM
+(SELECT PurchaseOrderID, EmployeeID, v.Name as 'VName'
+FROM Purchasing.PurchaseOrderHeader h
+JOIN Purchasing.Vendor v
+ON h.VendorID = v.VendorID) p
+PIVOT
+(
+COUNT (PurchaseOrderID)
+FOR EmployeeID IN
+( [164], [198], [223], [231], [233] )
+) pvt
+ORDER BY VName
+GO
+
+--Show an excerpt FOR VName starting with A
+SELECT TOP 5 * FROM pvt
+WHERE VName LIKE 'A%'
+GO
+
+--For display in book
+SELECT TOP 5 CAST(VName AS NVARCHAR(22)) 'VName',
+ [Mikael Q Sandberg], [Arvind B Rao],
+ [Linda P Meisner], [Fukiko J Ogisu]
+FROM pvt
+WHERE VName LIKE 'A%'
+GO
+
+--VendorID for Advanced Bicycles is 32
+--Four PurchaseOrderID column values exist in PurchaseOrderHeader
+--with VendorID values of 32 and EmployeeID values of 164
+SELECT VendorID, Name FROM Purchasing.Vendor WHERE Name = 'Advanced Bicycles'
+SELECT PurchaseOrderID FROM Purchasing.PurchaseOrderHeader WHERE VendorID = 32 and EmployeeID = 164
+
+--Unpivot values
+SELECT TOP 8 VName, Employee, OrdCnt
+FROM
+(SELECT VName, [Mikael Q Sandberg], [Arvind B Rao],
+ [Linda P Meisner], [Fukiko J Ogisu]
+FROM pvt) p
+UNPIVOT
+(OrdCnt FOR Employee IN ([Mikael Q Sandberg],
+[Arvind B Rao], [Linda P Meisner], [Fukiko J Ogisu])
+)AS unpvt
+GO
+
+--For display in book
+SELECT TOP 8 CAST(VName AS nvarchar(28)) 'VName', CAST(Employee AS nvarchar(18)) 'Employee', OrdCnt
+FROM
+ (SELECT VName, [Mikael Q Sandberg], [Arvind B Rao],
+ [Linda P Meisner], [Fukiko J Ogisu]
+ FROM pvt) p
+ UNPIVOT
+ (OrdCnt FOR Employee IN
+ ([Mikael Q Sandberg], [Arvind B Rao],
+ [Linda P Meisner], [Fukiko J Ogisu])
+ )AS unpvt
+GO
+
+
+--Query to check unpivoted values
+SELECT TOP 2 *
+FROM pvt
+ORDER BY VName ASC
+GO
+
+--For display in book
+SELECT TOP 2 CAST(VName AS NVARCHAR(22)) 'VName',
+ [Mikael Q Sandberg], [Arvind B Rao],
+ [Linda P Meisner], [Fukiko J Ogisu]
+FROM pvt
+ORDER BY VName ASC
+GO
+
+
+
+IF EXISTS(SELECT name FROM sys.tables WHERE name = 'pvt')
+DROP TABLE pvt
+GO
+
diff --git a/SamplesForChapter06/Chapter06/UsingUNIONOperators.sql b/SamplesForChapter06/Chapter06/UsingUNIONOperators.sql
new file mode 100644
index 0000000..1f753cc
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/UsingUNIONOperators.sql
@@ -0,0 +1,85 @@
+USE AdventureWorks
+GO
+
+--Using ALL can force duplicates into the result set
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+WHERE Name LIKE 'C%'
+UNION ALL
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+WHERE Name LIKE 'Cl%'
+
+--By default, UNION removes duplicates
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+WHERE Name LIKE 'C%'
+UNION
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+WHERE Name LIKE 'Cl%'
+
+
+--You can add marker columns and sort overall
+USE Northwind
+GO
+
+SELECT TOP 3 ContactName, Phone, ISNULL(Fax, '') 'Fax',
+ 'Customer' 'ContactType'
+FROM Customers
+UNION
+SELECT TOP 3 FirstName + ' ' + LastName, HomePhone, '',
+ 'Employee' 'ContactType'
+FROM Employees
+UNION
+SELECT TOP 3 CompanyName , Phone, '',
+ 'Shipper' 'ContactType'
+FROM Shippers
+ORDER BY ContactType
+
+--For display in book
+SELECT TOP 3 CAST(ContactName AS nvarchar(16)) 'ContactName',
+ CAST(Phone AS nvarchar(14)) 'Phone',
+ CAST(ISNULL(Fax, '') AS nvarchar(14)) 'Fax',
+ CAST('Customer' AS nvarchar(8)) 'ContactType'
+FROM Customers
+UNION
+SELECT TOP 3 CAST(FirstName + ' ' + LastName AS nvarchar(16)) 'ContactName',
+ CAST(HomePhone AS nvarchar(14)) 'Phone',
+ CAST('' AS nvarchar(14)) 'Fax',
+ CAST('Employee' AS nvarchar(8)) 'ContactType'
+FROM Employees
+UNION
+SELECT TOP 3 CAST(CompanyName AS nvarchar(16)) 'ContactName',
+ CAST(Phone AS nvarchar(14)) 'Phone',
+ CAST('' AS nvarchar(14)) 'Fax',
+ CAST('Shipper' AS nvarchar(8)) 'ContactType'
+FROM Shippers
+ORDER BY ContactType
+
+
+--SELECT/UNION into a new table
+USE AdventureWorks
+GO
+
+SELECT ProductCategoryID, Name
+INTO MyCopy
+FROM Production.ProductCategory
+WHERE Name LIKE 'C%'
+UNION ALL
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+WHERE Name LIKE 'C%' OR Name LIKE 'B%'
+
+--Display table
+SELECT ProductCategoryID, Name 'Name'
+FROM MyCopy
+
+SELECT ProductCategoryID, CAST(Name AS nvarchar(11)) 'Name'
+FROM MyCopy
+
+
+--Clean up
+DROP TABLE MyCopy
+SET NOCOUNT OFF
+
diff --git a/SamplesForChapter06/Chapter06/vEmployeeDeptID.sql b/SamplesForChapter06/Chapter06/vEmployeeDeptID.sql
new file mode 100644
index 0000000..1f55ffb
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/vEmployeeDeptID.sql
@@ -0,0 +1,15 @@
+
+--Not necessary the first time that you run the sample
+--DROP VIEW dbo.vEmployeeDeptID
+--GO
+
+CREATE VIEW dbo.vEmployeeDeptID
+AS
+SELECT HumanResources.Employee.EmployeeID 'EmployeeID',
+ HumanResources.Employee.ManagerID 'ManagerID',
+ HumanResources.EmployeeDepartmentHistory.DepartmentID
+FROM HumanResources.EmployeeDepartmentHistory INNER JOIN
+ HumanResources.Employee
+ ON HumanResources.EmployeeDepartmentHistory.EmployeeID =
+ HumanResources.Employee.EmployeeID
+WHERE HumanResources.EmployeeDepartmentHistory.EndDate IS NULL
diff --git a/SamplesForChapter06/Chapter06/vEmployeeDeptID.txt b/SamplesForChapter06/Chapter06/vEmployeeDeptID.txt
new file mode 100644
index 0000000..937bba9
--- /dev/null
+++ b/SamplesForChapter06/Chapter06/vEmployeeDeptID.txt
@@ -0,0 +1,12 @@
+CREATE VIEW dbo.vEmployeeDeptID
+AS
+SELECT HumanResources.Employee.EmployeeID, HumanResources.Employee.ManagerID, HumanResources.EmployeeDepartmentHistory.DepartmentID,
+ HumanResources.Employee.NationalIDNumber, HumanResources.Employee.ContactID, HumanResources.Employee.LoginID,
+ HumanResources.Employee.Title, HumanResources.Employee.BirthDate, HumanResources.Employee.MaritalStatus,
+ HumanResources.Employee.Gender, HumanResources.Employee.HireDate, HumanResources.Employee.SalariedFlag,
+ HumanResources.Employee.VacationHours, HumanResources.Employee.SickLeaveHours, HumanResources.Employee.CurrentFlag,
+ HumanResources.Employee.rowguid, HumanResources.Employee.ModifiedDate
+FROM HumanResources.EmployeeDepartmentHistory INNER JOIN
+ HumanResources.Employee ON HumanResources.EmployeeDepartmentHistory.EmployeeID = HumanResources.Employee.EmployeeID
+
+GO
\ No newline at end of file
diff --git a/SamplesForChapter07/Chapter07/FNUserDefinedFunctions.sql b/SamplesForChapter07/Chapter07/FNUserDefinedFunctions.sql
new file mode 100644
index 0000000..585ba71
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/FNUserDefinedFunctions.sql
@@ -0,0 +1,68 @@
+USE AdventureWorks
+GO
+
+--Create function to count the number of customers
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'FN' AND schema_id = SCHEMA_ID('dbo')
+ AND name = 'ufnCntCustomers')
+ DROP FUNCTION dbo.ufnCntCustomers
+GO
+
+
+CREATE FUNCTION dbo.ufnCntCustomers()
+RETURNS int
+AS
+BEGIN
+ RETURN (SELECT COUNT(*) FROM Sales.Customer)
+END
+GO
+
+--Invoke the function to count customers
+SELECT dbo.ufnCntCustomers() '# of Customers'
+GO
+
+--Drop ufnIsOdd function
+DROP FUNCTION dbo.ufnCntCustomers
+GO
+
+--Create function to determine if a
+--number (@n) is odd
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'FN' AND schema_id = SCHEMA_ID('dbo')
+ AND name = 'ufnIsOdd')
+ DROP FUNCTION dbo.ufnIsOdd
+GO
+
+CREATE FUNCTION dbo.ufnIsOdd (@n int)
+RETURNS bit
+AS
+BEGIN
+ RETURN (@n % 2)
+END
+GO
+
+--Use ufnIsOdd function
+DECLARE @numb int
+SELECT @numb 'Number', dbo.ufnIsOdd (@numb) 'Is_odd = 1'
+SET @numb = 6
+SELECT @numb 'Number', dbo.ufnIsOdd (@numb) 'Is_odd = 1'
+SET @numb = 7
+SELECT @numb 'Number', dbo.ufnIsOdd (@numb) 'Is_odd = 1'
+
+--Use ufnIsOdd for computed column
+SELECT TOP 5 SalesPersonID, FirstName, LastName,
+ dbo.ufnIsOdd(SalesPersonID) 'ID_odd = 1'
+FROM Sales.vSalesPerson
+
+--For display in book
+SELECT TOP 5 SalesPersonID, CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(8)) 'LastName',
+ dbo.ufnIsOdd(SalesPersonID) 'ID_odd = 1'
+FROM Sales.vSalesPerson
+
+--Drop ufnIsOdd function
+DROP FUNCTION dbo.ufnIsOdd
+GO
+
diff --git a/SamplesForChapter07/Chapter07/IFUserDefinedFunctions.sql b/SamplesForChapter07/Chapter07/IFUserDefinedFunctions.sql
new file mode 100644
index 0000000..2d28c0f
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/IFUserDefinedFunctions.sql
@@ -0,0 +1,160 @@
+USE AdventureWorks
+GO
+
+--Create function to list all sales persons
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'IF' AND schema_id = SCHEMA_ID('dbo')
+ AND name = 'uifListAllSalesPersons')
+ DROP FUNCTION dbo.uifListAllSalesPersons
+GO
+
+CREATE FUNCTION dbo.uifListAllSalesPersons()
+RETURNS table
+AS
+RETURN (
+ SELECT s.SalesPersonID, c.FirstName, c.LastName,
+ st.Name 'TerritoryName', c.Phone
+ FROM Sales.SalesPerson s
+ JOIN HumanResources.Employee e
+ ON s.SalesPersonID = e.EmployeeID
+ JOIN Person.Contact c
+ ON e.ContactID = c.ContactID
+ LEFT JOIN Sales.SalesTerritory st
+ ON s.TerritoryID = st.TerritoryID)
+GO
+
+--Invoke the function to list all sales persons
+SELECT TOP 3 * FROM uifListAllSalesPersons()
+GO
+
+--For display in book
+SELECT TOP 3 SalesPersonID,
+ CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(17)) 'LastName',
+ CAST(TerritoryName AS nvarchar(14)) 'TerritoryName',
+ CAST(Phone AS nvarchar(19)) 'Phone'
+FROM uifListAllSalesPersons()
+
+
+--Drop inline function
+DROP FUNCTION dbo.uifListAllSalesPersons
+GO
+
+
+--Create function to list sales persons from a territory
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'IF' AND schema_id = SCHEMA_ID('dbo')
+ AND name = 'uifListSalesPersonsInTerritory')
+ DROP FUNCTION dbo.uifListSalesPersonsInTerritory
+GO
+
+CREATE FUNCTION
+ dbo.uifListSalesPersonsInTerritory(@t AS nvarchar(50))
+RETURNS table
+AS
+RETURN (
+ SELECT SalesPersonID, FirstName, LastName,
+ TerritoryName, Phone
+ FROM Sales.vSalesPerson
+ WHERE TerritoryName = @t)
+GO
+
+--Invoke the function to list sales persons for a territory
+DECLARE @t as nvarchar(50)
+
+SET @t = 'Canada'
+SELECT * FROM dbo.uifListSalesPersonsInTerritory(@t)
+
+--For display in book
+SELECT TOP 3 SalesPersonID,
+ CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(12)) 'LastName',
+ CAST(TerritoryName AS nvarchar(13)) 'TerritoryName',
+ CAST(Phone AS nvarchar(12)) 'Phone'
+FROM dbo.uifListSalesPersonsInTerritory(@t)
+
+SET @t = 'Northwest'
+SELECT * FROM uifListSalesPersonsInTerritory(@t)
+
+--For display in book
+SELECT TOP 3 SalesPersonID,
+ CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(12)) 'LastName',
+ CAST(TerritoryName AS nvarchar(13)) 'TerritoryName',
+ CAST(Phone AS nvarchar(12)) 'Phone'
+FROM dbo.uifListSalesPersonsInTerritory(@t)
+GO
+
+--Drop inline function
+DROP FUNCTION dbo.uifListSalesPersonsInTerritory
+GO
+
+
+--Create function to list sales persons from a territory
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'IF' AND schema_id = SCHEMA_ID('dbo')
+ AND name = 'uifListSalesPersonsInTerritory')
+ DROP FUNCTION dbo.uifListSalesPersonsInTerritory
+GO
+
+CREATE FUNCTION
+ dbo.uifListSalesPersonsInTerritory(@t AS nvarchar(50))
+RETURNS table
+AS
+RETURN (
+ SELECT SalesPersonID, FirstName, LastName,
+ TerritoryName, Phone
+ FROM Sales.vSalesPerson
+ WHERE TerritoryName = @t)
+GO
+
+--Update and restore LastName column value through IF udf
+DECLARE @t as nvarchar(50)
+SET @t = 'Canada'
+SELECT * FROM dbo.uifListSalesPersonsInTerritory(@t)
+
+--For display in book
+SELECT TOP 3 SalesPersonID,
+ CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(12)) 'LastName',
+ CAST(TerritoryName AS nvarchar(13)) 'TerritoryName',
+ CAST(Phone AS nvarchar(12)) 'Phone'
+FROM dbo.uifListSalesPersonsInTerritory(@t)
+
+
+UPDATE dbo.uifListSalesPersonsInTerritory(@t)
+SET LastName = 'Vargax'
+WHERE SalesPersonID = 278
+
+SELECT * FROM dbo.uifListSalesPersonsInTerritory(@t)
+
+--For display in book
+SELECT TOP 3 SalesPersonID,
+ CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(12)) 'LastName',
+ CAST(TerritoryName AS nvarchar(13)) 'TerritoryName',
+ CAST(Phone AS nvarchar(12)) 'Phone'
+FROM dbo.uifListSalesPersonsInTerritory(@t)
+
+UPDATE dbo.uifListSalesPersonsInTerritory(@t)
+SET LastName = 'Vargas'
+WHERE SalesPersonID = 278
+
+SELECT * FROM dbo.uifListSalesPersonsInTerritory(@t)
+
+--For display in book
+SELECT TOP 3 SalesPersonID,
+ CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(12)) 'LastName',
+ CAST(TerritoryName AS nvarchar(13)) 'TerritoryName',
+ CAST(Phone AS nvarchar(12)) 'Phone'
+FROM dbo.uifListSalesPersonsInTerritory(@t)
+
+--Drop inline function
+DROP FUNCTION dbo.uifListSalesPersonsInTerritory
+
+
+
diff --git a/SamplesForChapter07/Chapter07/NewClasses.txt b/SamplesForChapter07/Chapter07/NewClasses.txt
new file mode 100644
index 0000000..5c9448d
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/NewClasses.txt
@@ -0,0 +1,2 @@
+2 Learning Visual Basic for DBAs
+3 Learning Visual Web Developer Express for DBAs
\ No newline at end of file
diff --git a/SamplesForChapter07/Chapter07/ProSSEAppsCh07.mdf b/SamplesForChapter07/Chapter07/ProSSEAppsCh07.mdf
new file mode 100644
index 0000000..c21dfd0
Binary files /dev/null and b/SamplesForChapter07/Chapter07/ProSSEAppsCh07.mdf differ
diff --git a/SamplesForChapter07/Chapter07/ProSSEAppsCh07_log.LDF b/SamplesForChapter07/Chapter07/ProSSEAppsCh07_log.LDF
new file mode 100644
index 0000000..bbb3409
Binary files /dev/null and b/SamplesForChapter07/Chapter07/ProSSEAppsCh07_log.LDF differ
diff --git a/SamplesForChapter07/Chapter07/StoredProcInputParameters.sql b/SamplesForChapter07/Chapter07/StoredProcInputParameters.sql
new file mode 100644
index 0000000..eedca84
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/StoredProcInputParameters.sql
@@ -0,0 +1,297 @@
+USE AdventureWorks
+GO
+
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalesPersonInATerritory')
+ DROP PROCEDURE usp_SalesPersonInATerritory
+GO
+
+--Create a stored proc with an input parameter
+CREATE PROCEDURE usp_SalesPersonInATerritory
+@TID int
+AS
+SELECT s.TerritoryID, c.LastName, c.Phone
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+WHERE s.TerritoryID = @TID
+GO
+
+--Run the stored proc with two different
+--parameter values
+EXEC usp_SalesPersonInATerritory 1
+GO
+EXEC usp_SalesPersonInATerritory 2
+GO
+
+--Failing to input a parameter can cause a failure
+--EXEC usp_SalesPersonInATerritory
+--GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalesPersonInATerritory
+GO
+
+--For display in book
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalesPersonInATerritory')
+ DROP PROCEDURE usp_SalesPersonInATerritory
+GO
+
+--Create a stored proc with an input parameter
+CREATE PROCEDURE usp_SalesPersonInATerritory
+@TID int
+AS
+SELECT s.TerritoryID,
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ CAST(c.Phone AS nvarchar(19)) 'Phone'
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+WHERE s.TerritoryID = @TID
+GO
+
+--Run the stored proc with two different
+--parameter values
+EXEC usp_SalesPersonInATerritory 1
+GO
+EXEC usp_SalesPersonInATerritory 2
+GO
+
+--Failing to input a parameter can cause a failure
+--EXEC usp_SalesPersonInATerritory
+--GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalesPersonInATerritory
+GO
+
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalesPersonInATerritory')
+ DROP PROCEDURE usp_SalesPersonInATerritory
+GO
+
+--Create a stored proc with an input parameter and
+--a non-null default value
+CREATE PROCEDURE usp_SalesPersonInATerritory
+@TID int = 2
+AS
+SELECT s.TerritoryID, c.LastName, c.Phone
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+WHERE s.TerritoryID = @TID
+GO
+
+--Run the stored proc with two different
+--parameter values
+EXEC usp_SalesPersonInATerritory 1
+GO
+
+--Failing to input a parameter can causeS
+--usp_SalesPersonInATerritory to use defaul
+--parameter value
+EXEC usp_SalesPersonInATerritory
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalesPersonInATerritory
+GO
+
+--For display in book
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalesPersonInATerritory')
+ DROP PROCEDURE usp_SalesPersonInATerritory
+GO
+
+--Create a stored proc with an input parameter and
+--a non-null default value
+CREATE PROCEDURE usp_SalesPersonInATerritory
+@TID int = 3
+AS
+SELECT s.TerritoryID,
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ CAST(c.Phone AS nvarchar(19)) 'Phone'
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+WHERE s.TerritoryID = @TID
+GO
+
+--Run the stored proc with two different
+--parameter values
+EXEC usp_SalesPersonInATerritory 1
+GO
+
+--Failing to input a parameter can causeS
+--usp_SalesPersonInATerritory to use defaul
+--parameter value
+EXEC usp_SalesPersonInATerritory
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalesPersonInATerritory
+GO
+
+
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalesPersonInATerritoryOrNot')
+ DROP PROCEDURE usp_SalesPersonInATerritoryOrNot
+GO
+
+--Create a stored proc with an input parameter,
+--default value assignment, and IF statement
+CREATE PROCEDURE usp_SalesPersonInATerritoryOrNot
+@TID int = NULL
+AS
+IF @TID IS NOT NULL
+ SELECT s.TerritoryID, c.LastName, c.Phone
+ FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ ON s.SalesPersonID = e.EmployeeID
+ JOIN Person.Contact c
+ ON c.ContactID = e.ContactID
+ WHERE s.TerritoryID = @TID
+ELSE
+ SELECT s.TerritoryID, c.LastName, c.Phone
+ FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ ON s.SalesPersonID = e.EmployeeID
+ JOIN Person.Contact c
+ ON c.ContactID = e.ContactID
+ WHERE s.TerritoryID IS NULL
+GO
+
+--Run the stored proc with three different
+--parameter values, including NULL
+EXEC usp_SalesPersonInATerritoryOrNot 1
+GO
+EXEC usp_SalesPersonInATerritoryOrNot NULL
+GO
+EXEC usp_SalesPersonInATerritoryOrNot
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalesPersonInATerritoryOrNot
+GO
+
+--For display in book
+--Drop prior instance of stored proc
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalesPersonInATerritoryOrNot')
+ DROP PROCEDURE usp_SalesPersonInATerritoryOrNot
+GO
+
+--Create a stored proc with an input parameter,
+--default value assignment, and IF statement
+CREATE PROCEDURE usp_SalesPersonInATerritoryOrNot
+@TID int = NULL
+AS
+IF @TID IS NOT NULL
+ SELECT s.TerritoryID,
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ CAST(c.Phone AS nvarchar(19)) 'Phone'
+ FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ ON s.SalesPersonID = e.EmployeeID
+ JOIN Person.Contact c
+ ON c.ContactID = e.ContactID
+ WHERE s.TerritoryID = @TID
+ELSE
+ SELECT s.TerritoryID,
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ CAST(c.Phone AS nvarchar(19)) 'Phone'
+ FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ ON s.SalesPersonID = e.EmployeeID
+ JOIN Person.Contact c
+ ON c.ContactID = e.ContactID
+ WHERE s.TerritoryID IS NULL
+GO
+
+--Run the stored proc with three different
+--parameter values, including NULL
+EXEC usp_SalesPersonInATerritoryOrNot 1
+GO
+EXEC usp_SalesPersonInATerritoryOrNot NULL
+GO
+EXEC usp_SalesPersonInATerritoryOrNot
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalesPersonInATerritoryOrNot
+GO
+
+
+--Create function to determine if a
+--number (@n) is odd
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'FN' AND schema_id = 1
+ AND name = 'ufnIsOdd')
+ DROP FUNCTION dbo.ufnIsOdd
+GO
+
+CREATE FUNCTION dbo.ufnIsOdd (@n int = 5)
+RETURNS bit
+AS
+BEGIN
+ RETURN (@n % 2)
+END
+GO
+
+--Use ufnIsOdd function
+DECLARE @numb int
+
+--Input a null value returns null instead of
+--using default parameter
+SELECT @numb 'Number', dbo.ufnIsOdd (@numb) 'Is_odd = 1'
+
+--To tap default parameter value, you must
+--explicitly reference default value with the
+--default keyword
+SELECT @numb 'Number', dbo.ufnIsOdd (DEFAULT) 'Is_odd = 1'
+
+SET @numb = 6
+SELECT @numb 'Number', dbo.ufnIsOdd (@numb) 'Is_odd = 1'
+
+--Drop ufnIsOdd function
+DROP FUNCTION dbo.ufnIsOdd
+GO
+
+
+--Same taks performed with a stored procedure
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_NumberIsOdd')
+ DROP PROCEDURE usp_NumberIsOdd
+GO
+
+CREATE PROCEDURE usp_NumberIsOdd
+@n int = 5
+AS
+SELECT @n 'Number', @n % 2 'Is_odd = 1'
+GO
+
+DECLARE @numb int
+
+EXEC usp_NumberIsOdd @numb
+EXEC usp_NumberIsOdd
+SET @numb = 6
+EXEC usp_NumberIsOdd @numb
+GO
+
+DROP PROCEDURE usp_NumberIsOdd
+GO
+
diff --git a/SamplesForChapter07/Chapter07/StoredProcOutputParameters.sql b/SamplesForChapter07/Chapter07/StoredProcOutputParameters.sql
new file mode 100644
index 0000000..9d3c17a
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/StoredProcOutputParameters.sql
@@ -0,0 +1,120 @@
+USE AdventureWorks
+GO
+
+--Create view with SubTotal values from
+--Sales.SalesOrderHeader table and row numbers
+IF EXISTS(SELECT *
+ FROM sys.views v JOIN sys.schemas s
+ ON V.schema_id = s.schema_id
+ WHERE v.name = 'vSTRow_Numbers' AND
+ s.name = 'dbo')
+ DROP VIEW dbo.vSTRow_Numbers
+GO
+
+CREATE VIEW dbo.vSTRow_Numbers
+AS
+SELECT SubTotal, Row_Number() OVER (ORDER BY SubTotal) rn
+FROM Sales.SalesOrderHeader
+GO
+
+--Create a view that returns the minimum and maximum
+--Subtotal values as output parameters
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_MinMaxSubTotal')
+ DROP PROCEDURE usp_MinMaxSubTotal
+GO
+
+--Create a stored proc with an input parameter
+CREATE PROCEDURE usp_MinMaxSubTotal
+@minSubTotal money OUTPUT,
+@maxSubTotal money OUTPUT
+AS
+SET @minSubTotal =
+ (SELECT TOP 1 SubTotal
+ FROM dbo.vSTRow_Numbers ORDER BY rn)
+SET @maxSubTotal =
+ (SELECT TOP 1 SubTotal
+ FROM dbo.vSTRow_Numbers ORDER BY rn DESC)
+GO
+
+--Invoke usp_MinMaxSubTotal to retrieve maximum and
+--minimum SubTotal values
+DECLARE @lclmin money, @lclmax money
+EXEC usp_MinMaxSubTotal @minSubTotal = @lclmin OUTPUT,
+ @maxSubTotal = @lclmax OUTPUT
+
+SELECT @lclmin 'Min. SubTotal', @lclmax 'Max. SubTotal'
+GO
+
+--Create FN user-defined function to determin
+--if a number is odd or even
+IF EXISTS(
+ SELECT * FROM sys.objects
+ WHERE type = 'FN' AND schema_id = 1
+ AND name = 'ufnIsOdd')
+ DROP FUNCTION dbo.ufnIsOdd
+GO
+
+CREATE FUNCTION dbo.ufnIsOdd (@n int)
+RETURNS bit
+AS
+BEGIN
+ RETURN (@n % 2)
+END
+GO
+
+
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_MedianSubTotal')
+ DROP PROCEDURE usp_MedianSubTotal
+GO
+
+--Create a stored proc with an input parameter
+CREATE PROCEDURE usp_MedianSubTotal
+@MedianVal money OUTPUT
+AS
+
+DECLARE @rnval int
+DECLARE @midup money, @middown money
+
+--Compute near middle row
+SET @rnval = ((SELECT COUNT(*) FROM dbo.vSTRow_Numbers)/2)
+
+IF dbo.ufnIsOdd
+ ((SELECT COUNT(*)
+ FROM dbo.vSTRow_Numbers)) = 1
+ --get mediam for odd count
+ SET @MedianVal = (SELECT SubTotal
+ FROM dbo.vSTRow_Numbers
+ WHERE rn = @rnval + 1)
+ELSE
+BEGIN
+ --compute mediam for even count
+ SET @midup =
+ (SELECT SubTotal
+ FROM dbo.vSTRow_Numbers
+ WHERE rn = @rnval)
+ SET @middown =
+ (SELECT SubTotal
+ FROM dbo.vSTRow_Numbers
+ WHERE rn = (SELECT @rnval + 1))
+ SET @MedianVal =
+ (SELECT (@midup + @middown)/2)
+END
+GO
+
+--Invoke usp_MedianSubTotal to retrieve median SubTotal value
+DECLARE @MedValue money
+
+EXEC usp_MedianSubTotal @MedianVal = @MedValue OUTPUT
+
+SELECT @MedValue 'Median value'
+GO
+
+
+DROP PROCEDURE usp_MinMaxSubTotal
+DROP PROCEDURE usp_MedianSubTotal
+DROP FUNCTION dbo.ufnIsOdd
+DROP VIEW dbo.vSTRow_Numbers
diff --git a/SamplesForChapter07/Chapter07/StoredProcResultSets.sql b/SamplesForChapter07/Chapter07/StoredProcResultSets.sql
new file mode 100644
index 0000000..faf5d4f
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/StoredProcResultSets.sql
@@ -0,0 +1,124 @@
+USE AdventureWorks
+GO
+
+--Make stored proc in default schema
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalePersonNamePhoneEmail')
+ DROP PROCEDURE usp_SalePersonNamePhoneEmail
+GO
+
+CREATE PROCEDURE usp_SalePersonNamePhoneEmail
+AS
+SELECT s.TerritoryID, c.LastName, c.Phone, c.EmailAddress
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+GO
+
+--Invoke stored proc
+EXEC usp_SalePersonNamePhoneEmail
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalePersonNamePhoneEmail
+GO
+
+--For display in book
+--Make stored proc in default schema
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalePersonNamePhoneEmail')
+ DROP PROCEDURE usp_SalePersonNamePhoneEmail
+GO
+
+CREATE PROCEDURE usp_SalePersonNamePhoneEmail
+AS
+SELECT s.TerritoryID,
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ CAST(c.Phone AS nvarchar(19)) 'Phone',
+ CAST(c.EmailAddress AS nvarchar(28)) 'EmailAddress'
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+GO
+
+--Invoke stored proc
+EXEC usp_SalePersonNamePhoneEmail
+GO
+
+--Drop stored proc
+DROP PROCEDURE usp_SalePersonNamePhoneEmail
+GO
+
+
+--Searches for usp_ProductCategoryCountSubcategory in
+--any schema and drops stored proc in Production schema
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_ProductCategoryCountSubcategory')
+ DROP PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+GO
+
+--Create a stored proc with two result sets
+CREATE PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+AS
+
+SELECT ProductCategoryID, Name
+FROM Production.ProductCategory
+ORDER BY ProductCategoryID
+
+SELECT ProductCategoryID, COUNT(*) 'No. Subcategories'
+FROM Production.ProductSubcategory
+GROUP BY ProductCategoryID
+ORDER BY ProductCategoryID
+GO
+
+--Invoke stored proc
+EXEC Production.usp_ProductCategoryCountSubcategory
+GO
+
+--Drop stored proc
+DROP PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+GO
+
+--For display in book
+--Searches for usp_ProductCategoryCountSubcategory in
+--any schema and drops stored proc in Production schema
+IF EXISTS(SELECT * FROM sys.objects o JOIN sys.schemas s
+ ON o.schema_id = s.schema_id
+ WHERE o.type = 'P' AND
+ s.name = 'Production' AND
+ o.name = 'usp_ProductCategoryCountSubcategory')
+ DROP PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+GO
+
+--Create a stored proc with two result sets
+CREATE PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+AS
+
+SELECT ProductCategoryID, CAST(Name AS nvarchar(11)) 'Name'
+FROM Production.ProductCategory
+ORDER BY ProductCategoryID
+
+SELECT ProductCategoryID, COUNT(*) 'No. Subcategories'
+FROM Production.ProductSubcategory
+GROUP BY ProductCategoryID
+ORDER BY ProductCategoryID
+GO
+
+--Invoke stored proc
+EXEC Production.usp_ProductCategoryCountSubcategory
+GO
+
+--Drop stored proc
+DROP PROCEDURE
+ Production.usp_ProductCategoryCountSubcategory
+GO
diff --git a/SamplesForChapter07/Chapter07/StoredProcReturnStatusValues.sql b/SamplesForChapter07/Chapter07/StoredProcReturnStatusValues.sql
new file mode 100644
index 0000000..39f323e
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/StoredProcReturnStatusValues.sql
@@ -0,0 +1,99 @@
+USE AdventureWorks
+GO
+
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalesPersonReport')
+ DROP PROCEDURE usp_SalesPersonReport
+GO
+
+CREATE PROC usp_SalesPersonReport
+@BestSalesPerson nvarchar(150) OUTPUT
+AS
+
+SET @BestSalesPerson = (SELECT REPLACE(FirstName + ' ' +
+ ISNULL(MiddleName, '') + ' ' + LastName, ' ', ' ')
+ FROM Sales.VSalesPerson
+ WHERE SalesYTD =
+ (SELECT MAX(SalesYTD) FROM Sales.VSalesPerson))
+
+SELECT SalesPersonID, FirstName, MiddleName,
+ LastName, SalesYTD
+FROM Sales.VSalesPerson
+
+IF (SELECT SalesYTD
+ FROM Sales.VSalesPerson
+ WHERE SalesYTD = (SELECT MAX(SalesYTD)
+ FROM Sales.VSalesPerson)) >
+ (SELECT SalesLastYear
+ FROM Sales.VSalesPerson
+ WHERE SalesYTD =
+ (SELECT MAX(SalesYTD)
+ FROM Sales.VSalesPerson))
+ RETURN 1
+ELSE
+ RETURN 0
+GO
+
+DECLARE @BestName nvarchar(150), @rsval int
+
+EXEC @rsval = usp_SalesPersonReport
+ @BestSalesPerson = @BestName OUTPUT
+
+IF @rsval = 1
+ SELECT @BestName 'Best sales person is:',
+ 'Yes' 'Exceeded last year:'
+ELSE
+ SELECT @BestName 'Best sales person is:',
+ 'No' 'Exceeded last year:'
+
+--For display in book
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_SalesPersonReport')
+ DROP PROCEDURE usp_SalesPersonReport
+GO
+
+CREATE PROC usp_SalesPersonReport
+@BestSalesPerson nvarchar(150) OUTPUT
+AS
+
+SET @BestSalesPerson = (SELECT REPLACE(FirstName + ' ' +
+ ISNULL(MiddleName, '') + ' ' + LastName, ' ', ' ')
+ FROM Sales.VSalesPerson
+ WHERE SalesYTD =
+ (SELECT MAX(SalesYTD) FROM Sales.VSalesPerson))
+
+SELECT SalesPersonID, CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(MiddleName AS nvarchar(10)) 'MiddleName',
+ CAST(LastName AS nvarchar(17)) 'LastName', SalesYTD
+FROM Sales.VSalesPerson
+
+IF (SELECT SalesYTD
+ FROM Sales.VSalesPerson
+ WHERE SalesYTD = (SELECT MAX(SalesYTD)
+ FROM Sales.VSalesPerson)) >
+ (SELECT SalesLastYear
+ FROM Sales.VSalesPerson
+ WHERE SalesYTD =
+ (SELECT MAX(SalesYTD)
+ FROM Sales.VSalesPerson))
+ RETURN 1
+ELSE
+ RETURN 0
+GO
+
+DECLARE @BestName nvarchar(150), @rsval int
+
+EXEC @rsval = usp_SalesPersonReport
+ @BestSalesPerson = @BestName OUTPUT
+
+IF @rsval = 1
+ SELECT CAST(@BestName AS nvarchar(21)) 'Best sales person is:',
+ 'Yes' 'Exceeded last year:'
+ELSE
+ SELECT CAST(@BestName AS nvarchar(21)) 'Best sales person is:',
+ 'No' 'Exceeded last year:'
+
+
+DROP PROCEDURE usp_SalesPersonReport
diff --git a/SamplesForChapter07/Chapter07/StoredProcsForDataModification.sql b/SamplesForChapter07/Chapter07/StoredProcsForDataModification.sql
new file mode 100644
index 0000000..0200053
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/StoredProcsForDataModification.sql
@@ -0,0 +1,175 @@
+USE ProSSEAppsCh07
+GO
+
+--Create a new view after dropping previously
+--existing version of view
+IF EXISTS(SELECT *
+ FROM sys.views
+ WHERE name = 'StudentGrades' AND
+ schema_id = 1)
+ DROP VIEW dbo.StudentGrades
+GO
+
+CREATE VIEW dbo.StudentGrades
+AS
+SELECT s.StudentID, s.FirstName, s.LastName, s.Fullname,
+ c.ClassID, c.ClassTitle, cg.Gradeletter
+FROM Classes c JOIN ClassGrades cg
+ON c.ClassID = cg.ClassID
+JOIN Students S
+ON s.StudentID = cg.StudentID
+GO
+
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_AddClass')
+ DROP PROCEDURE usp_AddClass
+GO
+
+CREATE PROC usp_AddClass
+@ClassIDval int,
+@ClassTitleval varchar(50)
+AS
+INSERT dbo.StudentGrades (ClassID, ClassTitle)
+ VALUES (@ClassIDval, @ClassTitleval)
+GO
+
+--SELECT from the underlying table before adding a new class
+SELECT ClassID, ClassTitle
+FROM Classes
+GO
+
+--INSERT new class through view
+EXEC usp_AddClass 2, 'Learning Visual Basic Express for DBAs'
+GO
+
+--Verify new row is there by querying the Classes table
+SELECT ClassID, ClassTitle
+FROM Classes
+GO
+
+--SELECT from view after adding a new class
+SELECT DISTINCT ClassID, ClassTitle
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_AddClassGrades')
+ DROP PROCEDURE usp_AddClassGrades
+GO
+
+CREATE PROC usp_AddClassGrades
+@ClassIDval int,
+@StudentIDval int,
+@Gradeletterval varchar(2)
+AS
+INSERT ClassGrades (ClassID, StudentID, Gradeletter)
+ VALUES(@ClassIDval, @StudentIDval, @Gradeletterval)
+GO
+
+EXEC usp_AddClassGrades 2, 1, 'B'
+EXEC usp_AddClassGrades 2, 2, 'A'
+GO
+
+--SELECT from view after adding a new class
+SELECT FirstName, LastName, ClassID, Gradeletter
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+--For display in book
+SELECT CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(12)) 'LastName', ClassID, Gradeletter
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_UpdateLastName')
+ DROP PROCEDURE usp_UpdateLastName
+GO
+
+CREATE PROC usp_UpdateLastName
+@StudentIDval int,
+@NewLastNameval nvarchar(50)
+AS
+UPDATE dbo.StudentGrades
+SET LastName = @NewLastNameval
+WHERE StudentID = @StudentIDval
+GO
+
+EXEC usp_UpdateLastName 2,'DBA-Minister'
+GO
+
+--SELECT from view after changing last name
+SELECT FirstName, LastName, ClassID, Gradeletter
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+--For display in book
+SELECT CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(12)) 'LastName', ClassID, Gradeletter
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'P' AND
+ name = 'usp_DeleteGradesClasses')
+ DROP PROCEDURE usp_DeleteGradesClasses
+GO
+
+CREATE PROC usp_DeleteGradesClasses
+@ClassIDval int
+AS
+DELETE FROM ClassGrades
+ WHERE ClassID = @ClassIDval
+DELETE FROM Classes
+ WHERE ClassID = @ClassIDval
+GO
+
+EXEC usp_DeleteGradesClasses 2
+GO
+
+--SELECT from view after changing last name
+SELECT FirstName, LastName, ClassID, Gradeletter
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+--For display in book
+SELECT CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(12)) 'LastName', ClassID, Gradeletter
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+--Inserting with the Bulk Insert statement
+USE ProSSEAppsCh07
+GO
+
+IF EXISTS(SELECT * FROM sys.objects
+ WHERE type = 'p' AND
+ name = 'usp_BULKINSERT')
+ DROP PROC usp_BULKINSERT
+GO
+
+CREATE PROC usp_BULKINSERT
+AS
+BULK INSERT Classes FROM "c:\NewClasses.txt"
+GO
+
+EXEC usp_BULKINSERT
+GO
+
+SELECT * FROM Classes
+GO
+
+DELETE FROM Classes WHERE ClassID = 2 OR ClassID = 3
diff --git a/SamplesForChapter07/Chapter07/TRIGGERS.sql b/SamplesForChapter07/Chapter07/TRIGGERS.sql
new file mode 100644
index 0000000..611e849
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/TRIGGERS.sql
@@ -0,0 +1,309 @@
+USE ProSSEAppsCh07
+GO
+
+--Conditionally drop trigger from dbo schema
+IF EXISTS(SELECT *
+ FROM sys.objects o JOIN sys.schemas s
+ ON o.schema_id = s.schema_id
+ WHERE type = 'TR' AND
+ s.name = 'dbo' AND
+ o.name = 'trStudentsEcho')
+ DROP TRIGGER trStudentsEcho
+GO
+
+--Add trigger to echo changes
+CREATE TRIGGER trStudentsEcho
+ON Students
+FOR UPDATE, INSERT, DELETE
+AS
+SELECT * FROM inserted
+SELECT * FROM deleted
+GO
+
+--For display in book
+IF EXISTS(SELECT *
+ FROM sys.objects o JOIN sys.schemas s
+ ON o.schema_id = s.schema_id
+ WHERE type = 'TR' AND
+ s.name = 'dbo' AND
+ o.name = 'trStudentsEcho_Display')
+ DROP TRIGGER trStudentsEcho_Display
+GO
+
+CREATE TRIGGER trStudentsEcho_Display
+ON Students
+FOR UPDATE, INSERT, DELETE
+AS
+SELECT StudentID, CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(9)) 'LastName',
+ CAST(FullName AS nvarchar(19)) 'FullName' FROM inserted
+SELECT StudentID, CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(9)) 'LastName',
+ CAST(FullName AS nvarchar(19)) 'FullName' FROM deleted
+GO
+
+--INSERT, UPDATE, DELETE
+SET NOCOUNT ON
+SELECT 'Before INSERT'
+INSERT Students (StudentID, FirstName, LastName)
+ VALUES (3, 'Rick', 'Dobson')
+
+SELECT 'Before UPDATE'
+UPDATE Students
+SET FirstName = 'Rickie'
+WHERE StudentID = 3
+
+SELECT 'Before DELETE'
+DELETE FROM Students WHERE StudentID = 3
+SET NOCOUNT OFF
+
+--Some of these statements may fail if the triggers do not currently exist
+DROP TRIGGER trStudentsEcho
+DROP TRIGGER trStudentsEcho_Display
+
+
+IF EXISTS(SELECT *
+ FROM sys.objects o JOIN sys.schemas s
+ ON o.schema_id = s.schema_id
+ WHERE type = 'TR' AND
+ s.name = 'dbo' AND
+ o.name = 'trStudents_Insert_Rollback')
+ DROP TRIGGER trStudents_Insert_Rollback
+GO
+
+--Add trigger with a rollback
+CREATE TRIGGER trStudents_Insert_Rollback
+ON Students
+FOR INSERT
+AS
+ROLLBACK TRAN
+PRINT 'INSERT statement rolled back.'
+GO
+
+--Disable trigger and insert, then delete the same row
+DISABLE TRIGGER trStudents_Insert_Rollback ON Students
+SELECT * FROM Students
+INSERT Students (StudentID, FirstName, LastName)
+ VALUES (3, 'Rick', 'Dobson')
+SELECT * FROM Students
+DELETE FROM Students WHERE StudentID = 3
+GO
+
+
+ENABLE TRIGGER trStudents_Insert_Rollback ON Students
+SELECT * FROM Students
+INSERT Students (StudentID, FirstName, LastName)
+ VALUES (3, 'Rick', 'Dobson')
+GO
+SELECT * FROM Students
+GO
+
+--For display in book
+SET NOCOUNT ON;
+DISABLE TRIGGER trStudents_Insert_Rollback ON Students
+SELECT StudentID, CAST(FirstName AS NVARCHAR(9)) 'FirstName',
+ CAST(LastName AS NVARCHAR(9)) 'LastName',
+ CAST(FullName AS NVARCHAR(18)) 'FullName'
+FROM Students
+INSERT Students (StudentID, FirstName, LastName)
+ VALUES (3, 'Rick', 'Dobson')
+SELECT StudentID, CAST(FirstName AS NVARCHAR(9)) 'FirstName',
+ CAST(LastName AS NVARCHAR(9)) 'LastName',
+ CAST(FullName AS NVARCHAR(18)) 'FullName'
+FROM Students
+DELETE FROM Students WHERE StudentID = 3
+GO
+
+ENABLE TRIGGER trStudents_Insert_Rollback ON Students
+SELECT StudentID, CAST(FirstName AS NVARCHAR(9)) 'FirstName',
+ CAST(LastName AS NVARCHAR(9)) 'LastName',
+ CAST(FullName AS NVARCHAR(18)) 'FullName'
+FROM Students
+INSERT Students (StudentID, FirstName, LastName)
+ VALUES (3, 'Rick', 'Dobson')
+GO
+SELECT StudentID, CAST(FirstName AS NVARCHAR(9)) 'FirstName',
+ CAST(LastName AS NVARCHAR(9)) 'LastName',
+ CAST(FullName AS NVARCHAR(18)) 'FullName'
+FROM Students
+GO
+SET NOCOUNT ON
+
+--Some of these statements may fail if the triggers do not currently exist
+DROP TRIGGER trStudentsEcho
+DROP TRIGGER trStudentsEcho_Display
+DROP TRIGGER trStudents_Insert_Rollback
+
+
+--Create table to archive changes to Students
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'StudentsArchive')
+ DROP TABLE StudentsArchive
+GO
+
+CREATE TABLE StudentsArchive (
+AID int IDENTITY(1,1) PRIMARY KEY CLUSTERED,
+type nvarchar(6) NOT NULL,
+whenchanged smalldatetime NOT NULL DEFAULT Getdate(),
+StudentID int,
+nFirstName nvarchar(30),
+nLastName nvarchar(50),
+oFirstName nvarchar(30),
+oLastName nvarchar(50)
+)
+GO
+
+--Conditionally drop trigger from dbo schema
+IF EXISTS(SELECT *
+ FROM sys.objects o JOIN sys.schemas s
+ ON o.schema_id = s.schema_id
+ WHERE type = 'TR' AND
+ s.name = 'dbo' AND
+ o.name = 'trStudents_INSERT')
+ DROP TRIGGER trStudents_INSERT
+GO
+
+CREATE TRIGGER trStudents_INSERT
+ON Students
+FOR INSERT
+AS
+DECLARE @StudentID int, @FirstName nvarchar(30),
+ @LasName nvarchar(50)
+
+SET @StudentID = (SELECT StudentID FROM inserted)
+SET @FirstName = (SELECT FirstName FROM inserted)
+SET @LasName = (SELECT LastName FROM inserted)
+INSERT StudentsArchive (type, StudentID, nFirstName,
+ nLastName)
+ VALUES('INSERT', @StudentID, @FirstName, @LasName)
+GO
+
+IF EXISTS(SELECT *
+ FROM sys.objects o JOIN sys.schemas s
+ ON o.schema_id = s.schema_id
+ WHERE type = 'TR' AND
+ s.name = 'dbo' AND
+ o.name = 'trStudents_DELETE')
+ DROP TRIGGER trStudents_DELETE
+GO
+
+CREATE TRIGGER trStudents_DELETE
+ON Students
+FOR DELETE
+AS
+DECLARE @StudentID int, @FirstName nvarchar(30),
+ @LasName nvarchar(50)
+
+SET @StudentID = (SELECT StudentID FROM deleted)
+SET @FirstName = (SELECT FirstName FROM deleted)
+SET @LasName = (SELECT LastName FROM deleted)
+INSERT StudentsArchive (type, StudentID, oFirstName,
+ oLastName)
+ VALUES('DELETE', @StudentID, @FirstName, @LasName)
+GO
+
+
+IF EXISTS(SELECT *
+ FROM sys.objects o JOIN sys.schemas s
+ ON o.schema_id = s.schema_id
+ WHERE type = 'TR' AND
+ s.name = 'dbo' AND
+ o.name = 'trStudents_UPDATE')
+ DROP TRIGGER trStudents_UPDATE
+GO
+
+CREATE TRIGGER trStudents_UPDATE
+ON Students
+INSTEAD OF UPDATE
+AS
+
+DECLARE @StudentID int, @nFirstName nvarchar(30),
+ @nLastName nvarchar(50), @oFirstName nvarchar(30),
+ @oldLasName nvarchar(50)
+
+IF (SELECT StudentID FROM inserted) <>
+ (SELECT StudentID FROM deleted)
+ RAISERROR ('You are not allowed to change StudentID.',
+ 10,1)
+ELSE
+BEGIN
+
+--set local variables
+ SET @StudentID = (SELECT StudentID FROM inserted)
+ SET @nFirstName = (SELECT FirstName FROM inserted)
+ SET @nLastName = (SELECT LastName FROM inserted)
+ SET @oFirstName = (SELECT FirstName FROM deleted)
+ SET @oldLasName = (SELECT LastName FROM deleted)
+
+--write to table
+ UPDATE Students
+ SET FirstName = @nFirstName, LastName = @nLastName
+ WHERE StudentID = @StudentID
+
+-- write to archive
+ INSERT StudentsArchive (type, StudentID, nFirstName,
+ nLastName, oFirstName, oLastName)
+ VALUES('UPDATE', @StudentID, @nFirstName, @nLastName,
+ @oFirstName, @oldLasName)
+END
+GO
+
+
+SELECT * FROM Students
+
+INSERT Students VALUES (3, 'Rickie', 'Hobson')
+SELECT * FROM StudentsArchive
+
+--For display in book
+SELECT CAST(AID AS nvarchar(3)) 'AID', type, CONVERT(varchar(19),whenchanged) 'whenchanged', CAST(StudentID AS nvarchar(9)) 'StudentID',
+ CAST(nFirstName AS nvarchar(10)) 'nFirstName',
+ CAST(nLastName AS nvarchar(9)) 'nLastName',
+ CAST(oFirstName AS nvarchar(10)) 'oFirstName',
+ CAST(oLastName AS nvarchar(9)) 'oLastName'
+FROM StudentsArchive
+
+UPDATE Students
+SET FirstName = 'Rick', LastName = 'Dobson'
+WHERE StudentID = 3
+SELECT * FROM StudentsArchive
+
+--For display in book
+SELECT CAST(AID AS nvarchar(3)) 'AID', type, CONVERT(varchar(19),whenchanged) 'whenchanged', CAST(StudentID AS nvarchar(9)) 'StudentID',
+ CAST(nFirstName AS nvarchar(10)) 'nFirstName',
+ CAST(nLastName AS nvarchar(9)) 'nLastName',
+ CAST(oFirstName AS nvarchar(10)) 'oFirstName',
+ CAST(oLastName AS nvarchar(9)) 'oLastName'
+FROM StudentsArchive
+
+UPDATE Students
+SET StudentID = 999
+WHERE StudentID = 3
+SELECT * FROM StudentsArchive
+
+--For display in book
+SELECT CAST(AID AS nvarchar(3)) 'AID', type, CONVERT(varchar(19),whenchanged) 'whenchanged', CAST(StudentID AS nvarchar(9)) 'StudentID',
+ CAST(nFirstName AS nvarchar(10)) 'nFirstName',
+ CAST(nLastName AS nvarchar(9)) 'nLastName',
+ CAST(oFirstName AS nvarchar(10)) 'oFirstName',
+ CAST(oLastName AS nvarchar(9)) 'oLastName'
+FROM StudentsArchive
+
+
+DELETE FROM Students WHERE StudentID = 3
+SELECT * FROM StudentsArchive
+
+--For display in book
+SELECT CAST(AID AS nvarchar(3)) 'AID', type, CONVERT(varchar(19),whenchanged) 'whenchanged', CAST(StudentID AS nvarchar(9)) 'StudentID',
+ CAST(nFirstName AS nvarchar(10)) 'nFirstName',
+ CAST(nLastName AS nvarchar(9)) 'nLastName',
+ CAST(oFirstName AS nvarchar(10)) 'oFirstName',
+ CAST(oLastName AS nvarchar(9)) 'oLastName'
+FROM StudentsArchive
+
+
+--Some of these statements may fail if the triggers do not currently exist
+DROP TRIGGER trStudents_INSERT
+DROP TRIGGER trStudents_DELETE
+DROP TRIGGER trStudents_UPDATE
+
+
diff --git a/SamplesForChapter07/Chapter07/TriggerForView.sql b/SamplesForChapter07/Chapter07/TriggerForView.sql
new file mode 100644
index 0000000..dda7eca
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/TriggerForView.sql
@@ -0,0 +1,119 @@
+USE ProSSEAppsCh07
+GO
+
+--Create a new view after dropping previously
+--existing version of view
+IF EXISTS(SELECT *
+ FROM sys.views
+ WHERE name = 'StudentGrades' AND
+ schema_id = 1)
+ DROP VIEW dbo.StudentGrades
+GO
+
+CREATE VIEW dbo.StudentGrades
+AS
+SELECT s.StudentID, s.FirstName, s.LastName, s.Fullname,
+ c.ClassID, c.ClassTitle, cg.Gradeletter
+FROM Classes c JOIN ClassGrades cg
+ON c.ClassID = cg.ClassID
+JOIN Students S
+ON s.StudentID = cg.StudentID
+GO
+
+
+--Create a trigger for inserting new students and classes
+IF EXISTS(SELECT *
+ FROM sys.objects o JOIN sys.schemas s
+ ON o.schema_id = s.schema_id
+ WHERE type = 'TR' AND
+ s.name = 'dbo' AND
+ o.name = 'trInsertClassStudentGrades')
+ DROP TRIGGER trInsertClassStudentGrades
+GO
+
+CREATE TRIGGER trInsertClassStudentGrades
+ON StudentGrades
+INSTEAD OF INSERT
+AS
+
+DECLARE @ClassID int, @StudentID int
+DECLARE @ClassIDIn bit, @StudentIDIn bit
+DECLARE @ClassTitle nvarchar(50), @FirstName nvarchar(30),
+ @LastName nvarchar(50)
+
+--Assign @ClassID and @StudentID
+SET @ClassID = (SELECT ClassID FROM inserted)
+SET @StudentID = (SELECT StudentID FROM inserted)
+
+--Is ClassID in Classes
+IF EXISTS(SELECT * FROM Classes WHERE ClassID = @ClassID)
+ SET @ClassIDIn = 1
+ELSE
+ SET @ClassIDIn = 0
+
+--Is StudentID in Students
+IF EXISTS(SELECT * FROM Students WHERE StudentID = @StudentID)
+ SET @StudentIDIn = 1
+ELSE
+ SET @StudentIDIn = 0
+
+--Insert Class info if @ClassID is valid
+if @ClassIDIn = 0 and @ClassID IS NOT NULL
+BEGIN
+ SET @ClassTitle = (SELECT ClassTitle FROM inserted)
+ INSERT dbo.StudentGrades (ClassID, ClassTitle)
+ VALUES (@ClassID, @ClassTitle)
+END
+ELSE
+ IF @ClassIDIn = 1
+ RAISERROR ('ClassID already assigned.',10,1)
+
+--Insert Student info if @StudentID is valid
+IF @StudentIDIn = 0 AND @StudentID IS NOT NULL
+BEGIN
+ SET @FirstName = (SELECT FirstName FROM inserted)
+ SET @LastName = (SELECT LastName FROM inserted)
+ INSERT dbo.StudentGrades (StudentID, FirstName, LastName)
+ VALUES (@StudentID, @FirstName, @LastName)
+END
+ELSE
+ IF @StudentIDIn = 1
+ RAISERROR ('StudentID already assigned.',10,1)
+GO
+
+--Code to test trInsertClassStudentGrades
+SELECT * FROM Students
+SELECT StudentID, CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(9)) 'LastName',
+ CAST(FullName AS nvarchar(19)) 'FullName'
+FROM Students
+
+INSERT dbo.StudentGrades (StudentID, FirstName, LastName)
+ VALUES (3,'Virginia', 'Dobson')
+
+
+SELECT * FROM Students
+SELECT StudentID, CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(9)) 'LastName',
+ CAST(FullName AS nvarchar(19)) 'FullName'
+FROM Students
+
+INSERT dbo.StudentGrades (StudentID, FirstName, LastName)
+ VALUES (3,'Mary', 'Dobson')
+
+SELECT * FROM Classes
+
+INSERT dbo.StudentGrades (ClassID, ClassTitle)
+ VALUES (2, 'Learning Visual Basic Express for DBAs')
+GO
+
+SELECT * FROM Classes
+
+DELETE FROM Classes WHERE ClassID = 2
+DELETE FROM Students WHERE StudentID = 3
+
+DROP TRIGGER trInsertClassStudentGrades
+
+
+
+
diff --git a/SamplesForChapter07/Chapter07/ViewsForDataAccess.sql b/SamplesForChapter07/Chapter07/ViewsForDataAccess.sql
new file mode 100644
index 0000000..e045178
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/ViewsForDataAccess.sql
@@ -0,0 +1,86 @@
+USE AdventureWorks
+GO
+
+--Drop previously existing version of view
+IF OBJECT_ID('dbo.vSalePersonNamePhoneEmail', 'VIEW') IS NOT NULL
+ DROP VIEW dbo.vSalePersonNamePhoneEmail
+GO
+
+--Create dbo.vSalePersonNamePhoneEmail view
+CREATE VIEW dbo.vSalePersonNamePhoneEmail
+AS
+SELECT s.SalesPersonID, c.FirstName, c.MiddleName,
+ c.LastName, c.Phone, c.EmailAddress
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+GO
+
+--Select from dbo.vSalePersonNamePhoneEmail
+SELECT SalesPersonID, FirstName, LastName,
+ Phone, EmailAddress
+FROM dbo.vSalePersonNamePhoneEmail
+WHERE LastName LIKE 'A%'
+
+--For display in book
+SELECT SalesPersonID,
+ CAST(FirstName AS nvarchar(9)) 'FirstName',
+ CAST(LastName AS nvarchar(15)) 'LastName',
+ CAST(Phone AS nvarchar(12)) 'Phone',
+ CAST(EmailAddress AS nvarchar(30)) 'EmailAddress'
+FROM dbo.vSalePersonNamePhoneEmail
+WHERE LastName LIKE 'A%'
+
+--Drop previously existing version of view in schema
+IF EXISTS(SELECT *
+ FROM sys.views
+ WHERE name = 'vSalePersonNamePhoneEmail' AND schema_id =
+ SCHEMA_ID('HumanResources'))
+ DROP VIEW HumanResources.vSalePersonNamePhoneEmail
+GO
+
+--Create HumanResources.vSalePersonNamePhoneEmail view
+CREATE VIEW HumanResources.vSalePersonNamePhoneEmail
+AS
+SELECT s.SalesPersonID, c.FirstName, c.MiddleName,
+ c.LastName, c.Phone, c.EmailAddress
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+GO
+
+--Select from HumanResources.vSalePersonNamePhoneEmail
+SELECT SalesPersonID, FirstName, LastName,
+ Phone, EmailAddress
+FROM HumanResources.vSalePersonNamePhoneEmail
+WHERE LastName LIKE 'A%'
+GO
+
+--List vSalePersonNamePhoneEmail views from sys.views
+--and INFORMATION_SCHEMA.VIEWS
+SELECT name, schema_id
+FROM sys.views
+WHERE name = 'vSalePersonNamePhoneEmail'
+
+SELECT TABLE_NAME, TABLE_SCHEMA
+FROM INFORMATION_SCHEMA.VIEWS
+WHERE TABLE_NAME = 'vSalePersonNamePhoneEmail'
+GO
+
+--For display in book
+SELECT CAST(name AS nvarchar(25)) 'name', schema_id
+FROM sys.views
+WHERE name = 'vSalePersonNamePhoneEmail'
+
+SELECT CAST(TABLE_NAME AS nvarchar(25)) 'TABLE_NAME', CAST(TABLE_SCHEMA AS nvarchar(14)) 'TABLE_SCHEMA'
+FROM INFORMATION_SCHEMA.VIEWS
+WHERE TABLE_NAME = 'vSalePersonNamePhoneEmail'
+GO
+
+--Drop custom views from the AdventureWorks database
+DROP VIEW dbo.vSalePersonNamePhoneEmail
+DROP VIEW HumanResources.vSalePersonNamePhoneEmail
+GO
+
diff --git a/SamplesForChapter07/Chapter07/ViewsForDataModification.sql b/SamplesForChapter07/Chapter07/ViewsForDataModification.sql
new file mode 100644
index 0000000..9abe924
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/ViewsForDataModification.sql
@@ -0,0 +1,113 @@
+USE ProSSEAppsCh07
+GO
+
+--Create a new view after dropping previously\
+--existing version of view
+IF EXISTS(SELECT *
+ FROM sys.views
+ WHERE name = 'StudentGrades' AND
+ schema_id = SCHEMA_ID('dbo'))
+ DROP VIEW dbo.StudentGrades
+GO
+
+CREATE VIEW dbo.StudentGrades
+AS
+SELECT s.StudentID, s.FirstName, s.LastName, s.Fullname,
+ c.ClassID, c.ClassTitle, cg.Gradeletter
+FROM Classes c JOIN ClassGrades cg
+ON c.ClassID = cg.ClassID
+JOIN Students S
+ON s.StudentID = cg.StudentID
+GO
+
+
+--SELECT from view before adding a new class
+SELECT DISTINCT ClassID, ClassTitle
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+--INSERT new class through view
+INSERT dbo.StudentGrades (ClassID, ClassTitle)
+ VALUES (2, 'Learning Visual Basic Express for DBAs')
+GO
+
+--SELECT from view after adding a new class
+SELECT DISTINCT ClassID, ClassTitle
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+--Verify new row is there by querying the Classes table
+SELECT ClassID, ClassTitle
+FROM Classes
+GO
+
+--Attempt to insert generates an error because modification
+--affects multiple base tables
+INSERT dbo.StudentGrades (ClassID, StudentID, Gradeletter)
+ VALUES(2, 1, 'B')
+INSERT dbo.StudentGrades (ClassID, StudentID, Gradeletter)
+ VALUES(2, 2, 'A')
+GO
+
+--Remedy by inserting directly into a base table
+INSERT ClassGrades (ClassID, StudentID, Gradeletter)
+ VALUES(2, 1, 'B')
+INSERT ClassGrades (ClassID, StudentID, Gradeletter)
+ VALUES(2, 2, 'A')
+GO
+
+--SELECT from view after adding a new class
+SELECT DISTINCT ClassID, ClassTitle
+FROM dbo.StudentGrades
+ORDER BY ClassID
+GO
+
+--SELECT from view before updating LastName
+SELECT StudentID, FullName, ClassTitle, GradeLetter
+FROM dbo.StudentGrades
+ORDER BY StudentID, ClassID
+
+--Update LastName of student
+UPDATE dbo.StudentGrades
+SET LastName = 'DBA-Minister'
+WHERE StudentID = 2
+GO
+
+
+--SELECT from view after updating last name
+SELECT StudentID, FullName, ClassTitle, GradeLetter
+FROM dbo.StudentGrades
+ORDER BY StudentID, ClassID
+
+
+
+--SELECT from view before updating LastName
+SELECT StudentID,
+ CAST(FullName AS nvarchar(19)) 'FullName',
+ CAST(ClassTitle AS nvarchar(38)) 'ClassTitle',
+ GradeLetter
+FROM dbo.StudentGrades
+ORDER BY StudentID, ClassID
+
+--Update LastName of student
+UPDATE dbo.StudentGrades
+SET LastName = 'DBA-Minister'
+WHERE StudentID = 2
+GO
+
+
+--SELECT from view after updating last name
+SELECT StudentID,
+ CAST(FullName AS nvarchar(19)) 'FullName',
+ CAST(ClassTitle AS nvarchar(38)) 'ClassTitle',
+ GradeLetter
+FROM dbo.StudentGrades
+ORDER BY StudentID, ClassID
+
+
+
+
+
+
diff --git a/SamplesForChapter07/Chapter07/ViewsForDataModificationSampleDB.sql b/SamplesForChapter07/Chapter07/ViewsForDataModificationSampleDB.sql
new file mode 100644
index 0000000..d493d71
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/ViewsForDataModificationSampleDB.sql
@@ -0,0 +1,81 @@
+USE master
+GO
+
+--Create a database
+IF EXISTS(SELECT name FROM sys.databases
+ WHERE name = 'ProSSEAppsCh07')
+ DROP DATABASE ProSSEAppsCh07
+GO
+
+CREATE DATABASE ProSSEAppsCh07
+GO
+
+USE ProSSEAppsCh07
+GO
+
+--Create three tables
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'ClassGrades')
+ DROP TABLE ClassGrades
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'Students')
+ DROP TABLE Students
+GO
+
+IF EXISTS(SELECT name FROM sys.tables
+ WHERE name = 'Classes')
+ DROP TABLE Classes
+GO
+
+CREATE TABLE Students(
+ StudentID int Primary Key,
+ FirstName nvarchar(30),
+ LastName nvarchar(50),
+ FullName AS (FirstName + ' ' + LastName)
+)
+GO
+
+CREATE TABLE Classes(
+ ClassID int Primary Key,
+ ClassTitle varchar(50)
+)
+GO
+
+CREATE TABLE ClassGrades(
+ ClassID int,
+ StudentID int,
+ GradeLetter varchar(2),
+ Constraint PK_ClassGrades
+ PRIMARY KEY(ClassID, StudentID),
+ Constraint FK_Classes_ClassID
+ FOREIGN KEY(ClassID)
+ REFERENCES Classes(ClassID) ON UPDATE CASCADE,
+ Constraint FK_Sudents_StudentID
+ FOREIGN KEY(StudentID)
+ REFERENCES Students(StudentID) ON UPDATE CASCADE
+)
+GO
+
+--Populate three tables with data
+--Insert classes rows
+INSERT Classes VALUES(1,
+ 'Learning SQL Server Express')
+INSERT Classes VALUES(999,
+ 'Biographies of Jesus Christ')
+GO
+
+--Insert Students rows
+INSERT Students VALUES(1, 'Poor', 'DBA')
+INSERT Students VALUES(2, 'Better', 'DBA')
+GO
+
+--Insert ClassGrades rows
+INSERT ClassGrades VALUES(1, 1, 'C+')
+INSERT ClassGrades VALUES(1, 2, 'A+')
+INSERT ClassGrades VALUES(999, 2, 'A')
+GO
+
+
+
diff --git a/SamplesForChapter07/Chapter07/ViewsForMetaData.sql b/SamplesForChapter07/Chapter07/ViewsForMetaData.sql
new file mode 100644
index 0000000..31d3149
--- /dev/null
+++ b/SamplesForChapter07/Chapter07/ViewsForMetaData.sql
@@ -0,0 +1,92 @@
+USE AdventureWorks
+GO
+
+--Drop previously existing version of view
+IF OBJECT_ID('dbo.vSalePersonNamePhoneEmail', 'VIEW') IS NOT NULL
+ DROP VIEW dbo.vSalePersonNamePhoneEmail
+IF OBJECT_ID('HumanResources.vSalePersonNamePhoneEmail', 'VIEW') IS NOT NULL
+ DROP VIEW HumanResources.vSalePersonNamePhoneEmail
+GO
+
+--Create dbo.vSalePersonNamePhoneEmail view
+CREATE VIEW dbo.vSalePersonNamePhoneEmail
+AS
+SELECT s.SalesPersonID, c.FirstName, c.MiddleName,
+ c.LastName, c.Phone, c.EmailAddress
+FROM Sales.SalesPerson S JOIN HumanResources.Employee e
+ON s.SalesPersonID = e.EmployeeID
+JOIN Person.Contact c
+ON c.ContactID = e.ContactID
+GO
+
+SELECT *
+FROM sys.views
+
+
+--Comparison of sys.views with INFORMATION_SCHEMA.VIEWS
+SELECT name, schema_id
+FROM sys.views
+WHERE name = 'vSalePersonNamePhoneEmail'
+
+SELECT TABLE_NAME, TABLE_SCHEMA, TABLE_Catalog
+FROM INFORMATION_SCHEMA.VIEWS
+WHERE TABLE_NAME = 'vSalePersonNamePhoneEmail'
+GO
+
+--Enhancement of sys.views with sys.schemas
+--and DB_NAME function
+SELECT v.name 'View name',
+ s.name 'Schema name',
+ DB_NAME() 'Database name'
+FROM sys.views v JOIN sys.schemas s
+ON v.schema_id = s.schema_id
+WHERE v.name = 'vSalePersonNamePhoneEmail'
+GO
+
+
+--For display in book
+SET NOCOUNT ON
+SELECT CAST(name AS nvarchar(25)) 'name', schema_id
+FROM sys.views
+WHERE name = 'vSalePersonNamePhoneEmail'
+
+SELECT CAST(TABLE_NAME AS nvarchar(25)) 'TABLE_NAME',
+ CAST(TABLE_SCHEMA AS nvarchar(12)) 'TABLE_SCHEMA',
+ CAST(TABLE_Catalog AS nvarchar(14)) 'TABLE_Catalog'
+FROM INFORMATION_SCHEMA.VIEWS
+WHERE TABLE_NAME = 'vSalePersonNamePhoneEmail'
+GO
+
+SELECT CAST(v.name AS nvarchar(25)) 'View name',
+ cast(s.name AS nvarchar(12)) 'Schema name',
+ CAST(DB_NAME() AS nvarchar(14)) 'Database name'
+FROM sys.views v JOIN sys.schemas s
+ON v.schema_id = s.schema_id
+WHERE v.name = 'vSalePersonNamePhoneEmail'
+GO
+SET NOCOUNT OFF
+
+--Column type summary
+SELECT c.name, t.name 'data type', c.max_length, c.is_identity
+FROM sys.columns c JOIN sys.types t
+ON t.system_type_id = c.system_type_id AND
+ t.system_type_id = t.user_type_id
+where object_id =
+ (SELECT OBJECT_ID('dbo.vSalePersonNamePhoneEmail', 'VIEW'))
+
+--For display in book
+SELECT CAST(c.name AS nvarchar(13)) 'Column',
+ CAST(t.name AS nvarchar(8)) 'data type',
+ c.max_length,
+ c.is_identity
+FROM sys.columns c JOIN sys.types t
+ON t.system_type_id = c.system_type_id AND
+ t.system_type_id = t.user_type_id
+WHERE object_id IN
+ (SELECT OBJECT_ID('dbo.vSalePersonNamePhoneEmail', 'VIEW'))
+
+--Drop custom views from the AdventureWorks database
+DROP VIEW vSalePersonNamePhoneEmail
+GO
+
+
diff --git a/SamplesForChapter08/Chapter08/AssigningFixedDatabaseRoles.sql b/SamplesForChapter08/Chapter08/AssigningFixedDatabaseRoles.sql
new file mode 100644
index 0000000..4650cc3
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/AssigningFixedDatabaseRoles.sql
@@ -0,0 +1,212 @@
+--Use login for Windows administrator or sa login to connect
+--to SQL Server Express and set AdventureWorks database as
+--the database context
+USE AdventureWorks
+GO
+
+--You can also select from tables
+SELECT * FROM Production.ProductCategory
+GO
+
+--Running from sqllogin1 causes an error because
+--does not have access permission for database
+EXECUTE AS login = 'sqllogin1'
+GO
+
+--Optional statement that is not strictly necessary
+REVERT
+GO
+
+--Enable guest account before and after cheching status of users
+SELECT name, hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+--For display in book
+SELECT CAST(name AS nvarchar(18)) 'name', hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+EXEC sp_adduser 'guest'
+
+SELECT name, hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+--For display in book
+SELECT CAST(name AS nvarchar(18)) 'name', hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+
+--You can now connect
+EXECUTE AS login = 'sqllogin1'
+GO
+
+--but you cannot select
+SELECT * FROM Production.ProductCategory
+GO
+
+REVERT
+GO
+
+--Disable guest user
+EXEC sp_dropuser 'guest'
+
+SELECT name, hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+--For display in book
+SELECT CAST(name AS nvarchar(18)) 'name', hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+
+--Create user from in AdventureWorks based on sqllogin1
+SELECT name, hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+--For display in book
+SELECT CAST(name AS nvarchar(18)) 'name', hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin1')
+ DROP USER sqllogin1
+GO
+
+CREATE USER sqllogin1 FOR LOGIN sqllogin1
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+SELECT name, hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+--For display in book
+SELECT CAST(name AS nvarchar(18)) 'name', hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+
+--Explore fixed database roles
+EXEC sp_helpdbfixedrole
+EXEC sp_dbfixedrolepermission 'db_datareader'
+EXEC sp_dbfixedrolepermission 'db_datawriter'
+
+--Now that sqllogin1 has access to the AdventureWorks
+--database, we can give it SELECT permission
+EXEC sp_addrolemember 'db_datareader', 'sqllogin1'
+
+--You can connect from sqllogin1 to the AdventureWorks database
+EXECUTE AS login = 'sqllogin1'
+GO
+
+--You can also select from tables
+SELECT * FROM Production.ProductCategory
+GO
+
+REVERT
+GO
+
+--Create a fresh copy of the TrackPersons table in the
+--NewDB1 database from the sqllogin1 execution context;
+--insert a row and display the inserted row with a
+--SELECT statement
+EXECUTE AS login = 'sqllogin1'
+GO
+
+USE NewDB1
+GO
+
+IF EXISTS(SELECT * FROM sys.tables WHERE name = 'TrackPersons')
+ DROP TABLE TrackPersons
+GO
+
+CREATE TABLE TrackPersons (
+tpid int Primary Key,
+name nvarchar (30)
+)
+GO
+
+INSERT TrackPersons VALUES (1, 'Rick Dobson')
+GO
+
+SELECT * FROM TrackPersons
+GO
+
+USE AdventureWorks
+GO
+
+REVERT
+GO
+
+
+--Add a fresh copy of hte cab233a\winlogin1 login;
+--revise the computer name from cab233a for your
+--computing environment
+USE master
+GO
+
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'cab233a\winlogin1')
+ DROP LOGIN [cab233a\winlogin1]
+GO
+
+CREATE LOGIN [cab233a\winlogin1] FROM WINDOWS
+GO
+
+USE NewDB1
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'cab233a\winlogin1')
+ DROP USER [cab233a\winlogin1]
+GO
+
+CREATE USER [cab233a\winlogin1] FOR LOGIN [cab233a\winlogin1]
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+--List users in NewDB1
+SELECT name, hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+--For display in book
+SELECT CAST(name AS nvarchar(18)) 'name', hasdbaccess, isntuser, issqluser
+FROM sys.sysusers
+WHERE issqlrole = 0
+
+
+--Assign cab233a\winlogin1 user to db_datareader and db_datawriter roles
+EXEC sp_addrolemember 'db_datareader', 'cab233a\winlogin1'
+EXEC sp_addrolemember 'db_datawriter', 'cab233a\winlogin1'
+
+
+EXECUTE AS login = 'cab233a\winlogin1'
+GO
+
+SELECT * FROM TrackPersons
+GO
+
+INSERT TrackPersons VALUES(2, 'Virginia Dobson')
+GO
+
+SELECT * FROM TrackPersons
+GO
+
+REVERT
+GO
+
+--Clean up
+USE AdventureWorks
+GO
+
+DROP USER sqllogin1
+
+
+
diff --git a/SamplesForChapter08/Chapter08/AssigningFixedServerRoles.sql b/SamplesForChapter08/Chapter08/AssigningFixedServerRoles.sql
new file mode 100644
index 0000000..b9060f7
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/AssigningFixedServerRoles.sql
@@ -0,0 +1,156 @@
+USE master
+GO
+
+--Login as Windows adaministrator and re-create
+--sqllogin1 and cab233a\winlogin1
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin1')
+ DROP LOGIN sqllogin1
+GO
+
+CREATE LOGIN sqllogin1
+ WITH PASSWORD = 'pass_sqllogin1'
+GO
+
+--Switch execution context to sqllogin1 login
+--and try to add a new login named sqllogin2
+EXECUTE AS login = 'sqllogin1'
+GO
+
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin2')
+ DROP LOGIN sqllogin2
+GO
+
+CREATE LOGIN sqllogin2
+ WITH PASSWORD = 'pass_sqllogin2'
+GO
+
+--Return to Windows administrator execution context
+REVERT
+GO
+
+--Explorer fixed server roles overall and drill
+--down on permissions for securityadmin role
+EXEC sp_helpsrvrole
+EXEC sp_srvrolepermission 'securityadmin'
+
+--Add sqllogin1 to the securityadmin fixed server role
+EXEC sp_addsrvrolemember 'sqllogin1', 'securityadmin'
+GO
+
+--Now add the new login from sqllogin1
+EXECUTE AS login = 'sqllogin1'
+GO
+
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin2')
+ DROP LOGIN sqllogin2
+GO
+
+--List logins and properties before adding a new one
+SELECT name, isntgroup, isntuser, securityadmin, sysadmin
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--For display in book
+SELECT CAST(name AS nvarchar(31)) 'name',
+ CAST(isntgroup AS nvarchar(9)) 'isntgroup',
+ CAST(isntuser AS nvarchar(8)) 'isntuser',
+ CAST(securityadmin AS nvarchar(9)) 'securityadmin',
+ CAST(sysadmin AS nvarchar(8)) 'sysadmin'
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+CREATE LOGIN sqllogin2
+ WITH PASSWORD = 'pass_sqllogin2'
+GO
+
+--List logins and properties before adding a new one
+SELECT name, isntgroup, isntuser, securityadmin, sysadmin
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--For display in book
+SELECT CAST(name AS nvarchar(31)) 'name',
+ CAST(isntgroup AS nvarchar(9)) 'isntgroup',
+ CAST(isntuser AS nvarchar(8)) 'isntuser',
+ CAST(securityadmin AS nvarchar(9)) 'securityadmin',
+ CAST(sysadmin AS nvarchar(8)) 'sysadmin'
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--Return to Windows administrator execution context
+REVERT
+GO
+
+--Explorer fixed server roles overall and drill
+--down on permissions for securityadmin role
+EXEC sp_helpsrvrole
+EXEC sp_srvrolepermission 'dbcreator'
+
+--Try to create NewDB1 from sqllogin1 login before adding sqllogin1 to dbcreator
+EXECUTE AS login = 'sqllogin1'
+GO
+
+USE master
+GO
+
+IF EXISTS(SELECT name FROM sys.databases
+ WHERE name = N'NewDB1')
+ DROP DATABASE NewDB1
+GO
+
+CREATE DATABASE NewDB1
+GO
+
+REVERT
+GO
+
+
+--Add sqllogin1 to the securityadmin fixed server role
+EXEC sp_addsrvrolemember 'sqllogin1', 'dbcreator'
+GO
+
+--Now create NewDB1 from sqllogin1 login
+EXECUTE AS login = 'sqllogin1'
+GO
+
+USE master
+GO
+
+IF EXISTS(SELECT name FROM sys.databases
+ WHERE name = N'NewDB1')
+ DROP DATABASE NewDB1
+GO
+
+SELECT COUNT(*) 'NewDB1 is there = 1'
+ FROM sys.databases
+ WHERE name = N'NewDB1'
+GO
+
+CREATE DATABASE NewDB1
+GO
+
+SELECT COUNT(*) 'NewDB1 is there = 1'
+ FROM sys.databases
+ WHERE name = N'NewDB1'
+GO
+
+REVERT
+GO
+
+DROP DATABASE NewDB1
+
+
+EXEC sp_dropsrvrolemember 'sqllogin1', 'dbcreator'
+GO
+
+EXEC sp_dropsrvrolemember 'sqllogin1', 'securityadmin'
+GO
+
+
diff --git a/SamplesForChapter08/Chapter08/CreatingObjectsInOwnedSchemas.sql b/SamplesForChapter08/Chapter08/CreatingObjectsInOwnedSchemas.sql
new file mode 100644
index 0000000..04e88ab
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/CreatingObjectsInOwnedSchemas.sql
@@ -0,0 +1,113 @@
+USE NewDB2
+GO
+
+--Run script in this file only just after running the
+--script in the OwningSchemas.sql
+
+--Grant CREATE TABLE permission for owned schema
+GRANT CREATE TABLE TO sqllogin3
+GO
+
+--Create a table in the user's default schema, which is owned
+EXECUTE AS login = 'sqllogin3'
+
+CREATE TABLE TrackPersons (
+ tpid int Primary Key,
+ name nvarchar (30)
+ )
+GO
+
+SELECT name, schema_id FROM sys.tables
+
+--For display in book
+SELECT CAST(name AS nvarchar(12)) 'name', schema_id FROM sys.tables
+
+REVERT
+GO
+
+
+
+--Drop any prior versions of TrackPersons table in
+--sqllogin3 (schema_id =5) schema
+IF EXISTS(SELECT * FROM sys.tables
+ WHERE name = 'TrackPersons' AND schema_id = 5)
+ DROP TABLE sqllogin3.TrackPersons
+
+
+--Drop sqllogin3 user from sqllogin3SchemaOwner role
+EXEC sp_droprolemember 'sqllogin3SchemaOwner', 'sqllogin3'
+
+--Try again to create a table in the user's default schema
+EXECUTE AS login = 'sqllogin3'
+
+CREATE TABLE TrackPersons (
+ tpid int Primary Key,
+ name nvarchar (30)
+ )
+GO
+
+SELECT name, schema_id FROM sys.tables
+
+--For display in book
+SELECT CAST(name AS nvarchar(12)) 'name', schema_id FROM sys.tables
+
+REVERT
+GO
+
+
+--Drop any prior versions of TrackPersons table in
+--sqllogin3 (schema_id =5) schema
+IF EXISTS(SELECT * FROM sys.tables
+ WHERE name = 'TrackPersons' AND schema_id = 5)
+ DROP TABLE sqllogin3.TrackPersons
+GO
+
+--Grant CREATE TABLE permission for owned schema
+GRANT CREATE TABLE TO sqllogin4
+GO
+
+--Create a table in the user's owned schema
+EXECUTE AS login = 'sqllogin4'
+
+CREATE TABLE sqllogin3.TrackPersons (
+ tpid int Primary Key,
+ name nvarchar (30)
+ )
+GO
+
+SELECT name, schema_id FROM sys.tables
+
+--For display in book
+SELECT CAST(name AS nvarchar(12)) 'name', schema_id FROM sys.tables
+
+--Drop any prior versions of TrackPersons table in
+--sqllogin3 (schema_id =5) schema
+IF EXISTS(SELECT * FROM sys.tables
+ WHERE name = 'TrackPersons' AND schema_id = 5)
+ DROP TABLE sqllogin3.TrackPersons
+
+REVERT
+GO
+
+
+
+--Try again to create a table in the user's default schema
+EXECUTE AS login = 'sqllogin4'
+
+CREATE TABLE TrackPersons (
+ tpid int Primary Key,
+ name nvarchar (30)
+ )
+GO
+
+SELECT name, schema_id FROM sys.tables
+
+--For display in book
+SELECT CAST(name AS nvarchar(12)) 'name', schema_id FROM sys.tables
+
+REVERT
+GO
+
+
+
+
diff --git a/SamplesForChapter08/Chapter08/CreatingObjesInAnySchema.sql b/SamplesForChapter08/Chapter08/CreatingObjesInAnySchema.sql
new file mode 100644
index 0000000..8f8e01b
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/CreatingObjesInAnySchema.sql
@@ -0,0 +1,72 @@
+USE NewDB2
+GO
+
+--Drop any prior versions of TrackPersons table in
+--dbo (schema_id = 1) and sqllogin3 (schema_id =5) schemas
+IF EXISTS(SELECT * FROM sys.tables
+ WHERE name = 'TrackPersons' AND schema_id = 1)
+ DROP TABLE dbo.TrackPersons
+IF EXISTS(SELECT * FROM sys.tables
+ WHERE name = 'TrackPersons' AND schema_id = 5)
+ DROP TABLE sqllogin3.TrackPersons
+GO
+
+--Add sqllogin3 to db_ddladmin fixed databaes role
+EXEC sp_addrolemember 'db_ddladmin', 'sqllogin4'
+GO
+
+--Execute as database user for sqllogin3 login
+EXECUTE AS login = 'sqllogin4'
+
+--Specify dbo or sqllogin3 for schema name
+DECLARE @sname nvarchar(18)
+SET @sname = 'sqllogin3'
+
+IF EXISTS(SELECT *
+ FROM sys.tables t
+ JOIN sys.schemas s
+ ON t.schema_id = s.schema_id
+ WHERE t.name = 'TrackPersons' AND s.name = @sname
+ AND @sname = 'dbo')
+BEGIN
+ DROP TABLE dbo.TrackPersons
+ print 'Dropped TrackPersons table in dbo schema'
+END
+ELSE IF EXISTS(SELECT *
+ FROM sys.tables t
+ JOIN sys.schemas s
+ ON t.schema_id = s.schema_id
+ WHERE t.name = 'TrackPersons' AND s.name = @sname
+ AND @sname = 'sqllogin3')
+BEGIN
+ DROP TABLE sqllogin3.TrackPersons
+ print 'Dropped TrackPersons table in sqllogin3 schema'
+END
+ELSE IF (@sname <> 'dbo' AND @sname <> 'sqllogin3')
+ PRINT 'Specify schema name of dbo or sqllogin3.'
+
+IF @sname = 'dbo'
+BEGIN
+ CREATE TABLE dbo.TrackPersons (
+ tpid int Primary Key,
+ name nvarchar (30)
+ )
+ Print 'Created TrackPersons table in dbo schema.'
+END
+ELSE IF @sname = 'sqllogin3'
+BEGIN
+ CREATE TABLE sqllogin3.TrackPersons (
+ tpid int Primary Key,
+ name nvarchar (30)
+ )
+ Print 'Created TrackPersons table in sqllogin3 schema.'
+END
+ELSE print 'Did not create table.'
+
+REVERT
+GO
+
+
+
+
+
diff --git a/SamplesForChapter08/Chapter08/CreatingPrincipals.sql b/SamplesForChapter08/Chapter08/CreatingPrincipals.sql
new file mode 100644
index 0000000..5d12bd0
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/CreatingPrincipals.sql
@@ -0,0 +1,288 @@
+USE master
+GO
+
+--Display non-internal server-based principals before adding new login
+SELECT name, principal_id, type_desc
+FROM sys.server_principals
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--FOR display in book
+SELECT CAST(name AS nvarchar(31)) 'name',
+ principal_id, CAST(type_desc AS nvarchar(24)) 'type_desc'
+FROM sys.server_principals
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--Create sqllogin1 with password of pass_sqllogin1
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin1')
+ DROP LOGIN sqllogin1
+GO
+
+CREATE LOGIN sqllogin1
+ WITH PASSWORD = 'pass_sqllogin1'
+GO
+
+--Display non-internal server-based principals after adding new login
+SELECT name, principal_id, type_desc
+FROM sys.server_principals
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--FOR display in book
+SELECT CAST(name AS nvarchar(31)) 'name',
+ principal_id, CAST(type_desc AS nvarchar(24)) 'type_desc'
+FROM sys.server_principals
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+EXECUTE AS login = 'sqllogin1'
+GO
+
+SELECT name, principal_id, type_desc
+FROM sys.server_principals
+WHERE LEFT(name, 4) <> '##MS' AND
+ type_desc<> 'SERVER_ROLE'
+GO
+
+--Display non-internal logins after adding new login
+SELECT name, hasaccess, isntname, isntgroup, isntuser, sysadmin
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+EXECUTE AS login = 'sqllogin1'
+GO
+
+--Display non-internal logins after adding new login
+SELECT name, hasaccess, isntname, isntgroup, isntuser, sysadmin
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--Revert to previous execution context
+REVERT
+GO
+
+
+--Display non-internal logins before adding new Windows login
+SELECT name, hasaccess, isntname, isntgroup, isntuser, sysadmin
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--For display in book
+SELECT CAST(name AS nvarchar(31)) 'name',
+ CAST(hasaccess AS nvarchar(9)) 'hasaccess',
+ CAST(isntname AS nvarchar(8)) 'isntname',
+ CAST(isntgroup AS nvarchar(9)) 'isntgroup',
+ CAST(isntuser AS nvarchar(8)) 'isntuser',
+ CAST(sysadmin AS nvarchar(8)) 'sysadmin'
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--Create SQL Server Express winlogin1 login
+--from winlogin1 Windows login
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'cab233a\winlogin1')
+ DROP LOGIN [cab233a\winlogin1]
+GO
+
+CREATE LOGIN [cab233a\winlogin1] FROM WINDOWS
+GO
+
+--Display non-internal logins after adding new Windows login
+SELECT name, hasaccess, isntname, isntgroup, isntuser, sysadmin
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--For display in book
+SELECT CAST(name AS nvarchar(17)) 'name',
+ CAST(hasaccess AS nvarchar(9)) 'hasaccess',
+ CAST(isntname AS nvarchar(8)) 'isntname',
+ CAST(isntgroup AS nvarchar(9)) 'isntgroup',
+ CAST(isntuser AS nvarchar(8)) 'isntuser',
+ CAST(sysadmin AS nvarchar(8)) 'sysadmin'
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--Run in winlogin1 login context
+EXECUTE AS login = 'cab233a\winlogin1'
+GO
+
+--Display non-internal logins after adding new Windows login
+SELECT name, hasaccess, isntname, isntgroup, isntuser, sysadmin
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--For display in book
+SELECT CAST(name AS nvarchar(17)) 'name',
+ CAST(hasaccess AS nvarchar(9)) 'hasaccess',
+ CAST(isntname AS nvarchar(8)) 'isntname',
+ CAST(isntgroup AS nvarchar(9)) 'isntgroup',
+ CAST(isntuser AS nvarchar(8)) 'isntuser',
+ CAST(sysadmin AS nvarchar(8)) 'sysadmin'
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--Restore Windows admin account
+REVERT
+GO
+
+EXECUTE AS login = 'sqllogin1'
+GO
+
+--Display non-internal logins after adding new Windows login
+SELECT name, hasaccess, isntname, isntgroup, isntuser, sysadmin
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--For display in book
+SELECT CAST(name AS nvarchar(17)) 'name',
+ CAST(hasaccess AS nvarchar(9)) 'hasaccess',
+ CAST(isntname AS nvarchar(8)) 'isntname',
+ CAST(isntgroup AS nvarchar(9)) 'isntgroup',
+ CAST(isntuser AS nvarchar(8)) 'isntuser',
+ CAST(sysadmin AS nvarchar(8)) 'sysadmin'
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--Restore Windows admin account
+REVERT
+GO
+
+
+--Execute AS does not properly simulate account when
+--there is no BUILTIN\Users account
+--Run in winlogin2 login context
+EXECUTE AS login = 'cab233a\winlogin2'
+GO
+
+--Display non-internal logins after adding new Windows login
+SELECT name, hasaccess, isntname, isntgroup, isntuser, sysadmin
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--For display in book
+SELECT CAST(name AS nvarchar(17)) 'name',
+ CAST(hasaccess AS nvarchar(9)) 'hasaccess',
+ CAST(isntname AS nvarchar(8)) 'isntname',
+ CAST(isntgroup AS nvarchar(9)) 'isntgroup',
+ CAST(isntuser AS nvarchar(8)) 'isntuser',
+ CAST(sysadmin AS nvarchar(8)) 'sysadmin'
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+REVERT
+GO
+
+
+--Run in winlogin3 login context; winlogin3 does not exist
+EXECUTE AS login = 'cab233a\winlogin3'
+GO
+
+--Result set is for Windows administrator
+SELECT name, hasaccess, isntname, isntgroup, isntuser, sysadmin
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+--For display in book
+SELECT CAST(name AS nvarchar(31)) 'name',
+ CAST(hasaccess AS nvarchar(9)) 'hasaccess',
+ CAST(isntname AS nvarchar(8)) 'isntname',
+ CAST(isntgroup AS nvarchar(9)) 'isntgroup',
+ CAST(isntuser AS nvarchar(8)) 'isntuser',
+ CAST(sysadmin AS nvarchar(8)) 'sysadmin'
+FROM sys.syslogins
+WHERE LEFT(name, 4) <> '##MS'
+GO
+
+REVERT
+GO
+
+--Switch the database context to NewDB (see ExploringPrincipals.sql)
+USE NewDB
+GO
+
+--Dislay database-based principals
+SELECT name, principal_id, type_desc,
+ default_schema_name, is_fixed_role
+FROM sys.database_principals
+
+--For display in book
+SELECT CAST(name AS nvarchar(18)) 'name', principal_id, CAST(type_desc AS nvarchar(13)) 'type_desc',
+ CAST(default_schema_name AS nvarchar(19)) 'default_schema_name', is_fixed_role
+FROM sys.database_principals
+
+--Create a user for sqllogin1 in the guest schema
+IF EXISTS(SELECT * FROM sys.sysusers WHERE name = 'sqllogin1')
+ DROP USER sqllogin1
+GO
+
+CREATE USER sqllogin1 FOR LOGIN sqllogin1 WITH DEFAULT_SCHEMA = guest
+GO
+
+--Dislay database-based principals
+SELECT name, principal_id, type_desc,
+ default_schema_name, is_fixed_role
+FROM sys.database_principals
+
+--For display in book
+SELECT CAST(name AS nvarchar(18)) 'name', principal_id, CAST(type_desc AS nvarchar(13)) 'type_desc',
+ CAST(default_schema_name AS nvarchar(19)) 'default_schema_name', is_fixed_role
+FROM sys.database_principals
+GO
+
+--Create a user for sqllogin1 in the default schema (dbo)
+IF EXISTS(SELECT * FROM sys.sysusers WHERE name = 'sqllogin1')
+ DROP USER sqllogin1
+GO
+
+CREATE USER sqllogin1 FOR LOGIN sqllogin1
+GO
+
+--Dislay database-based principals
+SELECT name, principal_id, type_desc,
+ default_schema_name, is_fixed_role
+FROM sys.database_principals
+WHERE name = 'sqllogin1'
+GO
+
+--For display in book
+SELECT CAST(name AS nvarchar(18)) 'name', principal_id, CAST(type_desc AS nvarchar(13)) 'type_desc',
+ CAST(default_schema_name AS nvarchar(19)) 'default_schema_name', is_fixed_role
+FROM sys.database_principals
+WHERE name = 'sqllogin1'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers WHERE name = 'cab233a\winlogin1')
+ DROP USER [cab233a\winlogin1]
+GO
+
+CREATE USER [cab233a\winlogin1] FOR LOGIN [cab233a\winlogin1]
+GO
+
+--Dislay database-based principals
+SELECT name, principal_id, type_desc,
+ default_schema_name, is_fixed_role
+FROM sys.database_principals
+WHERE type_desc <> 'DATABASE_ROLE'
+GO
+
+SELECT CAST(name AS nvarchar(18)) 'name', principal_id, CAST(type_desc AS nvarchar(13)) 'type_desc',
+ CAST(default_schema_name AS nvarchar(19)) 'default_schema_name', is_fixed_role
+FROM sys.database_principals
+WHERE type_desc <> 'DATABASE_ROLE'
+GO
+
diff --git a/SamplesForChapter08/Chapter08/EncryptingDecryptingData.sql b/SamplesForChapter08/Chapter08/EncryptingDecryptingData.sql
new file mode 100644
index 0000000..cfef4eb
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/EncryptingDecryptingData.sql
@@ -0,0 +1,37 @@
+USE NewDB3
+GO
+
+--Insert a row
+DECLARE @name nvarchar(20), @in_id_data nvarchar(70)
+
+SET @name = 'Rick Dobson'
+SET @in_id_data = '111-11-1111'
+INSERT ForEncDemo (name, id_data_orig) VALUES(@name, @in_id_data)
+GO
+
+--Encrypt a column value
+DECLARE @pp_value nvarchar(10)
+
+SET @pp_value = 'passphrase'
+
+UPDATE ForEncDemo
+SET id_data_enc = EncryptByPassPhrase(@pp_value, id_data_orig,
+ 1,
+ CONVERT( varbinary, rowid))
+WHERE rowid = 1
+GO
+
+--Decrypt an ecrypted value
+DECLARE @pp_value nvarchar(10);
+SET @pp_value = 'passphrase';
+
+-- Decrypt the encrypted record.
+SELECT id_data_orig, id_data_enc AS "Encrypted data",
+ CONVERT(nvarchar, DecryptByPassphrase(@pp_value, id_data_enc,
+ 1,
+ CONVERT(varbinary, rowid))) AS "Decrypted data"
+FROM ForEncDemo
+WHERE rowid = 1;
+GO
+
+
diff --git a/SamplesForChapter08/Chapter08/EncryptingDecryptingData_old.sql b/SamplesForChapter08/Chapter08/EncryptingDecryptingData_old.sql
new file mode 100644
index 0000000..4dc70b0
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/EncryptingDecryptingData_old.sql
@@ -0,0 +1,34 @@
+USE NewDB3
+GO
+
+DECLARE @pp_value nvarchar(128),
+ @name nvarchar(2000), @in_id_data varchar(1100)
+
+SET @pp_value = 'passphrase'
+
+--Insert a row with an encrypted column value
+SET @name = 'Rick Dobson'
+SET @in_id_data = '111-11-1111'
+INSERT ForEncDemo VALUES(@name, @in_id_data,
+ EncryptByPassPhrase(@pp_value, @in_id_data,1,CONVERT(varbinary, @in_id_data)))
+
+--Insert another row with an encrypted column value
+SET @name = 'Virginia Dobson'
+SET @in_id_data = '222-22-2222'
+INSERT ForEncDemo VALUES(@name, @in_id_data,
+ EncryptByPassPhrase(@pp_value, @in_id_data,1,CONVERT(varbinary,@in_id_data)))
+
+
+--Display all table column values
+SELECT rowid, name, id_data_orig,
+ CAST(id_data_enc AS varbinary(5)) 'id_data_dec'
+FROM ForEncDemo
+
+--Display original versus decrypted column values
+SELECT rowid, id_data_orig,
+ CONVERT(varchar(110),
+ DecryptByPassPhrase(@pp_value,id_data_enc)) 'id_data_enc Decrypted'
+FROM ForEncDemo
+
+
+
diff --git a/SamplesForChapter08/Chapter08/ExploringPrincipals.sql b/SamplesForChapter08/Chapter08/ExploringPrincipals.sql
new file mode 100644
index 0000000..45e878c
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/ExploringPrincipals.sql
@@ -0,0 +1,51 @@
+USE master
+GO
+
+--Display server-based principals, excluding those
+--for internal use
+SELECT name, principal_id, type_desc
+FROM sys.server_principals
+WHERE LEFT(name, 4) <> '##MS'
+
+--FOR display in book
+SELECT CAST(name AS nvarchar(31)) 'name',
+ principal_id, CAST(type_desc AS nvarchar(24)) 'type_desc'
+FROM sys.server_principals
+WHERE LEFT(name, 4) <> '##MS'
+
+
+EXEC sp_helpsrvrole
+EXEC sp_helpsrvrolemember 'sysadmin'
+EXEC sp_srvrolepermission 'bulkadmin'
+
+--Crate a database named NewDB
+USE master
+GO
+
+IF EXISTS(SELECT name FROM sys.databases
+ WHERE name = N'NewDB')
+ DROP DATABASE NewDB
+GO
+
+CREATE DATABASE NewDB
+GO
+
+USE NewDB
+GO
+
+--Dislay database-based principals
+SELECT name, principal_id, type_desc,
+ default_schema_name, is_fixed_role
+FROM sys.database_principals
+
+--For display in book
+SELECT CAST(name AS nvarchar(18)) 'name', principal_id, CAST(type_desc AS nvarchar(13)) 'type_desc',
+ CAST(default_schema_name AS nvarchar(19)) 'default_schema_name', is_fixed_role
+FROM sys.database_principals
+
+EXEC sp_helpdbfixedrole
+EXEC sp_helprolemember 'db_owner'
+EXEC sp_dbfixedrolepermission
+
+
+
diff --git a/SamplesForChapter08/Chapter08/ImpersonatingPrincipalsInModules.sql b/SamplesForChapter08/Chapter08/ImpersonatingPrincipalsInModules.sql
new file mode 100644
index 0000000..0a93c58
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/ImpersonatingPrincipalsInModules.sql
@@ -0,0 +1,153 @@
+USE AdventureWorks
+GO
+
+--Create logins and users named sqllogin3, sqllogin4, sqllogin5
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin3')
+ DROP LOGIN sqllogin3
+GO
+
+CREATE LOGIN sqllogin3
+ WITH PASSWORD = 'pass_sqllogin3'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin3')
+ DROP USER sqllogin3
+GO
+
+CREATE USER sqllogin3 FOR LOGIN sqllogin3
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin4')
+ DROP LOGIN sqllogin4
+GO
+
+CREATE LOGIN sqllogin4
+ WITH PASSWORD = 'pass_sqllogin4'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin4')
+ DROP USER sqllogin4
+GO
+
+CREATE USER sqllogin4 FOR LOGIN sqllogin4
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin5')
+ DROP LOGIN sqllogin5
+GO
+
+CREATE LOGIN sqllogin5
+ WITH PASSWORD = 'pass_sqllogin5'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin5')
+ DROP USER sqllogin5
+GO
+
+CREATE USER sqllogin5 FOR LOGIN sqllogin5
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+--Optional statement to check role memberships
+EXEC sp_helprolemember
+
+--Add sqllogin3 to db_ddladmin role
+EXEC sp_addrolemember 'db_ddladmin', 'sqllogin3'
+
+--Create a stored proc without WITH EXECUTE AS clause
+EXECUTE AS login = 'sqllogin3'
+
+IF EXISTs(SELECT *
+ FROM sys.objects
+ WHERE type = 'P' AND name = 'NOEXECUTEAS')
+ DROP PROCEDURE NOEXECUTEAS
+GO
+
+CREATE PROC NOEXECUTEAS
+@colnames varchar(100),
+@tblname varchar(50)
+AS
+
+SELECT USER
+
+EXEC ('SELECT ' + @colnames + ' FROM ' + @tblname)
+GO
+
+REVERT
+GO
+
+
+--Execute stored proc from sqllogin5 after granting
+--EXEC permission to user
+GRANT EXEC ON NOEXECUTEAS TO sqllogin5
+GO
+
+EXECUTE AS login = 'sqllogin5'
+GO
+
+EXEC NOEXECUTEAS 'ProductCategoryID, Name',
+ 'Production.ProductCategory'
+GO
+
+REVERT
+GO
+
+
+--Create a stored proc with dynamic sql that runs
+--as sqllogin4
+GRANT IMPERSONATE ON USER::sqllogin4 TO sqllogin3
+
+EXECUTE AS login = 'sqllogin3'
+GO
+
+IF EXISTs(SELECT *
+ FROM sys.objects
+ WHERE type = 'P' AND name = 'SPASSQLLOGIN4')
+ DROP PROCEDURE SPASSQLLOGIN4
+GO
+
+CREATE PROC SPASSQLLOGIN4
+@colnames varchar(100),
+@tblname varchar(50)
+WITH EXECUTE AS 'sqllogin4'
+AS
+
+SELECT USER
+
+EXEC ('SELECT ' + @colnames + ' FROM ' + @tblname)
+GO
+
+REVERT
+GO
+
+GRANT SELECT ON Production.ProductCategory TO sqllogin4
+GRANT EXEC ON SPASSQLLOGIN4 TO sqllogin5
+GO
+
+
+EXECUTE AS login = 'sqllogin5'
+GO
+
+EXEC SPASSQLLOGIN4 'ProductCategoryID, Name',
+ 'Production.ProductCategory'
+GO
+
+EXEC SPASSQLLOGIN4 'EmployeeID', 'HumanResources.Employee'
+GO
+
+REVERT
+GO
+
+--Clean up
+EXEC sp_droprolemember 'db_ddladmin', 'sqllogin3'
+
+
+
diff --git a/SamplesForChapter08/Chapter08/OwningSchemas.sql b/SamplesForChapter08/Chapter08/OwningSchemas.sql
new file mode 100644
index 0000000..d74d651
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/OwningSchemas.sql
@@ -0,0 +1,153 @@
+USE master
+GO
+
+--Create NewDB2 database
+IF EXISTS(SELECT * FROM sys.databases
+ WHERE name = 'NewDB2')
+ DROP DATABASE NewDB2
+GO
+
+CREATE DATABASE NewDB2
+GO
+
+--Switch to NewDB database context
+USE NewDB2
+GO
+
+--Display schema ID and name along with owner principal ID and name
+SELECT s.schema_id, s.name 'Schema name', s.principal_id,
+ dp.name 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--For display in book
+SELECT s.schema_id, CAST(s.name AS nvarchar(18)) 'Schema name', s.principal_id, CAST(dp.name AS nvarchar(20)) 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+
+
+--Create sqllogin3 login and user with
+--user having default schema of sqllogin3
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin3')
+ DROP LOGIN sqllogin3
+GO
+
+CREATE LOGIN sqllogin3
+ WITH PASSWORD = 'pass_sqllogin3'
+GO
+
+--Drop sqllogin3 schema before trying to drop
+--sqllogin3 user
+IF EXISTS(SELECT * FROM sys.schemas
+ WHERE name = 'sqllogin3')
+ DROP SCHEMA sqllogin3
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin3')
+ DROP USER sqllogin3
+GO
+
+CREATE USER sqllogin3 FOR LOGIN sqllogin3
+ WITH DEFAULT_SCHEMA = sqllogin3
+GO
+
+--Create schema specified in CREATE USER statement
+--for the sqllogin3 user
+CREATE SCHEMA sqllogin3 AUTHORIZATION sqllogin3
+GO
+
+--Display schema ID and name along with owner principal ID and name
+SELECT s.schema_id, s.name 'Schema name',
+ s.principal_id, dp.name 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--For display in book
+SELECT s.schema_id, CAST(s.name AS nvarchar(18)) 'Schema name', s.principal_id, CAST(dp.name AS nvarchar(20)) 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--Create sqllogin4 login and user with
+--no default schema spec for the user;
+--assign login as owner of sqllogin3 schema
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin4')
+ DROP LOGIN sqllogin4
+GO
+
+CREATE LOGIN sqllogin4
+ WITH PASSWORD = 'pass_sqllogin4'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin4')
+ DROP USER sqllogin4
+GO
+
+CREATE USER sqllogin4 FOR LOGIN sqllogin4
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+ALTER AUTHORIZATION ON SCHEMA::sqllogin3 TO sqllogin4
+GO
+
+
+--Display schema ID and name along with owner principal ID and name
+SELECT s.schema_id, s.name 'Schema name', s.principal_id, dp.name 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--For display in book
+SELECT s.schema_id, CAST(s.name AS nvarchar(18)) 'Schema name', s.principal_id, CAST(dp.name AS nvarchar(20)) 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--Create role, add users to it, and make the role the owner
+--of the sqllogin3 schema
+--SELECT * FROM sys.sysusers
+
+--Clear sqllogin3SchemaOwner members and ownership before dropping
+IF EXISTS(SELECT * FROM sys.database_principals
+ WHERE name = 'sqllogin3SchemaOwner'
+ AND type_desc = 'DATABASE_ROLE')
+BEGIN
+ EXEC sp_droprolemember 'sqllogin3SchemaOwner', 'sqllogin3'
+ EXEC sp_droprolemember 'sqllogin3SchemaOwner', 'sqllogin4'
+ ALTER AUTHORIZATION ON SCHEMA::sqllogin3 TO dbo
+ DROP ROLE sqllogin3SchemaOwner
+END
+GO
+
+--Create role, add users to it, and make the role the owner
+--of the sqllogin3 schema
+CREATE ROLE sqllogin3SchemaOwner
+EXEC sp_addrolemember 'sqllogin3SchemaOwner', 'sqllogin3'
+EXEC sp_addrolemember 'sqllogin3SchemaOwner', 'sqllogin4'
+ALTER AUTHORIZATION ON SCHEMA::sqllogin3 TO sqllogin3SchemaOwner
+GO
+
+
+--Display schema ID and name along with owner principal ID and name
+SELECT s.schema_id, s.name 'Schema name', s.principal_id, dp.name 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--For display in book
+SELECT s.schema_id, CAST(s.name AS nvarchar(18)) 'Schema name', s.principal_id, CAST(dp.name AS nvarchar(20)) 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+
+
+
diff --git a/SamplesForChapter08/Chapter08/PermissionsAndRoles.sql b/SamplesForChapter08/Chapter08/PermissionsAndRoles.sql
new file mode 100644
index 0000000..f2d3aac
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/PermissionsAndRoles.sql
@@ -0,0 +1,102 @@
+USE NewDB1
+GO
+
+--cREATE stored proc to restore TrackPersons table values
+IF EXISTs(SELECT *
+ FROM sys.objects
+ WHERE type = 'P' AND name = 'RestoreTrackPersons')
+ DROP PROCEDURE RestoreTrackPersons
+GO
+
+CREATE PROC RestoreTrackPersons
+AS
+
+DELETE FROM TrackPersons
+
+INSERT TrackPersons VALUES(1, 'Rick Dobosn')
+INSERT TrackPersons vALUES(2, 'Virginia Dobson')
+INSERT TrackPersons VALUES(3, 'Name to change')
+INSERT TrackPersons VALUES(4, 'Name to delete')
+GO
+
+
+--List role memberships to show permissions for users
+EXEC sp_helprolemember
+
+--Restore TrackPersons table and display results
+EXEC RestoreTrackPersons
+SELECT * FROM TrackPersons
+
+--Attempt to perform update and delete in
+--execution context of cab233a\winlogin1
+EXECUTE AS login = 'cab233a\winlogin1'
+
+UPDATE TrackPersons
+SET name = 'Name changed'
+WHERE tpid = 3
+
+DELETE FROM TrackPersons WHERE tpid = 4
+GO
+SELECT * FROM TrackPersons
+GO
+
+REVERT
+GO
+
+--Restore TrackPersons table and deny
+--cab233a from updating in TrackPersons
+EXEC RestoreTrackPersons
+DENY UPDATE ON TrackPersons TO [Cab233a\winlogin1]
+GO
+
+
+--Attempt to perform update and delete in
+--execution context of cab233a\winlogin1
+EXECUTE AS login = 'cab233a\winlogin1'
+
+UPDATE TrackPersons
+SET name = 'Name changed'
+WHERE tpid = 3
+
+DELETE FROM TrackPersons WHERE tpid = 4
+GO
+SELECT * FROM TrackPersons
+GO
+
+REVERT
+GO
+
+
+--Restore TrackPersons table and
+--revoke cab233a denial of updating in TrackPersons and
+--deny cab233a from deleting in TrackPersons
+EXEC RestoreTrackPersons
+REVOKE UPDATE ON TrackPersons TO [Cab233a\winlogin1]
+DENY DELETE ON TrackPersons TO [Cab233a\winlogin1]
+GO
+
+
+
+--Attempt to perform update and delete in
+--execution context of cab233a\winlogin1
+EXECUTE AS login = 'cab233a\winlogin1'
+
+UPDATE TrackPersons
+SET name = 'Name changed'
+WHERE tpid = 3
+
+DELETE FROM TrackPersons WHERE tpid = 4
+GO
+SELECT * FROM TrackPersons
+GO
+
+REVERT
+GO
+
+--REVOKE UPDATE ON TrackPersons TO [Cab233a\winlogin1]
+REVOKE DELETE ON TrackPersons TO [Cab233a\winlogin1]
+GO
+
+
+
+
diff --git a/SamplesForChapter08/Chapter08/PermissionsOrRoles.sql b/SamplesForChapter08/Chapter08/PermissionsOrRoles.sql
new file mode 100644
index 0000000..ae52717
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/PermissionsOrRoles.sql
@@ -0,0 +1,66 @@
+USE AdventureWorks
+GO
+
+--Create fresh copies of sqllogin2 login and user
+--in AdventureWorks database
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin2')
+ DROP LOGIN sqllogin2
+GO
+
+CREATE LOGIN sqllogin2
+ WITH PASSWORD = 'pass_sqllogin2'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin2')
+ DROP USER sqllogin2
+GO
+
+CREATE USER sqllogin2 FOR LOGIN sqllogin2
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+--Demo that login grants access, but not SELECT permission
+EXECUTE AS login = 'sqllogin2'
+SELECT ProductCategoryID, Name FROM Production.ProductCategory
+GO
+
+REVERT
+GO
+
+--Grant SELECT permission for a single table
+GRANT SELECT ON Production.ProductCategory TO sqllogin2
+GO
+
+--Demo that you can read one table but not another for sqllogin2 user
+EXECUTE AS login = 'sqllogin2'
+SELECT ProductCategoryID, Name FROM Production.ProductCategory
+GO
+SELECT COUNT(*)
+FROM Production.ProductSubcategory
+GO
+
+REVERT
+GO
+
+--Show members of db_datareader role
+EXEC sp_helprolemember 'db_datareader'
+
+--Demo htat you can read from more than one table with membership
+--in the db_datareader role
+EXECUTE AS login = 'sqllogin1'
+SELECT ProductCategoryID, Name FROM Production.ProductCategory
+GO
+SELECT COUNT(*)
+FROM Production.ProductSubcategory
+GO
+
+REVERT
+GO
+
+--Clean up
+REVOKE SELECT ON Production.ProductCategory TO sqllogin2
+DROP USER sqllogin2
+GO
+
diff --git a/SamplesForChapter08/Chapter08/Query1.sql b/SamplesForChapter08/Chapter08/Query1.sql
new file mode 100644
index 0000000..f1a5e59
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/Query1.sql
@@ -0,0 +1,132 @@
+USE master
+GO
+
+--Create NewDB2 database
+IF EXISTS(SELECT * FROM sys.databases
+ WHERE name = 'NewDB2')
+ DROP DATABASE NewDB2
+GO
+
+CREATE DATABASE NewDB2
+GO
+
+--Switch to NewDB database context
+USE NewDB2
+GO
+
+--display built-in schemas immediately after
+--the creation of a database
+
+--Display schema ID and name along with owner principal ID and name
+SELECT s.schema_id, s.name 'Schema name', s.principal_id,
+ dp.name 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--For display in book
+SELECT s.schema_id, CAST(s.name AS nvarchar(18)) 'Schema name', s.principal_id, CAST(dp.name AS nvarchar(20)) 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+
+
+--Create sqllogin3 login and user with
+--user having default schema of sqllogin3
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin3')
+ DROP LOGIN sqllogin3
+GO
+
+CREATE LOGIN sqllogin3
+ WITH PASSWORD = 'pass_sqllogin3'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin3')
+ DROP USER sqllogin3
+GO
+
+CREATE USER sqllogin3 FOR LOGIN sqllogin3
+ WITH DEFAULT_SCHEMA = sqllogin3
+GO
+
+--Create schema specified in CREATE USER statement
+--for the sqllogin3 user
+CREATE SCHEMA sqllogin3 AUTHORIZATION sqllogin3
+GO
+
+--Display schema ID and name along with owner principal ID and name
+SELECT s.schema_id, s.name 'Schema name', s.principal_id, dp.name 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--For display in book
+SELECT s.schema_id, CAST(s.name AS nvarchar(18)) 'Schema name', s.principal_id, CAST(dp.name AS nvarchar(20)) 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--Create sqllogin4 login and user with
+--no default schema spec for the user;
+--assign login as owner of sqllogin3 schema
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin4')
+ DROP LOGIN sqllogin4
+GO
+
+CREATE LOGIN sqllogin4
+ WITH PASSWORD = 'pass_sqllogin4'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin4')
+ DROP USER sqllogin4
+GO
+
+CREATE USER sqllogin4 FOR LOGIN sqllogin4
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+ALTER AUTHORIZATION ON SCHEMA::sqllogin3 TO sqllogin4
+GO
+
+
+--Display schema ID and name along with owner principal ID and name
+SELECT s.schema_id, s.name 'Schema name', s.principal_id, dp.name 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--For display in book
+SELECT s.schema_id, CAST(s.name AS nvarchar(18)) 'Schema name', s.principal_id, CAST(dp.name AS nvarchar(20)) 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--Create role, add users to it, and make the role the owner
+--of the sqllogin3 schema
+CREATE ROLE sqllogin3SchemaOwner
+EXEC sp_addrolemember 'sqllogin3SchemaOwner', 'sqllogin3'
+EXEC sp_addrolemember 'sqllogin3SchemaOwner', 'sqllogin4'
+ALTER AUTHORIZATION ON SCHEMA::sqllogin3 TO sqllogin3SchemaOwner
+GO
+
+
+--Display schema ID and name along with owner principal ID and name
+SELECT s.schema_id, s.name 'Schema name', s.principal_id, dp.name 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+--For display in book
+SELECT s.schema_id, CAST(s.name AS nvarchar(18)) 'Schema name', s.principal_id, CAST(dp.name AS nvarchar(20)) 'Principal name'
+FROM sys.schemas s RIGHT JOIN sys.database_principals dp
+ON s.principal_id = dp.principal_id
+WHERE dp.is_fixed_role = 0 AND dp.name <> 'public'
+
+
+
+
diff --git a/SamplesForChapter08/Chapter08/Query2.sql b/SamplesForChapter08/Chapter08/Query2.sql
new file mode 100644
index 0000000..42947ea
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/Query2.sql
@@ -0,0 +1,62 @@
+USE NewDB2
+GO
+
+--Add sqllogin3 to db_ddladmin fixed databaes role
+EXEC sp_addrolemember 'db_ddladmin', 'sqllogin3'
+GO
+
+--Execute as database user for sqllogin3 login
+EXECUTE AS login = 'sqllogin3'
+
+--Specify dbo or sqllogin3 for schema name
+DECLARE @sname nvarchar(18)
+SET @sname = 'dbo'
+
+IF EXISTS(SELECT *
+ FROM sys.tables t
+ JOIN sys.schemas s
+ ON t.schema_id = s.schema_id
+ WHERE t.name = 'TrackPersons' AND s.name = @sname
+ AND @sname = 'dbo')
+BEGIN
+ DROP TABLE dbo.TrackPersons
+ print 'Dropped TrackPersons table in dbo schema'
+END
+ELSE IF EXISTS(SELECT *
+ FROM sys.tables t
+ JOIN sys.schemas s
+ ON t.schema_id = s.schema_id
+ WHERE t.name = 'TrackPersons' AND s.name = @sname
+ AND @sname = 'sqllogin3')
+BEGIN
+ DROP TABLE sqllogin3.TrackPersons
+ print 'Dropped TrackPersons table in sqllogin3 schema'
+END
+ELSE IF (@sname <> 'dbo' AND @sname <> 'sqllogin3')
+ PRINT 'Specify schema name of dbo or sqllogin3.'
+
+IF @sname = 'dbo'
+BEGIN
+ CREATE TABLE dbo.TrackPersons (
+ tpid int Primary Key,
+ name nvarchar (30)
+ )
+ Print 'Created TrackPersons table in dbo schema.'
+END
+ELSE IF @sname = 'sqllogin3'
+BEGIN
+ CREATE TABLE sqllogin3.TrackPersons (
+ tpid int Primary Key,
+ name nvarchar (30)
+ )
+ Print 'Created TrackPersons table in sqllogin3 schema.'
+END
+ELSE print 'Did not create table.'
+
+REVERT
+GO
+
+
+
+
+
diff --git a/SamplesForChapter08/Chapter08/SettingUpEncSignDemo.sql b/SamplesForChapter08/Chapter08/SettingUpEncSignDemo.sql
new file mode 100644
index 0000000..4b6c3d6
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/SettingUpEncSignDemo.sql
@@ -0,0 +1,47 @@
+--Create database and table for encryption signing samples
+
+USE master
+GO
+
+IF EXISTS(SELECT * FROM sys.databases WHERE name = 'NewDB3')
+ DROP DATABASE NewDB3
+GO
+
+CREATE DATABASE NewDB3
+GO
+
+USE NewDB3
+GO
+
+IF EXISTS(SELECT * FROM sys.tables WHERE name = 'ForEncDemo')
+ DROP TABLE ForEncDemo
+GO
+
+CREATE TABLE ForEncDemo (
+ rowid int IDENTITY(1,1) PRIMARY KEY,
+ name nvarChar(20),
+ id_data_orig Nvarchar(11),
+ id_data_enc varbinary(70)
+)
+GO
+
+
+IF EXISTS(SELECT * FROM sys.tables WHERE name = 'SignedData')
+ DROP TABLE SignedData
+GO
+
+CREATE TABLE SignedData (
+ rowid int IDENTITY(1,1) PRIMARY KEY,
+ certname nvarChar(128) NOT NULL,
+ mytext nvarchar(256),
+ mysignature varbinary(1024)
+)
+GO
+
+
+
+
+
+
+
+
diff --git a/SamplesForChapter08/Chapter08/ShowingPermissions.sql b/SamplesForChapter08/Chapter08/ShowingPermissions.sql
new file mode 100644
index 0000000..7fe8790
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/ShowingPermissions.sql
@@ -0,0 +1,48 @@
+USE master
+GO
+
+--Syntax for listing all permissions
+SELECT * FROM sys.fn_builtin_permissions(DEFAULT)
+
+--Return a list of all securable class names
+SELECT DISTINCT class_desc
+FROM sys.fn_builtin_permissions(DEFAULT)
+ORDER BY class_desc
+
+--List permissions for LOGIN securable class
+SELECT class_desc 'class',
+ permission_name,
+ covering_permission_name 'covering_permission',
+ parent_class_desc 'parent_class',
+ parent_covering_permission_name 'parent_covering_permission'
+FROM sys.fn_builtin_permissions(N'LOGIN')
+
+--For display in book
+SELECT CAST(class_desc AS nvarchar(5)) 'class',
+ CAST(permission_name AS nvarchar(15)) 'permission_name',
+ CAST(covering_permission_name AS nvarchar(19)) 'covering_permission',
+ CAST(parent_class_desc AS nvarchar(12)) 'parent_class',
+ CAST(parent_covering_permission_name AS nvarchar(26)) 'parent_covering_permission'
+FROM sys.fn_builtin_permissions(N'LOGIN')
+
+
+--Explore a specific permission for a securable class
+SELECT class_desc 'class',
+ permission_name,
+ covering_permission_name 'covering_permission',
+ parent_class_desc 'parent_class',
+ parent_covering_permission_name 'parent_covering_permission'
+FROM sys.fn_builtin_permissions(N'SERVER')
+WHERE permission_name = 'ALTER ANY LOGIN'
+
+--For display in book
+SELECT CAST(class_desc AS nvarchar(6)) 'class',
+ CAST(permission_name AS nvarchar(15)) 'permission_name',
+ CAST(covering_permission_name AS nvarchar(19)) 'covering_permission',
+ CAST(parent_class_desc AS nvarchar(12)) 'parent_class',
+ CAST(parent_covering_permission_name AS nvarchar(26)) 'parent_covering_permission'
+FROM sys.fn_builtin_permissions(N'SERVER')
+WHERE permission_name = 'ALTER ANY LOGIN'
+
+
+
diff --git a/SamplesForChapter08/Chapter08/SigningData.sql b/SamplesForChapter08/Chapter08/SigningData.sql
new file mode 100644
index 0000000..fe0584f
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/SigningData.sql
@@ -0,0 +1,130 @@
+USE NewDB3
+GO
+
+--Add certificates for Rick and Virginia Dobson
+IF EXISTS(SELECT * FROM sys.certificates
+ WHERE name = 'HisCert')
+ DROP CERTIFICATE HisCert
+GO
+
+CREATE CERTIFICATE HisCert
+ ENCRYPTION BY PASSWORD = 'his secret'
+ WITH SUBJECT = 'Rick Dobson',
+ EXPIRY_DATE = '12/31/2007'
+GO
+
+IF EXISTS(SELECT * FROM sys.certificates
+ WHERE name = 'HerCert')
+ DROP CERTIFICATE HerCert
+GO
+
+CREATE CERTIFICATE HerCert
+ ENCRYPTION BY PASSWORD = 'her secret'
+ WITH SUBJECT = 'Virginia Dobson',
+ EXPIRY_DATE = '12/31/2007'
+GO
+
+--Create a stored procedure to insert a row
+-- and sign it
+IF EXISTS(SELECT *
+ FROM sys.objects
+ WHERE type = 'P' AND name = 'SignandInsert')
+ DROP PROCEDURE SignandInsert
+GO
+
+CREATE PROCEDURE SignandInsert
+ @myinput nvarchar(256),
+ @CertName nvarchar(128),
+ @CertSecret nvarchar(128)
+AS
+INSERT SignedData VALUES(@CertName,
+ @myinput, SignByCert( Cert_Id( @CertName),
+ @myinput, @CertSecret))
+GO
+
+--Enter a signed row and verify the signature for HisCert certificate
+DECLARE @myinput nvarchar(256)
+SET @myinput =
+ N'This is my story'
+EXEC SignandInsert
+ @myinput, 'HisCert', 'his secret'
+GO
+
+SELECT rowid, CONVERT(nvarchar(10), certname) 'certname',
+ CONVERT(nvarchar(20), mytext) 'mytext',
+ VerifySignedByCert(Cert_Id('HisCert'),
+ mytext, mysignature ) as IsSignatureValid
+FROM SignedData
+WHERE certname = 'HisCert'
+GO
+
+
+--Enter a signed row and verify the signature for HerCert certificate
+DECLARE @myinput nvarchar(256)
+SET @myinput =
+ N'This is my song'
+EXEC SignandInsert
+ @myinput, 'HerCert', 'her secret'
+GO
+
+SELECT rowid, CONVERT(nvarchar(10), certname) 'certname',
+ CONVERT(nvarchar(20), mytext) 'mytext',
+ VerifySignedByCert(Cert_Id('HerCert'),
+ mytext, mysignature ) as IsSignatureValid
+FROM SignedData
+WHERE certname = 'HerCert'
+GO
+
+
+--Update the row, sign it, and confirm that
+--the new signature is valid
+DECLARE @myinput nvarchar(256), @CertSecret nvarchar(128)
+SET @CertSecret = 'his secret'
+SET @myinput =
+ N'All the day long'
+UPDATE SignedData
+SET mytext = @myinput,
+mysignature = SignByCert( Cert_Id( 'HisCert'), @myinput, @CertSecret)
+WHERE rowid = 2
+GO
+
+SELECT rowid, CONVERT(nvarchar(10), certname) 'certname',
+ CONVERT(nvarchar(20), mytext) 'mytext',
+ VerifySignedByCert(Cert_Id('HerCert'),
+ mytext, mysignature ) as IsSignatureValid
+FROM SignedData
+WHERE certname = 'HerCert'
+GO
+
+SELECT rowid, CONVERT(nvarchar(10), certname) 'certname',
+ CONVERT(nvarchar(20), mytext) 'mytext',
+ VerifySignedByCert(Cert_Id('HisCert'),
+ mytext, mysignature ) as IsSignatureValid
+FROM SignedData
+WHERE rowid = 2
+GO
+
+
+
+
+--Update the row, do not sign it, and confirm that
+--the original signature is no longer valid
+DECLARE @myinput nvarchar(256), @CertSecret nvarchar(128)
+SET @CertSecret = 'his secret'
+SET @myinput =
+ N'Update not signed'
+UPDATE SignedData
+SET mytext = @myinput
+WHERE rowid = 2
+GO
+
+SELECT rowid, CONVERT(nvarchar(10), certname) 'certname',
+ CONVERT(nvarchar(20), mytext) 'mytext',
+ VerifySignedByCert(Cert_Id('HisCert'),
+ mytext, mysignature ) as IsSignatureValid
+FROM SignedData
+WHERE rowid = 2
+GO
+
+
+
diff --git a/SamplesForChapter08/Chapter08/UsersRolesPermissions.sql b/SamplesForChapter08/Chapter08/UsersRolesPermissions.sql
new file mode 100644
index 0000000..efa530a
--- /dev/null
+++ b/SamplesForChapter08/Chapter08/UsersRolesPermissions.sql
@@ -0,0 +1,140 @@
+USE AdventureWorks
+GO
+
+--Create proc
+IF EXISTs(SELECT *
+ FROM sys.objects
+ WHERE type = 'P' AND name = 'ProcHello')
+ DROP PROCEDURE ProcHello
+GO
+
+CREATE PROC ProcHello
+AS
+Print 'Hello from ProcHello.'
+GO
+
+--Create roles
+CREATE ROLE ReadCats
+CREATE ROLE ReadCatsSubCats
+CREATE ROLE SayHello
+
+GRANT SELECT ON Production.ProductCategory
+ TO ReadCats, ReadCatsSubCats, SayHello
+GRANT SELECT ON Production.ProductSubcategory
+ TO ReadCatsSubCats, SayHello
+GRANT EXEC ON dbo.ProcHello TO SayHello
+
+
+--Create logins and users named sqllogin3, sqllogin4, sqllogin5
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin3')
+ DROP LOGIN sqllogin3
+GO
+
+CREATE LOGIN sqllogin3
+ WITH PASSWORD = 'pass_sqllogin3'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin3')
+ DROP USER sqllogin3
+GO
+
+CREATE USER sqllogin3 FOR LOGIN sqllogin3
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin4')
+ DROP LOGIN sqllogin4
+GO
+
+CREATE LOGIN sqllogin4
+ WITH PASSWORD = 'pass_sqllogin4'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin4')
+ DROP USER sqllogin4
+GO
+
+CREATE USER sqllogin4 FOR LOGIN sqllogin4
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+IF EXISTS(SELECT * FROM sys.syslogins
+ WHERE name = N'sqllogin5')
+ DROP LOGIN sqllogin5
+GO
+
+CREATE LOGIN sqllogin5
+ WITH PASSWORD = 'pass_sqllogin5'
+GO
+
+IF EXISTS(SELECT * FROM sys.sysusers
+ WHERE name = 'sqllogin5')
+ DROP USER sqllogin5
+GO
+
+CREATE USER sqllogin5 FOR LOGIN sqllogin5
+ WITH DEFAULT_SCHEMA = dbo
+GO
+
+--Assign users to roles
+EXEC sp_addrolemember 'ReadCats', 'sqllogin3'
+EXEC sp_addrolemember 'ReadCatsSubCats', 'sqllogin4'
+EXEC sp_addrolemember 'SayHello', 'sqllogin5'
+
+EXECUTE AS login = 'sqllogin3'
+SELECT ProductCategoryID, Name FROM Production.ProductCategory
+GO
+SELECT COUNT(*) '# of Subcategories'
+FROM Production.ProductSubcategory
+GO
+EXEC ProcHello
+GO
+
+REVERT
+GO
+
+EXECUTE AS login = 'sqllogin4'
+SELECT ProductCategoryID, Name FROM Production.ProductCategory
+SELECT COUNT(*) '# of Subcategories'
+FROM Production.ProductSubcategory
+GO
+EXEC ProcHello
+GO
+
+REVERT
+GO
+
+
+EXECUTE AS login = 'sqllogin5'
+SELECT ProductCategoryID, Name FROM Production.ProductCategory
+SELECT COUNT(*) '# of Subcategories'
+FROM Production.ProductSubcategory
+GO
+EXEC ProcHello
+GO
+
+REVERT
+GO
+
+--Clean up
+EXEC sp_droprolemember 'ReadCats', 'sqllogin3'
+EXEC sp_droprolemember 'ReadCatsSubCats', 'sqllogin4'
+EXEC sp_droprolemember 'SayHello', 'sqllogin5'
+
+DROP ROLE ReadCats
+DROP ROLE ReadCatsSubCats
+DROP ROLE SayHello
+
+DROP USER sqllogin3
+DROP USER sqllogin4
+DROP USER sqllogin5
+
+DROP LOGIN sqllogin3
+DROP LOGIN sqllogin4
+DROP LOGIN sqllogin5
+
+DROP PROCEDURE ProcHello
diff --git a/SamplesForChapter09/Chapter09/SalesByPersonTerritoryRegion.rpt b/SamplesForChapter09/Chapter09/SalesByPersonTerritoryRegion.rpt
new file mode 100644
index 0000000..fa8f23d
--- /dev/null
+++ b/SamplesForChapter09/Chapter09/SalesByPersonTerritoryRegion.rpt
@@ -0,0 +1,22 @@
+Changed database context to 'AdventureWorks'.
+Region Territory SalesPersonID FirstName LastName SalesYTD SalesLastYear
+-------------- -------------- ------------- --------- ----------------- --------------------- ---------------------
+NULL NULL 268 Stephen Jiang 677558.4653 0.0000
+United States Northeast 275 Michael Blythe 4557045.0459 1750406.4785
+United States Southwest 276 Linda Mitchell 5200475.2313 1439156.0291
+United States Central 277 Jillian Carson 3857163.6332 1997186.2037
+Canada Canada 278 Garrett Vargas 1764938.9859 1620276.8966
+United States Southeast 279 Tsvi Reiter 2811012.7151 1849640.9418
+United States Northwest 280 Pamela Ansman-Wolfe 0.0000 1927059.1780
+United States Southwest 281 Shu Ito 3018725.4858 2073505.9999
+Canada Canada 282 José Saraiva 3189356.2465 2038234.6549
+United States Northwest 283 David Campbell 3587378.4257 1371635.3158
+NULL NULL 284 Amy Alberts 636440.2510 0.0000
+United Kingdom United Kingdom 285 Jae Pak 5015682.3752 1635823.3967
+France France 286 Ranjit Varkey Chudukatil 3827950.2380 2396539.7601
+United States Northwest 287 Tete Mensa-Annan 1931620.1835 0.0000
+NULL NULL 288 Syed Abbas 219088.8836 0.0000
+Germany Germany 289 Rachel Valdez 2241204.0424 1307949.7917
+Australia Australia 290 Lynn Tsoflias 1758385.9260 2278548.9776
+
+(17 rows affected)
diff --git a/SamplesForChapter09/Chapter09/SalesByPersonTerritoryRegion.sql b/SamplesForChapter09/Chapter09/SalesByPersonTerritoryRegion.sql
new file mode 100644
index 0000000..0c404b8
--- /dev/null
+++ b/SamplesForChapter09/Chapter09/SalesByPersonTerritoryRegion.sql
@@ -0,0 +1,17 @@
+USE AdventureWorks
+GO
+
+SELECT CAST(cr.Name AS nvarchar(14)) 'Region',
+ CAST(st.Name AS nvarchar(14)) 'Territory',
+ s.SalesPersonID,
+ CAST(c.FirstName AS nvarchar(8)) 'FirstName',
+ CAST(c.LastName AS nvarchar(17)) 'LastName',
+ s.SalesYTD,
+ s.SalesLastYear
+FROM Sales.SalesPerson s JOIN HumanResources.Employee e
+ON e.EmployeeID = s.SalesPersonID JOIN Person.Contact c
+ON c.ContactID = e.ContactID LEFT JOIN Sales.SalesTerritory st
+ON st.TerritoryID = s.TerritoryID LEFT JOIN Person.CountryRegion cr
+ON cr.CountryRegionCode = st.CountryRegionCode
+
+
diff --git a/SamplesForChapter09/Chapter09/sqlcmdTorpt.txt b/SamplesForChapter09/Chapter09/sqlcmdTorpt.txt
new file mode 100644
index 0000000..453342d
--- /dev/null
+++ b/SamplesForChapter09/Chapter09/sqlcmdTorpt.txt
@@ -0,0 +1,3 @@
+
+
+sqlcmd -S .\sqlexpress -i c:\ProSSEApps\Chapter09\SalesByPersonTerritoryRegion.sql -o c:\ProSSEApps\Chapter09\SalesByPersonTerritoryRegion.rpt
\ No newline at end of file
diff --git a/SamplesForChapter09/Samples/WindowsApplication1.ZIP b/SamplesForChapter09/Samples/WindowsApplication1.ZIP
new file mode 100644
index 0000000..64a672e
Binary files /dev/null and b/SamplesForChapter09/Samples/WindowsApplication1.ZIP differ
diff --git a/SamplesForChapter10/Samples/WebSite1.ZIP b/SamplesForChapter10/Samples/WebSite1.ZIP
new file mode 100644
index 0000000..be7a2d4
Binary files /dev/null and b/SamplesForChapter10/Samples/WebSite1.ZIP differ
diff --git a/SamplesForChapter10/Samples/WebSite1FromChapter10.ZIP b/SamplesForChapter10/Samples/WebSite1FromChapter10.ZIP
new file mode 100644
index 0000000..262c0dd
Binary files /dev/null and b/SamplesForChapter10/Samples/WebSite1FromChapter10.ZIP differ
diff --git a/SamplesForChapter10/SamplesForChapter11And12.ZIP b/SamplesForChapter10/SamplesForChapter11And12.ZIP
new file mode 100644
index 0000000..6874dc9
Binary files /dev/null and b/SamplesForChapter10/SamplesForChapter11And12.ZIP differ
diff --git a/SamplesForChapter11And12/Samples/WebCh12.ZIP b/SamplesForChapter11And12/Samples/WebCh12.ZIP
new file mode 100644
index 0000000..d10de1d
Binary files /dev/null and b/SamplesForChapter11And12/Samples/WebCh12.ZIP differ
diff --git a/SamplesForChapter11And12/Samples/WinCh12.ZIP b/SamplesForChapter11And12/Samples/WinCh12.ZIP
new file mode 100644
index 0000000..522b113
Binary files /dev/null and b/SamplesForChapter11And12/Samples/WinCh12.ZIP differ
diff --git a/WebCh13/Chapter13/WebCh13/App_Data/Northwind.mdb b/WebCh13/Chapter13/WebCh13/App_Data/Northwind.mdb
new file mode 100644
index 0000000..7a597a6
Binary files /dev/null and b/WebCh13/Chapter13/WebCh13/App_Data/Northwind.mdb differ
diff --git a/WebCh13/Chapter13/WebCh13/App_Data/northwnd.mdf b/WebCh13/Chapter13/WebCh13/App_Data/northwnd.mdf
new file mode 100644
index 0000000..8a9fc40
Binary files /dev/null and b/WebCh13/Chapter13/WebCh13/App_Data/northwnd.mdf differ
diff --git a/WebCh13/Chapter13/WebCh13/App_Data/northwnd_log.ldf b/WebCh13/Chapter13/WebCh13/App_Data/northwnd_log.ldf
new file mode 100644
index 0000000..d55c6c7
Binary files /dev/null and b/WebCh13/Chapter13/WebCh13/App_Data/northwnd_log.ldf differ
diff --git a/WebCh13/Chapter13/WebCh13/Default.aspx b/WebCh13/Chapter13/WebCh13/Default.aspx
new file mode 100644
index 0000000..377360d
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/Default.aspx
@@ -0,0 +1,16 @@
+<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
+
+
+
+
+
+ Untitled Page
+
+
+
+
+
diff --git a/WebCh13/Chapter13/WebCh13/Default.aspx.vb b/WebCh13/Chapter13/WebCh13/Default.aspx.vb
new file mode 100644
index 0000000..75f1603
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/Default.aspx.vb
@@ -0,0 +1,5 @@
+
+Partial Class _Default
+ Inherits System.Web.UI.Page
+
+End Class
diff --git a/WebCh13/Chapter13/WebCh13/LookupAccessData.aspx b/WebCh13/Chapter13/WebCh13/LookupAccessData.aspx
new file mode 100644
index 0000000..b91c95e
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/LookupAccessData.aspx
@@ -0,0 +1,74 @@
+<%@ Page Language="VB" AutoEventWireup="false" CodeFile="LookupAccessData.aspx.vb" Inherits="LookupAccessData" %>
+
+
+
+
+
+ Untitled Page
+
+
+
+
+
diff --git a/WebCh13/Chapter13/WebCh13/LookupAccessData.aspx.vb b/WebCh13/Chapter13/WebCh13/LookupAccessData.aspx.vb
new file mode 100644
index 0000000..ddbbe94
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/LookupAccessData.aspx.vb
@@ -0,0 +1,5 @@
+
+Partial Class LookupAccessData
+ Inherits System.Web.UI.Page
+
+End Class
diff --git a/WebCh13/Chapter13/WebCh13/LookupSSEData.aspx b/WebCh13/Chapter13/WebCh13/LookupSSEData.aspx
new file mode 100644
index 0000000..c0477c3
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/LookupSSEData.aspx
@@ -0,0 +1,52 @@
+<%@ Page Language="VB" AutoEventWireup="false" CodeFile="LookupSSEData.aspx.vb" Inherits="LookupSSEData" %>
+
+
+
+
+
+ Untitled Page
+
+
+
+
+
diff --git a/WebCh13/Chapter13/WebCh13/LookupSSEData.aspx.vb b/WebCh13/Chapter13/WebCh13/LookupSSEData.aspx.vb
new file mode 100644
index 0000000..b02c15a
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/LookupSSEData.aspx.vb
@@ -0,0 +1,5 @@
+
+Partial Class LookupSSEData
+ Inherits System.Web.UI.Page
+
+End Class
diff --git a/WebCh13/Chapter13/WebCh13/PagedSortedEdited.aspx b/WebCh13/Chapter13/WebCh13/PagedSortedEdited.aspx
new file mode 100644
index 0000000..765d3d8
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/PagedSortedEdited.aspx
@@ -0,0 +1,60 @@
+<%@ Page Language="VB" AutoEventWireup="false" CodeFile="PagedSortedEdited.aspx.vb" Inherits="PagedSortedEdited" %>
+
+
+
+
+
+ Untitled Page
+
+
+
+
+
diff --git a/WebCh13/Chapter13/WebCh13/PagedSortedEdited.aspx.vb b/WebCh13/Chapter13/WebCh13/PagedSortedEdited.aspx.vb
new file mode 100644
index 0000000..e64b97c
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/PagedSortedEdited.aspx.vb
@@ -0,0 +1,5 @@
+
+Partial Class PagedSortedEdited
+ Inherits System.Web.UI.Page
+
+End Class
diff --git a/WebCh13/Chapter13/WebCh13/ShortGridView.aspx b/WebCh13/Chapter13/WebCh13/ShortGridView.aspx
new file mode 100644
index 0000000..4f18e72
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/ShortGridView.aspx
@@ -0,0 +1,41 @@
+<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ShortGridView.aspx.vb" Inherits="ShortGridView" %>
+
+
+
+
+
+ Untitled Page
+
+
+
+
+
diff --git a/WebCh13/Chapter13/WebCh13/ShortGridView.aspx.vb b/WebCh13/Chapter13/WebCh13/ShortGridView.aspx.vb
new file mode 100644
index 0000000..662c05f
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/ShortGridView.aspx.vb
@@ -0,0 +1,5 @@
+
+Partial Class ShortGridView
+ Inherits System.Web.UI.Page
+
+End Class
diff --git a/WebCh13/Chapter13/WebCh13/Web.Config b/WebCh13/Chapter13/WebCh13/Web.Config
new file mode 100644
index 0000000..89e9ff0
--- /dev/null
+++ b/WebCh13/Chapter13/WebCh13/Web.Config
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13.sln b/WinCh13/Chapter13/WinChap13/WinChap13.sln
new file mode 100644
index 0000000..2b4b486
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Basic Express 2005
+Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WinChap13", "WinChap13\WinChap13.vbproj", "{FE333FE0-D630-4405-97DD-154A3DA960BF}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {FE333FE0-D630-4405-97DD-154A3DA960BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FE333FE0-D630-4405-97DD-154A3DA960BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FE333FE0-D630-4405-97DD-154A3DA960BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FE333FE0-D630-4405-97DD-154A3DA960BF}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13.suo b/WinCh13/Chapter13/WinChap13/WinChap13.suo
new file mode 100644
index 0000000..51ae7ae
Binary files /dev/null and b/WinCh13/Chapter13/WinChap13/WinChap13.suo differ
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.Designer.vb
new file mode 100644
index 0000000..2bfe13a
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.Designer.vb
@@ -0,0 +1,1552 @@
+'------------------------------------------------------------------------------
+'
+' This code was generated by a tool.
+' Runtime Version:2.0.50727.42
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+'
+'------------------------------------------------------------------------------
+
+Option Strict Off
+Option Explicit On
+
+Imports System
+
+
+ _
+Partial Public Class CatSubCatAdventureWorks_DataDataSet
+ Inherits System.Data.DataSet
+
+ Private tableProductCategory As ProductCategoryDataTable
+
+ Private tableProductSubcategory As ProductSubcategoryDataTable
+
+ Private relationFK_ProductSubcategory_ProductCategory_ProductCategoryID As System.Data.DataRelation
+
+ Private _schemaSerializationMode As System.Data.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+
+ _
+ Public Sub New()
+ MyBase.New
+ Me.BeginInit
+ Me.InitClass
+ Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
+ AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler
+ AddHandler MyBase.Relations.CollectionChanged, schemaChangedHandler
+ Me.EndInit
+ End Sub
+
+ _
+ Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)
+ MyBase.New(info, context, false)
+ If (Me.IsBinarySerialized(info, context) = true) Then
+ Me.InitVars(false)
+ Dim schemaChangedHandler1 As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
+ AddHandler Me.Tables.CollectionChanged, schemaChangedHandler1
+ AddHandler Me.Relations.CollectionChanged, schemaChangedHandler1
+ Return
+ End If
+ Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(String)),String)
+ If (Me.DetermineSchemaSerializationMode(info, context) = System.Data.SchemaSerializationMode.IncludeSchema) Then
+ Dim ds As System.Data.DataSet = New System.Data.DataSet
+ ds.ReadXmlSchema(New System.Xml.XmlTextReader(New System.IO.StringReader(strSchema)))
+ If (Not (ds.Tables("ProductCategory")) Is Nothing) Then
+ MyBase.Tables.Add(New ProductCategoryDataTable(ds.Tables("ProductCategory")))
+ End If
+ If (Not (ds.Tables("ProductSubcategory")) Is Nothing) Then
+ MyBase.Tables.Add(New ProductSubcategoryDataTable(ds.Tables("ProductSubcategory")))
+ End If
+ Me.DataSetName = ds.DataSetName
+ Me.Prefix = ds.Prefix
+ Me.Namespace = ds.Namespace
+ Me.Locale = ds.Locale
+ Me.CaseSensitive = ds.CaseSensitive
+ Me.EnforceConstraints = ds.EnforceConstraints
+ Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
+ Me.InitVars
+ Else
+ Me.ReadXmlSchema(New System.Xml.XmlTextReader(New System.IO.StringReader(strSchema)))
+ End If
+ Me.GetSerializationData(info, context)
+ Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
+ AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler
+ AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
+ End Sub
+
+ _
+ Public ReadOnly Property ProductCategory() As ProductCategoryDataTable
+ Get
+ Return Me.tableProductCategory
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property ProductSubcategory() As ProductSubcategoryDataTable
+ Get
+ Return Me.tableProductSubcategory
+ End Get
+ End Property
+
+ _
+ Public Overrides Property SchemaSerializationMode() As System.Data.SchemaSerializationMode
+ Get
+ Return Me._schemaSerializationMode
+ End Get
+ Set
+ Me._schemaSerializationMode = value
+ End Set
+ End Property
+
+ _
+ Public Shadows ReadOnly Property Tables() As System.Data.DataTableCollection
+ Get
+ Return MyBase.Tables
+ End Get
+ End Property
+
+ _
+ Public Shadows ReadOnly Property Relations() As System.Data.DataRelationCollection
+ Get
+ Return MyBase.Relations
+ End Get
+ End Property
+
+ _
+ Protected Overrides Sub InitializeDerivedDataSet()
+ Me.BeginInit
+ Me.InitClass
+ Me.EndInit
+ End Sub
+
+ _
+ Public Overrides Function Clone() As System.Data.DataSet
+ Dim cln As CatSubCatAdventureWorks_DataDataSet = CType(MyBase.Clone,CatSubCatAdventureWorks_DataDataSet)
+ cln.InitVars
+ cln.SchemaSerializationMode = Me.SchemaSerializationMode
+ Return cln
+ End Function
+
+ _
+ Protected Overrides Function ShouldSerializeTables() As Boolean
+ Return false
+ End Function
+
+ _
+ Protected Overrides Function ShouldSerializeRelations() As Boolean
+ Return false
+ End Function
+
+ _
+ Protected Overrides Sub ReadXmlSerializable(ByVal reader As System.Xml.XmlReader)
+ If (Me.DetermineSchemaSerializationMode(reader) = System.Data.SchemaSerializationMode.IncludeSchema) Then
+ Me.Reset
+ Dim ds As System.Data.DataSet = New System.Data.DataSet
+ ds.ReadXml(reader)
+ If (Not (ds.Tables("ProductCategory")) Is Nothing) Then
+ MyBase.Tables.Add(New ProductCategoryDataTable(ds.Tables("ProductCategory")))
+ End If
+ If (Not (ds.Tables("ProductSubcategory")) Is Nothing) Then
+ MyBase.Tables.Add(New ProductSubcategoryDataTable(ds.Tables("ProductSubcategory")))
+ End If
+ Me.DataSetName = ds.DataSetName
+ Me.Prefix = ds.Prefix
+ Me.Namespace = ds.Namespace
+ Me.Locale = ds.Locale
+ Me.CaseSensitive = ds.CaseSensitive
+ Me.EnforceConstraints = ds.EnforceConstraints
+ Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
+ Me.InitVars
+ Else
+ Me.ReadXml(reader)
+ Me.InitVars
+ End If
+ End Sub
+
+ _
+ Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchema
+ Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
+ Me.WriteXmlSchema(New System.Xml.XmlTextWriter(stream, Nothing))
+ stream.Position = 0
+ Return System.Xml.Schema.XmlSchema.Read(New System.Xml.XmlTextReader(stream), Nothing)
+ End Function
+
+ _
+ Friend Overloads Sub InitVars()
+ Me.InitVars(true)
+ End Sub
+
+ _
+ Friend Overloads Sub InitVars(ByVal initTable As Boolean)
+ Me.tableProductCategory = CType(MyBase.Tables("ProductCategory"),ProductCategoryDataTable)
+ If (initTable = true) Then
+ If (Not (Me.tableProductCategory) Is Nothing) Then
+ Me.tableProductCategory.InitVars
+ End If
+ End If
+ Me.tableProductSubcategory = CType(MyBase.Tables("ProductSubcategory"),ProductSubcategoryDataTable)
+ If (initTable = true) Then
+ If (Not (Me.tableProductSubcategory) Is Nothing) Then
+ Me.tableProductSubcategory.InitVars
+ End If
+ End If
+ Me.relationFK_ProductSubcategory_ProductCategory_ProductCategoryID = Me.Relations("FK_ProductSubcategory_ProductCategory_ProductCategoryID")
+ End Sub
+
+ _
+ Private Sub InitClass()
+ Me.DataSetName = "CatSubCatAdventureWorks_DataDataSet"
+ Me.Prefix = ""
+ Me.Namespace = "http://tempuri.org/CatSubCatAdventureWorks_DataDataSet.xsd"
+ Me.EnforceConstraints = true
+ Me.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+ Me.tableProductCategory = New ProductCategoryDataTable
+ MyBase.Tables.Add(Me.tableProductCategory)
+ Me.tableProductSubcategory = New ProductSubcategoryDataTable
+ MyBase.Tables.Add(Me.tableProductSubcategory)
+ Me.relationFK_ProductSubcategory_ProductCategory_ProductCategoryID = New System.Data.DataRelation("FK_ProductSubcategory_ProductCategory_ProductCategoryID", New System.Data.DataColumn() {Me.tableProductCategory.ProductCategoryIDColumn}, New System.Data.DataColumn() {Me.tableProductSubcategory.ProductCategoryIDColumn}, false)
+ Me.Relations.Add(Me.relationFK_ProductSubcategory_ProductCategory_ProductCategoryID)
+ End Sub
+
+ _
+ Private Function ShouldSerializeProductCategory() As Boolean
+ Return false
+ End Function
+
+ _
+ Private Function ShouldSerializeProductSubcategory() As Boolean
+ Return false
+ End Function
+
+ _
+ Private Sub SchemaChanged(ByVal sender As Object, ByVal e As System.ComponentModel.CollectionChangeEventArgs)
+ If (e.Action = System.ComponentModel.CollectionChangeAction.Remove) Then
+ Me.InitVars
+ End If
+ End Sub
+
+ _
+ Public Shared Function GetTypedDataSetSchema(ByVal xs As System.Xml.Schema.XmlSchemaSet) As System.Xml.Schema.XmlSchemaComplexType
+ Dim ds As CatSubCatAdventureWorks_DataDataSet = New CatSubCatAdventureWorks_DataDataSet
+ Dim type As System.Xml.Schema.XmlSchemaComplexType = New System.Xml.Schema.XmlSchemaComplexType
+ Dim sequence As System.Xml.Schema.XmlSchemaSequence = New System.Xml.Schema.XmlSchemaSequence
+ xs.Add(ds.GetSchemaSerializable)
+ Dim any As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny
+ any.Namespace = ds.Namespace
+ sequence.Items.Add(any)
+ type.Particle = sequence
+ Return type
+ End Function
+
+ Public Delegate Sub ProductCategoryRowChangeEventHandler(ByVal sender As Object, ByVal e As ProductCategoryRowChangeEvent)
+
+ Public Delegate Sub ProductSubcategoryRowChangeEventHandler(ByVal sender As Object, ByVal e As ProductSubcategoryRowChangeEvent)
+
+ _
+ Partial Public Class ProductCategoryDataTable
+ Inherits System.Data.DataTable
+ Implements System.Collections.IEnumerable
+
+ Private columnProductCategoryID As System.Data.DataColumn
+
+ Private columnName As System.Data.DataColumn
+
+ Private columnrowguid As System.Data.DataColumn
+
+ Private columnModifiedDate As System.Data.DataColumn
+
+ _
+ Public Sub New()
+ MyBase.New
+ Me.TableName = "ProductCategory"
+ Me.BeginInit
+ Me.InitClass
+ Me.EndInit
+ End Sub
+
+ _
+ Friend Sub New(ByVal table As System.Data.DataTable)
+ MyBase.New
+ Me.TableName = table.TableName
+ If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
+ Me.CaseSensitive = table.CaseSensitive
+ End If
+ If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
+ Me.Locale = table.Locale
+ End If
+ If (table.Namespace <> table.DataSet.Namespace) Then
+ Me.Namespace = table.Namespace
+ End If
+ Me.Prefix = table.Prefix
+ Me.MinimumCapacity = table.MinimumCapacity
+ End Sub
+
+ _
+ Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)
+ MyBase.New(info, context)
+ Me.InitVars
+ End Sub
+
+ _
+ Public ReadOnly Property ProductCategoryIDColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnProductCategoryID
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property NameColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnName
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property rowguidColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnrowguid
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property ModifiedDateColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnModifiedDate
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property Count() As Integer
+ Get
+ Return Me.Rows.Count
+ End Get
+ End Property
+
+ _
+ Public Default ReadOnly Property Item(ByVal index As Integer) As ProductCategoryRow
+ Get
+ Return CType(Me.Rows(index),ProductCategoryRow)
+ End Get
+ End Property
+
+ Public Event ProductCategoryRowChanging As ProductCategoryRowChangeEventHandler
+
+ Public Event ProductCategoryRowChanged As ProductCategoryRowChangeEventHandler
+
+ Public Event ProductCategoryRowDeleting As ProductCategoryRowChangeEventHandler
+
+ Public Event ProductCategoryRowDeleted As ProductCategoryRowChangeEventHandler
+
+ _
+ Public Overloads Sub AddProductCategoryRow(ByVal row As ProductCategoryRow)
+ Me.Rows.Add(row)
+ End Sub
+
+ _
+ Public Overloads Function AddProductCategoryRow(ByVal Name As String, ByVal rowguid As System.Guid, ByVal ModifiedDate As Date) As ProductCategoryRow
+ Dim rowProductCategoryRow As ProductCategoryRow = CType(Me.NewRow,ProductCategoryRow)
+ rowProductCategoryRow.ItemArray = New Object() {Nothing, Name, rowguid, ModifiedDate}
+ Me.Rows.Add(rowProductCategoryRow)
+ Return rowProductCategoryRow
+ End Function
+
+ _
+ Public Function FindByProductCategoryID(ByVal ProductCategoryID As Integer) As ProductCategoryRow
+ Return CType(Me.Rows.Find(New Object() {ProductCategoryID}),ProductCategoryRow)
+ End Function
+
+ _
+ Public Overridable Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
+ Return Me.Rows.GetEnumerator
+ End Function
+
+ _
+ Public Overrides Function Clone() As System.Data.DataTable
+ Dim cln As ProductCategoryDataTable = CType(MyBase.Clone,ProductCategoryDataTable)
+ cln.InitVars
+ Return cln
+ End Function
+
+ _
+ Protected Overrides Function CreateInstance() As System.Data.DataTable
+ Return New ProductCategoryDataTable
+ End Function
+
+ _
+ Friend Sub InitVars()
+ Me.columnProductCategoryID = MyBase.Columns("ProductCategoryID")
+ Me.columnName = MyBase.Columns("Name")
+ Me.columnrowguid = MyBase.Columns("rowguid")
+ Me.columnModifiedDate = MyBase.Columns("ModifiedDate")
+ End Sub
+
+ _
+ Private Sub InitClass()
+ Me.columnProductCategoryID = New System.Data.DataColumn("ProductCategoryID", GetType(Integer), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnProductCategoryID)
+ Me.columnName = New System.Data.DataColumn("Name", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnName)
+ Me.columnrowguid = New System.Data.DataColumn("rowguid", GetType(System.Guid), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnrowguid)
+ Me.columnModifiedDate = New System.Data.DataColumn("ModifiedDate", GetType(Date), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnModifiedDate)
+ Me.Constraints.Add(New System.Data.UniqueConstraint("Constraint1", New System.Data.DataColumn() {Me.columnProductCategoryID}, true))
+ Me.columnProductCategoryID.AutoIncrement = true
+ Me.columnProductCategoryID.AllowDBNull = false
+ Me.columnProductCategoryID.ReadOnly = true
+ Me.columnProductCategoryID.Unique = true
+ Me.columnName.AllowDBNull = false
+ Me.columnName.MaxLength = 50
+ Me.columnrowguid.AllowDBNull = false
+ Me.columnModifiedDate.AllowDBNull = false
+ End Sub
+
+ _
+ Public Function NewProductCategoryRow() As ProductCategoryRow
+ Return CType(Me.NewRow,ProductCategoryRow)
+ End Function
+
+ _
+ Protected Overrides Function NewRowFromBuilder(ByVal builder As System.Data.DataRowBuilder) As System.Data.DataRow
+ Return New ProductCategoryRow(builder)
+ End Function
+
+ _
+ Protected Overrides Function GetRowType() As System.Type
+ Return GetType(ProductCategoryRow)
+ End Function
+
+ _
+ Protected Overrides Sub OnRowChanged(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowChanged(e)
+ If (Not (Me.ProductCategoryRowChangedEvent) Is Nothing) Then
+ RaiseEvent ProductCategoryRowChanged(Me, New ProductCategoryRowChangeEvent(CType(e.Row,ProductCategoryRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Protected Overrides Sub OnRowChanging(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowChanging(e)
+ If (Not (Me.ProductCategoryRowChangingEvent) Is Nothing) Then
+ RaiseEvent ProductCategoryRowChanging(Me, New ProductCategoryRowChangeEvent(CType(e.Row,ProductCategoryRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Protected Overrides Sub OnRowDeleted(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowDeleted(e)
+ If (Not (Me.ProductCategoryRowDeletedEvent) Is Nothing) Then
+ RaiseEvent ProductCategoryRowDeleted(Me, New ProductCategoryRowChangeEvent(CType(e.Row,ProductCategoryRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Protected Overrides Sub OnRowDeleting(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowDeleting(e)
+ If (Not (Me.ProductCategoryRowDeletingEvent) Is Nothing) Then
+ RaiseEvent ProductCategoryRowDeleting(Me, New ProductCategoryRowChangeEvent(CType(e.Row,ProductCategoryRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Public Sub RemoveProductCategoryRow(ByVal row As ProductCategoryRow)
+ Me.Rows.Remove(row)
+ End Sub
+
+ _
+ Public Shared Function GetTypedTableSchema(ByVal xs As System.Xml.Schema.XmlSchemaSet) As System.Xml.Schema.XmlSchemaComplexType
+ Dim type As System.Xml.Schema.XmlSchemaComplexType = New System.Xml.Schema.XmlSchemaComplexType
+ Dim sequence As System.Xml.Schema.XmlSchemaSequence = New System.Xml.Schema.XmlSchemaSequence
+ Dim ds As CatSubCatAdventureWorks_DataDataSet = New CatSubCatAdventureWorks_DataDataSet
+ xs.Add(ds.GetSchemaSerializable)
+ Dim any1 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny
+ any1.Namespace = "http://www.w3.org/2001/XMLSchema"
+ any1.MinOccurs = New Decimal(0)
+ any1.MaxOccurs = Decimal.MaxValue
+ any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax
+ sequence.Items.Add(any1)
+ Dim any2 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny
+ any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"
+ any2.MinOccurs = New Decimal(1)
+ any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax
+ sequence.Items.Add(any2)
+ Dim attribute1 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute
+ attribute1.Name = "namespace"
+ attribute1.FixedValue = ds.Namespace
+ type.Attributes.Add(attribute1)
+ Dim attribute2 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute
+ attribute2.Name = "tableTypeName"
+ attribute2.FixedValue = "ProductCategoryDataTable"
+ type.Attributes.Add(attribute2)
+ type.Particle = sequence
+ Return type
+ End Function
+ End Class
+
+ _
+ Partial Public Class ProductSubcategoryDataTable
+ Inherits System.Data.DataTable
+ Implements System.Collections.IEnumerable
+
+ Private columnProductSubcategoryID As System.Data.DataColumn
+
+ Private columnProductCategoryID As System.Data.DataColumn
+
+ Private columnName As System.Data.DataColumn
+
+ Private columnrowguid As System.Data.DataColumn
+
+ Private columnModifiedDate As System.Data.DataColumn
+
+ _
+ Public Sub New()
+ MyBase.New
+ Me.TableName = "ProductSubcategory"
+ Me.BeginInit
+ Me.InitClass
+ Me.EndInit
+ End Sub
+
+ _
+ Friend Sub New(ByVal table As System.Data.DataTable)
+ MyBase.New
+ Me.TableName = table.TableName
+ If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
+ Me.CaseSensitive = table.CaseSensitive
+ End If
+ If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
+ Me.Locale = table.Locale
+ End If
+ If (table.Namespace <> table.DataSet.Namespace) Then
+ Me.Namespace = table.Namespace
+ End If
+ Me.Prefix = table.Prefix
+ Me.MinimumCapacity = table.MinimumCapacity
+ End Sub
+
+ _
+ Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)
+ MyBase.New(info, context)
+ Me.InitVars
+ End Sub
+
+ _
+ Public ReadOnly Property ProductSubcategoryIDColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnProductSubcategoryID
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property ProductCategoryIDColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnProductCategoryID
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property NameColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnName
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property rowguidColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnrowguid
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property ModifiedDateColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnModifiedDate
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property Count() As Integer
+ Get
+ Return Me.Rows.Count
+ End Get
+ End Property
+
+ _
+ Public Default ReadOnly Property Item(ByVal index As Integer) As ProductSubcategoryRow
+ Get
+ Return CType(Me.Rows(index),ProductSubcategoryRow)
+ End Get
+ End Property
+
+ Public Event ProductSubcategoryRowChanging As ProductSubcategoryRowChangeEventHandler
+
+ Public Event ProductSubcategoryRowChanged As ProductSubcategoryRowChangeEventHandler
+
+ Public Event ProductSubcategoryRowDeleting As ProductSubcategoryRowChangeEventHandler
+
+ Public Event ProductSubcategoryRowDeleted As ProductSubcategoryRowChangeEventHandler
+
+ _
+ Public Overloads Sub AddProductSubcategoryRow(ByVal row As ProductSubcategoryRow)
+ Me.Rows.Add(row)
+ End Sub
+
+ _
+ Public Overloads Function AddProductSubcategoryRow(ByVal parentProductCategoryRowByFK_ProductSubcategory_ProductCategory_ProductCategoryID As ProductCategoryRow, ByVal Name As String, ByVal rowguid As System.Guid, ByVal ModifiedDate As Date) As ProductSubcategoryRow
+ Dim rowProductSubcategoryRow As ProductSubcategoryRow = CType(Me.NewRow,ProductSubcategoryRow)
+ rowProductSubcategoryRow.ItemArray = New Object() {Nothing, parentProductCategoryRowByFK_ProductSubcategory_ProductCategory_ProductCategoryID(0), Name, rowguid, ModifiedDate}
+ Me.Rows.Add(rowProductSubcategoryRow)
+ Return rowProductSubcategoryRow
+ End Function
+
+ _
+ Public Function FindByProductSubcategoryID(ByVal ProductSubcategoryID As Integer) As ProductSubcategoryRow
+ Return CType(Me.Rows.Find(New Object() {ProductSubcategoryID}),ProductSubcategoryRow)
+ End Function
+
+ _
+ Public Overridable Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
+ Return Me.Rows.GetEnumerator
+ End Function
+
+ _
+ Public Overrides Function Clone() As System.Data.DataTable
+ Dim cln As ProductSubcategoryDataTable = CType(MyBase.Clone,ProductSubcategoryDataTable)
+ cln.InitVars
+ Return cln
+ End Function
+
+ _
+ Protected Overrides Function CreateInstance() As System.Data.DataTable
+ Return New ProductSubcategoryDataTable
+ End Function
+
+ _
+ Friend Sub InitVars()
+ Me.columnProductSubcategoryID = MyBase.Columns("ProductSubcategoryID")
+ Me.columnProductCategoryID = MyBase.Columns("ProductCategoryID")
+ Me.columnName = MyBase.Columns("Name")
+ Me.columnrowguid = MyBase.Columns("rowguid")
+ Me.columnModifiedDate = MyBase.Columns("ModifiedDate")
+ End Sub
+
+ _
+ Private Sub InitClass()
+ Me.columnProductSubcategoryID = New System.Data.DataColumn("ProductSubcategoryID", GetType(Integer), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnProductSubcategoryID)
+ Me.columnProductCategoryID = New System.Data.DataColumn("ProductCategoryID", GetType(Integer), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnProductCategoryID)
+ Me.columnName = New System.Data.DataColumn("Name", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnName)
+ Me.columnrowguid = New System.Data.DataColumn("rowguid", GetType(System.Guid), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnrowguid)
+ Me.columnModifiedDate = New System.Data.DataColumn("ModifiedDate", GetType(Date), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnModifiedDate)
+ Me.Constraints.Add(New System.Data.UniqueConstraint("Constraint1", New System.Data.DataColumn() {Me.columnProductSubcategoryID}, true))
+ Me.columnProductSubcategoryID.AutoIncrement = true
+ Me.columnProductSubcategoryID.AllowDBNull = false
+ Me.columnProductSubcategoryID.ReadOnly = true
+ Me.columnProductSubcategoryID.Unique = true
+ Me.columnProductCategoryID.AllowDBNull = false
+ Me.columnName.AllowDBNull = false
+ Me.columnName.MaxLength = 50
+ Me.columnrowguid.AllowDBNull = false
+ Me.columnModifiedDate.AllowDBNull = false
+ End Sub
+
+ _
+ Public Function NewProductSubcategoryRow() As ProductSubcategoryRow
+ Return CType(Me.NewRow,ProductSubcategoryRow)
+ End Function
+
+ _
+ Protected Overrides Function NewRowFromBuilder(ByVal builder As System.Data.DataRowBuilder) As System.Data.DataRow
+ Return New ProductSubcategoryRow(builder)
+ End Function
+
+ _
+ Protected Overrides Function GetRowType() As System.Type
+ Return GetType(ProductSubcategoryRow)
+ End Function
+
+ _
+ Protected Overrides Sub OnRowChanged(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowChanged(e)
+ If (Not (Me.ProductSubcategoryRowChangedEvent) Is Nothing) Then
+ RaiseEvent ProductSubcategoryRowChanged(Me, New ProductSubcategoryRowChangeEvent(CType(e.Row,ProductSubcategoryRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Protected Overrides Sub OnRowChanging(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowChanging(e)
+ If (Not (Me.ProductSubcategoryRowChangingEvent) Is Nothing) Then
+ RaiseEvent ProductSubcategoryRowChanging(Me, New ProductSubcategoryRowChangeEvent(CType(e.Row,ProductSubcategoryRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Protected Overrides Sub OnRowDeleted(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowDeleted(e)
+ If (Not (Me.ProductSubcategoryRowDeletedEvent) Is Nothing) Then
+ RaiseEvent ProductSubcategoryRowDeleted(Me, New ProductSubcategoryRowChangeEvent(CType(e.Row,ProductSubcategoryRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Protected Overrides Sub OnRowDeleting(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowDeleting(e)
+ If (Not (Me.ProductSubcategoryRowDeletingEvent) Is Nothing) Then
+ RaiseEvent ProductSubcategoryRowDeleting(Me, New ProductSubcategoryRowChangeEvent(CType(e.Row,ProductSubcategoryRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Public Sub RemoveProductSubcategoryRow(ByVal row As ProductSubcategoryRow)
+ Me.Rows.Remove(row)
+ End Sub
+
+ _
+ Public Shared Function GetTypedTableSchema(ByVal xs As System.Xml.Schema.XmlSchemaSet) As System.Xml.Schema.XmlSchemaComplexType
+ Dim type As System.Xml.Schema.XmlSchemaComplexType = New System.Xml.Schema.XmlSchemaComplexType
+ Dim sequence As System.Xml.Schema.XmlSchemaSequence = New System.Xml.Schema.XmlSchemaSequence
+ Dim ds As CatSubCatAdventureWorks_DataDataSet = New CatSubCatAdventureWorks_DataDataSet
+ xs.Add(ds.GetSchemaSerializable)
+ Dim any1 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny
+ any1.Namespace = "http://www.w3.org/2001/XMLSchema"
+ any1.MinOccurs = New Decimal(0)
+ any1.MaxOccurs = Decimal.MaxValue
+ any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax
+ sequence.Items.Add(any1)
+ Dim any2 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny
+ any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"
+ any2.MinOccurs = New Decimal(1)
+ any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax
+ sequence.Items.Add(any2)
+ Dim attribute1 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute
+ attribute1.Name = "namespace"
+ attribute1.FixedValue = ds.Namespace
+ type.Attributes.Add(attribute1)
+ Dim attribute2 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute
+ attribute2.Name = "tableTypeName"
+ attribute2.FixedValue = "ProductSubcategoryDataTable"
+ type.Attributes.Add(attribute2)
+ type.Particle = sequence
+ Return type
+ End Function
+ End Class
+
+ _
+ Partial Public Class ProductCategoryRow
+ Inherits System.Data.DataRow
+
+ Private tableProductCategory As ProductCategoryDataTable
+
+ _
+ Friend Sub New(ByVal rb As System.Data.DataRowBuilder)
+ MyBase.New(rb)
+ Me.tableProductCategory = CType(Me.Table,ProductCategoryDataTable)
+ End Sub
+
+ _
+ Public Property ProductCategoryID() As Integer
+ Get
+ Return CType(Me(Me.tableProductCategory.ProductCategoryIDColumn),Integer)
+ End Get
+ Set
+ Me(Me.tableProductCategory.ProductCategoryIDColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property Name() As String
+ Get
+ Return CType(Me(Me.tableProductCategory.NameColumn),String)
+ End Get
+ Set
+ Me(Me.tableProductCategory.NameColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property rowguid() As System.Guid
+ Get
+ Return CType(Me(Me.tableProductCategory.rowguidColumn),System.Guid)
+ End Get
+ Set
+ Me(Me.tableProductCategory.rowguidColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property ModifiedDate() As Date
+ Get
+ Return CType(Me(Me.tableProductCategory.ModifiedDateColumn),Date)
+ End Get
+ Set
+ Me(Me.tableProductCategory.ModifiedDateColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Function GetProductSubcategoryRows() As ProductSubcategoryRow()
+ Return CType(MyBase.GetChildRows(Me.Table.ChildRelations("FK_ProductSubcategory_ProductCategory_ProductCategoryID")),ProductSubcategoryRow())
+ End Function
+ End Class
+
+ _
+ Partial Public Class ProductSubcategoryRow
+ Inherits System.Data.DataRow
+
+ Private tableProductSubcategory As ProductSubcategoryDataTable
+
+ _
+ Friend Sub New(ByVal rb As System.Data.DataRowBuilder)
+ MyBase.New(rb)
+ Me.tableProductSubcategory = CType(Me.Table,ProductSubcategoryDataTable)
+ End Sub
+
+ _
+ Public Property ProductSubcategoryID() As Integer
+ Get
+ Return CType(Me(Me.tableProductSubcategory.ProductSubcategoryIDColumn),Integer)
+ End Get
+ Set
+ Me(Me.tableProductSubcategory.ProductSubcategoryIDColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property ProductCategoryID() As Integer
+ Get
+ Return CType(Me(Me.tableProductSubcategory.ProductCategoryIDColumn),Integer)
+ End Get
+ Set
+ Me(Me.tableProductSubcategory.ProductCategoryIDColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property Name() As String
+ Get
+ Return CType(Me(Me.tableProductSubcategory.NameColumn),String)
+ End Get
+ Set
+ Me(Me.tableProductSubcategory.NameColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property rowguid() As System.Guid
+ Get
+ Return CType(Me(Me.tableProductSubcategory.rowguidColumn),System.Guid)
+ End Get
+ Set
+ Me(Me.tableProductSubcategory.rowguidColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property ModifiedDate() As Date
+ Get
+ Return CType(Me(Me.tableProductSubcategory.ModifiedDateColumn),Date)
+ End Get
+ Set
+ Me(Me.tableProductSubcategory.ModifiedDateColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property ProductCategoryRow() As ProductCategoryRow
+ Get
+ Return CType(Me.GetParentRow(Me.Table.ParentRelations("FK_ProductSubcategory_ProductCategory_ProductCategoryID")),ProductCategoryRow)
+ End Get
+ Set
+ Me.SetParentRow(value, Me.Table.ParentRelations("FK_ProductSubcategory_ProductCategory_ProductCategoryID"))
+ End Set
+ End Property
+ End Class
+
+ _
+ Public Class ProductCategoryRowChangeEvent
+ Inherits System.EventArgs
+
+ Private eventRow As ProductCategoryRow
+
+ Private eventAction As System.Data.DataRowAction
+
+ _
+ Public Sub New(ByVal row As ProductCategoryRow, ByVal action As System.Data.DataRowAction)
+ MyBase.New
+ Me.eventRow = row
+ Me.eventAction = action
+ End Sub
+
+ _
+ Public ReadOnly Property Row() As ProductCategoryRow
+ Get
+ Return Me.eventRow
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property Action() As System.Data.DataRowAction
+ Get
+ Return Me.eventAction
+ End Get
+ End Property
+ End Class
+
+ _
+ Public Class ProductSubcategoryRowChangeEvent
+ Inherits System.EventArgs
+
+ Private eventRow As ProductSubcategoryRow
+
+ Private eventAction As System.Data.DataRowAction
+
+ _
+ Public Sub New(ByVal row As ProductSubcategoryRow, ByVal action As System.Data.DataRowAction)
+ MyBase.New
+ Me.eventRow = row
+ Me.eventAction = action
+ End Sub
+
+ _
+ Public ReadOnly Property Row() As ProductSubcategoryRow
+ Get
+ Return Me.eventRow
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property Action() As System.Data.DataRowAction
+ Get
+ Return Me.eventAction
+ End Get
+ End Property
+ End Class
+End Class
+
+Namespace CatSubCatAdventureWorks_DataDataSetTableAdapters
+
+ _
+ Partial Public Class ProductCategoryTableAdapter
+ Inherits System.ComponentModel.Component
+
+ Private WithEvents _adapter As System.Data.SqlClient.SqlDataAdapter
+
+ Private _connection As System.Data.SqlClient.SqlConnection
+
+ Private _commandCollection() As System.Data.SqlClient.SqlCommand
+
+ Private _clearBeforeFill As Boolean
+
+ _
+ Public Sub New()
+ MyBase.New
+ Me.ClearBeforeFill = true
+ End Sub
+
+ _
+ Private ReadOnly Property Adapter() As System.Data.SqlClient.SqlDataAdapter
+ Get
+ If (Me._adapter Is Nothing) Then
+ Me.InitAdapter
+ End If
+ Return Me._adapter
+ End Get
+ End Property
+
+ _
+ Friend Property Connection() As System.Data.SqlClient.SqlConnection
+ Get
+ If (Me._connection Is Nothing) Then
+ Me.InitConnection
+ End If
+ Return Me._connection
+ End Get
+ Set
+ Me._connection = value
+ If (Not (Me.Adapter.InsertCommand) Is Nothing) Then
+ Me.Adapter.InsertCommand.Connection = value
+ End If
+ If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then
+ Me.Adapter.DeleteCommand.Connection = value
+ End If
+ If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then
+ Me.Adapter.UpdateCommand.Connection = value
+ End If
+ Dim i As Integer = 0
+ Do While (i < Me.CommandCollection.Length)
+ If (Not (Me.CommandCollection(i)) Is Nothing) Then
+ CType(Me.CommandCollection(i),System.Data.SqlClient.SqlCommand).Connection = value
+ End If
+ i = (i + 1)
+ Loop
+ End Set
+ End Property
+
+ _
+ Protected ReadOnly Property CommandCollection() As System.Data.SqlClient.SqlCommand()
+ Get
+ If (Me._commandCollection Is Nothing) Then
+ Me.InitCommandCollection
+ End If
+ Return Me._commandCollection
+ End Get
+ End Property
+
+ _
+ Public Property ClearBeforeFill() As Boolean
+ Get
+ Return Me._clearBeforeFill
+ End Get
+ Set
+ Me._clearBeforeFill = value
+ End Set
+ End Property
+
+ _
+ Private Sub InitAdapter()
+ Me._adapter = New System.Data.SqlClient.SqlDataAdapter
+ Dim tableMapping As System.Data.Common.DataTableMapping = New System.Data.Common.DataTableMapping
+ tableMapping.SourceTable = "Table"
+ tableMapping.DataSetTable = "ProductCategory"
+ tableMapping.ColumnMappings.Add("ProductCategoryID", "ProductCategoryID")
+ tableMapping.ColumnMappings.Add("Name", "Name")
+ tableMapping.ColumnMappings.Add("rowguid", "rowguid")
+ tableMapping.ColumnMappings.Add("ModifiedDate", "ModifiedDate")
+ Me._adapter.TableMappings.Add(tableMapping)
+ Me._adapter.DeleteCommand = New System.Data.SqlClient.SqlCommand
+ Me._adapter.DeleteCommand.Connection = Me.Connection
+ Me._adapter.DeleteCommand.CommandText = "DELETE FROM [Production].[ProductCategory] WHERE (([ProductCategoryID] = @Origina"& _
+ "l_ProductCategoryID) AND ([Name] = @Original_Name) AND ([rowguid] = @Original_ro"& _
+ "wguid) AND ([ModifiedDate] = @Original_ModifiedDate))"
+ Me._adapter.DeleteCommand.CommandType = System.Data.CommandType.Text
+ Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ProductCategoryID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "ProductCategoryID", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Name", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Name", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_rowguid", System.Data.SqlDbType.UniqueIdentifier, 0, System.Data.ParameterDirection.Input, 0, 0, "rowguid", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ModifiedDate", System.Data.SqlDbType.DateTime, 0, System.Data.ParameterDirection.Input, 0, 0, "ModifiedDate", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.InsertCommand = New System.Data.SqlClient.SqlCommand
+ Me._adapter.InsertCommand.Connection = Me.Connection
+ Me._adapter.InsertCommand.CommandText = "INSERT INTO [Production].[ProductCategory] ([Name], [rowguid], [ModifiedDate]) VA"& _
+ "LUES (@Name, @rowguid, @ModifiedDate);"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT ProductCategoryID, Name, rowguid,"& _
+ " ModifiedDate FROM Production.ProductCategory WHERE (ProductCategoryID = SCOPE_I"& _
+ "DENTITY())"
+ Me._adapter.InsertCommand.CommandType = System.Data.CommandType.Text
+ Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Name", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Name", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@rowguid", System.Data.SqlDbType.UniqueIdentifier, 0, System.Data.ParameterDirection.Input, 0, 0, "rowguid", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ModifiedDate", System.Data.SqlDbType.DateTime, 0, System.Data.ParameterDirection.Input, 0, 0, "ModifiedDate", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand = New System.Data.SqlClient.SqlCommand
+ Me._adapter.UpdateCommand.Connection = Me.Connection
+ Me._adapter.UpdateCommand.CommandText = "UPDATE [Production].[ProductCategory] SET [Name] = @Name, [rowguid] = @rowguid, ["& _
+ "ModifiedDate] = @ModifiedDate WHERE (([ProductCategoryID] = @Original_ProductCat"& _
+ "egoryID) AND ([Name] = @Original_Name) AND ([rowguid] = @Original_rowguid) AND ("& _
+ "[ModifiedDate] = @Original_ModifiedDate));"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT ProductCategoryID, Name, rowg"& _
+ "uid, ModifiedDate FROM Production.ProductCategory WHERE (ProductCategoryID = @Pr"& _
+ "oductCategoryID)"
+ Me._adapter.UpdateCommand.CommandType = System.Data.CommandType.Text
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Name", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Name", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@rowguid", System.Data.SqlDbType.UniqueIdentifier, 0, System.Data.ParameterDirection.Input, 0, 0, "rowguid", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ModifiedDate", System.Data.SqlDbType.DateTime, 0, System.Data.ParameterDirection.Input, 0, 0, "ModifiedDate", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ProductCategoryID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "ProductCategoryID", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Name", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Name", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_rowguid", System.Data.SqlDbType.UniqueIdentifier, 0, System.Data.ParameterDirection.Input, 0, 0, "rowguid", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ModifiedDate", System.Data.SqlDbType.DateTime, 0, System.Data.ParameterDirection.Input, 0, 0, "ModifiedDate", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ProductCategoryID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, 0, 0, "ProductCategoryID", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ End Sub
+
+ _
+ Private Sub InitConnection()
+ Me._connection = New System.Data.SqlClient.SqlConnection
+ Me._connection.ConnectionString = Global.WinChap13.My.MySettings.Default.AdventureWorks_DataConnectionString
+ End Sub
+
+ _
+ Private Sub InitCommandCollection()
+ Me._commandCollection = New System.Data.SqlClient.SqlCommand(0) {}
+ Me._commandCollection(0) = New System.Data.SqlClient.SqlCommand
+ Me._commandCollection(0).Connection = Me.Connection
+ Me._commandCollection(0).CommandText = "SELECT ProductCategoryID, Name, rowguid, ModifiedDate FROM Production.ProductCate"& _
+ "gory"
+ Me._commandCollection(0).CommandType = System.Data.CommandType.Text
+ End Sub
+
+ _
+ Public Overloads Overridable Function Fill(ByVal dataTable As CatSubCatAdventureWorks_DataDataSet.ProductCategoryDataTable) As Integer
+ Me.Adapter.SelectCommand = Me.CommandCollection(0)
+ If (Me.ClearBeforeFill = true) Then
+ dataTable.Clear
+ End If
+ Dim returnValue As Integer = Me.Adapter.Fill(dataTable)
+ Return returnValue
+ End Function
+
+ _
+ Public Overloads Overridable Function GetData() As CatSubCatAdventureWorks_DataDataSet.ProductCategoryDataTable
+ Me.Adapter.SelectCommand = Me.CommandCollection(0)
+ Dim dataTable As CatSubCatAdventureWorks_DataDataSet.ProductCategoryDataTable = New CatSubCatAdventureWorks_DataDataSet.ProductCategoryDataTable
+ Me.Adapter.Fill(dataTable)
+ Return dataTable
+ End Function
+
+ _
+ Public Overloads Overridable Function Update(ByVal dataTable As CatSubCatAdventureWorks_DataDataSet.ProductCategoryDataTable) As Integer
+ Return Me.Adapter.Update(dataTable)
+ End Function
+
+ _
+ Public Overloads Overridable Function Update(ByVal dataSet As CatSubCatAdventureWorks_DataDataSet) As Integer
+ Return Me.Adapter.Update(dataSet, "ProductCategory")
+ End Function
+
+ _
+ Public Overloads Overridable Function Update(ByVal dataRow As System.Data.DataRow) As Integer
+ Return Me.Adapter.Update(New System.Data.DataRow() {dataRow})
+ End Function
+
+ _
+ Public Overloads Overridable Function Update(ByVal dataRows() As System.Data.DataRow) As Integer
+ Return Me.Adapter.Update(dataRows)
+ End Function
+
+ _
+ Public Overloads Overridable Function Delete(ByVal Original_ProductCategoryID As Integer, ByVal Original_Name As String, ByVal Original_rowguid As System.Guid, ByVal Original_ModifiedDate As Date) As Integer
+ Me.Adapter.DeleteCommand.Parameters(0).Value = CType(Original_ProductCategoryID,Integer)
+ If (Original_Name Is Nothing) Then
+ Throw New System.ArgumentNullException("Original_Name")
+ Else
+ Me.Adapter.DeleteCommand.Parameters(1).Value = CType(Original_Name,String)
+ End If
+ Me.Adapter.DeleteCommand.Parameters(2).Value = CType(Original_rowguid,System.Guid)
+ Me.Adapter.DeleteCommand.Parameters(3).Value = CType(Original_ModifiedDate,Date)
+ Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.DeleteCommand.Connection.State
+ If ((Me.Adapter.DeleteCommand.Connection.State And System.Data.ConnectionState.Open) _
+ <> System.Data.ConnectionState.Open) Then
+ Me.Adapter.DeleteCommand.Connection.Open
+ End If
+ Try
+ Dim returnValue As Integer = Me.Adapter.DeleteCommand.ExecuteNonQuery
+ Return returnValue
+ Finally
+ If (previousConnectionState = System.Data.ConnectionState.Closed) Then
+ Me.Adapter.DeleteCommand.Connection.Close
+ End If
+ End Try
+ End Function
+
+ _
+ Public Overloads Overridable Function Insert(ByVal Name As String, ByVal rowguid As System.Guid, ByVal ModifiedDate As Date) As Integer
+ If (Name Is Nothing) Then
+ Throw New System.ArgumentNullException("Name")
+ Else
+ Me.Adapter.InsertCommand.Parameters(0).Value = CType(Name,String)
+ End If
+ Me.Adapter.InsertCommand.Parameters(1).Value = CType(rowguid,System.Guid)
+ Me.Adapter.InsertCommand.Parameters(2).Value = CType(ModifiedDate,Date)
+ Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.InsertCommand.Connection.State
+ If ((Me.Adapter.InsertCommand.Connection.State And System.Data.ConnectionState.Open) _
+ <> System.Data.ConnectionState.Open) Then
+ Me.Adapter.InsertCommand.Connection.Open
+ End If
+ Try
+ Dim returnValue As Integer = Me.Adapter.InsertCommand.ExecuteNonQuery
+ Return returnValue
+ Finally
+ If (previousConnectionState = System.Data.ConnectionState.Closed) Then
+ Me.Adapter.InsertCommand.Connection.Close
+ End If
+ End Try
+ End Function
+
+ _
+ Public Overloads Overridable Function Update(ByVal Name As String, ByVal rowguid As System.Guid, ByVal ModifiedDate As Date, ByVal Original_ProductCategoryID As Integer, ByVal Original_Name As String, ByVal Original_rowguid As System.Guid, ByVal Original_ModifiedDate As Date, ByVal ProductCategoryID As Integer) As Integer
+ If (Name Is Nothing) Then
+ Throw New System.ArgumentNullException("Name")
+ Else
+ Me.Adapter.UpdateCommand.Parameters(0).Value = CType(Name,String)
+ End If
+ Me.Adapter.UpdateCommand.Parameters(1).Value = CType(rowguid,System.Guid)
+ Me.Adapter.UpdateCommand.Parameters(2).Value = CType(ModifiedDate,Date)
+ Me.Adapter.UpdateCommand.Parameters(3).Value = CType(Original_ProductCategoryID,Integer)
+ If (Original_Name Is Nothing) Then
+ Throw New System.ArgumentNullException("Original_Name")
+ Else
+ Me.Adapter.UpdateCommand.Parameters(4).Value = CType(Original_Name,String)
+ End If
+ Me.Adapter.UpdateCommand.Parameters(5).Value = CType(Original_rowguid,System.Guid)
+ Me.Adapter.UpdateCommand.Parameters(6).Value = CType(Original_ModifiedDate,Date)
+ Me.Adapter.UpdateCommand.Parameters(7).Value = CType(ProductCategoryID,Integer)
+ Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.UpdateCommand.Connection.State
+ If ((Me.Adapter.UpdateCommand.Connection.State And System.Data.ConnectionState.Open) _
+ <> System.Data.ConnectionState.Open) Then
+ Me.Adapter.UpdateCommand.Connection.Open
+ End If
+ Try
+ Dim returnValue As Integer = Me.Adapter.UpdateCommand.ExecuteNonQuery
+ Return returnValue
+ Finally
+ If (previousConnectionState = System.Data.ConnectionState.Closed) Then
+ Me.Adapter.UpdateCommand.Connection.Close
+ End If
+ End Try
+ End Function
+ End Class
+
+ _
+ Partial Public Class ProductSubcategoryTableAdapter
+ Inherits System.ComponentModel.Component
+
+ Private WithEvents _adapter As System.Data.SqlClient.SqlDataAdapter
+
+ Private _connection As System.Data.SqlClient.SqlConnection
+
+ Private _commandCollection() As System.Data.SqlClient.SqlCommand
+
+ Private _clearBeforeFill As Boolean
+
+ _
+ Public Sub New()
+ MyBase.New
+ Me.ClearBeforeFill = true
+ End Sub
+
+ _
+ Private ReadOnly Property Adapter() As System.Data.SqlClient.SqlDataAdapter
+ Get
+ If (Me._adapter Is Nothing) Then
+ Me.InitAdapter
+ End If
+ Return Me._adapter
+ End Get
+ End Property
+
+ _
+ Friend Property Connection() As System.Data.SqlClient.SqlConnection
+ Get
+ If (Me._connection Is Nothing) Then
+ Me.InitConnection
+ End If
+ Return Me._connection
+ End Get
+ Set
+ Me._connection = value
+ If (Not (Me.Adapter.InsertCommand) Is Nothing) Then
+ Me.Adapter.InsertCommand.Connection = value
+ End If
+ If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then
+ Me.Adapter.DeleteCommand.Connection = value
+ End If
+ If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then
+ Me.Adapter.UpdateCommand.Connection = value
+ End If
+ Dim i As Integer = 0
+ Do While (i < Me.CommandCollection.Length)
+ If (Not (Me.CommandCollection(i)) Is Nothing) Then
+ CType(Me.CommandCollection(i),System.Data.SqlClient.SqlCommand).Connection = value
+ End If
+ i = (i + 1)
+ Loop
+ End Set
+ End Property
+
+ _
+ Protected ReadOnly Property CommandCollection() As System.Data.SqlClient.SqlCommand()
+ Get
+ If (Me._commandCollection Is Nothing) Then
+ Me.InitCommandCollection
+ End If
+ Return Me._commandCollection
+ End Get
+ End Property
+
+ _
+ Public Property ClearBeforeFill() As Boolean
+ Get
+ Return Me._clearBeforeFill
+ End Get
+ Set
+ Me._clearBeforeFill = value
+ End Set
+ End Property
+
+ _
+ Private Sub InitAdapter()
+ Me._adapter = New System.Data.SqlClient.SqlDataAdapter
+ Dim tableMapping As System.Data.Common.DataTableMapping = New System.Data.Common.DataTableMapping
+ tableMapping.SourceTable = "Table"
+ tableMapping.DataSetTable = "ProductSubcategory"
+ tableMapping.ColumnMappings.Add("ProductSubcategoryID", "ProductSubcategoryID")
+ tableMapping.ColumnMappings.Add("ProductCategoryID", "ProductCategoryID")
+ tableMapping.ColumnMappings.Add("Name", "Name")
+ tableMapping.ColumnMappings.Add("rowguid", "rowguid")
+ tableMapping.ColumnMappings.Add("ModifiedDate", "ModifiedDate")
+ Me._adapter.TableMappings.Add(tableMapping)
+ Me._adapter.DeleteCommand = New System.Data.SqlClient.SqlCommand
+ Me._adapter.DeleteCommand.Connection = Me.Connection
+ Me._adapter.DeleteCommand.CommandText = "DELETE FROM [Production].[ProductSubcategory] WHERE (([ProductSubcategoryID] = @O"& _
+ "riginal_ProductSubcategoryID) AND ([ProductCategoryID] = @Original_ProductCatego"& _
+ "ryID) AND ([Name] = @Original_Name) AND ([rowguid] = @Original_rowguid) AND ([Mo"& _
+ "difiedDate] = @Original_ModifiedDate))"
+ Me._adapter.DeleteCommand.CommandType = System.Data.CommandType.Text
+ Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ProductSubcategoryID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "ProductSubcategoryID", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ProductCategoryID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "ProductCategoryID", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Name", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Name", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_rowguid", System.Data.SqlDbType.UniqueIdentifier, 0, System.Data.ParameterDirection.Input, 0, 0, "rowguid", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ModifiedDate", System.Data.SqlDbType.DateTime, 0, System.Data.ParameterDirection.Input, 0, 0, "ModifiedDate", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.InsertCommand = New System.Data.SqlClient.SqlCommand
+ Me._adapter.InsertCommand.Connection = Me.Connection
+ Me._adapter.InsertCommand.CommandText = "INSERT INTO [Production].[ProductSubcategory] ([ProductCategoryID], [Name], [rowg"& _
+ "uid], [ModifiedDate]) VALUES (@ProductCategoryID, @Name, @rowguid, @ModifiedDate"& _
+ ");"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT ProductSubcategoryID, ProductCategoryID, Name, rowguid, ModifiedDate "& _
+ "FROM Production.ProductSubcategory WHERE (ProductSubcategoryID = SCOPE_IDENTITY("& _
+ "))"
+ Me._adapter.InsertCommand.CommandType = System.Data.CommandType.Text
+ Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ProductCategoryID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "ProductCategoryID", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Name", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Name", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@rowguid", System.Data.SqlDbType.UniqueIdentifier, 0, System.Data.ParameterDirection.Input, 0, 0, "rowguid", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ModifiedDate", System.Data.SqlDbType.DateTime, 0, System.Data.ParameterDirection.Input, 0, 0, "ModifiedDate", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand = New System.Data.SqlClient.SqlCommand
+ Me._adapter.UpdateCommand.Connection = Me.Connection
+ Me._adapter.UpdateCommand.CommandText = "UPDATE [Production].[ProductSubcategory] SET [ProductCategoryID] = @ProductCatego"& _
+ "ryID, [Name] = @Name, [rowguid] = @rowguid, [ModifiedDate] = @ModifiedDate WHERE"& _
+ " (([ProductSubcategoryID] = @Original_ProductSubcategoryID) AND ([ProductCategor"& _
+ "yID] = @Original_ProductCategoryID) AND ([Name] = @Original_Name) AND ([rowguid]"& _
+ " = @Original_rowguid) AND ([ModifiedDate] = @Original_ModifiedDate));"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT Pr"& _
+ "oductSubcategoryID, ProductCategoryID, Name, rowguid, ModifiedDate FROM Producti"& _
+ "on.ProductSubcategory WHERE (ProductSubcategoryID = @ProductSubcategoryID)"
+ Me._adapter.UpdateCommand.CommandType = System.Data.CommandType.Text
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ProductCategoryID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "ProductCategoryID", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Name", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Name", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@rowguid", System.Data.SqlDbType.UniqueIdentifier, 0, System.Data.ParameterDirection.Input, 0, 0, "rowguid", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ModifiedDate", System.Data.SqlDbType.DateTime, 0, System.Data.ParameterDirection.Input, 0, 0, "ModifiedDate", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ProductSubcategoryID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "ProductSubcategoryID", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ProductCategoryID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "ProductCategoryID", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Name", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Name", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_rowguid", System.Data.SqlDbType.UniqueIdentifier, 0, System.Data.ParameterDirection.Input, 0, 0, "rowguid", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ModifiedDate", System.Data.SqlDbType.DateTime, 0, System.Data.ParameterDirection.Input, 0, 0, "ModifiedDate", System.Data.DataRowVersion.Original, false, Nothing, "", "", ""))
+ Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ProductSubcategoryID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, 0, 0, "ProductSubcategoryID", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ End Sub
+
+ _
+ Private Sub InitConnection()
+ Me._connection = New System.Data.SqlClient.SqlConnection
+ Me._connection.ConnectionString = Global.WinChap13.My.MySettings.Default.AdventureWorks_DataConnectionString
+ End Sub
+
+ _
+ Private Sub InitCommandCollection()
+ Me._commandCollection = New System.Data.SqlClient.SqlCommand(1) {}
+ Me._commandCollection(0) = New System.Data.SqlClient.SqlCommand
+ Me._commandCollection(0).Connection = Me.Connection
+ Me._commandCollection(0).CommandText = "SELECT ProductSubcategoryID, ProductCategoryID, Name, rowguid, ModifiedDate FROM "& _
+ "Production.ProductSubcategory"
+ Me._commandCollection(0).CommandType = System.Data.CommandType.Text
+ Me._commandCollection(1) = New System.Data.SqlClient.SqlCommand
+ Me._commandCollection(1).Connection = Me.Connection
+ Me._commandCollection(1).CommandText = "SELECT ProductSubcategoryID, ProductCategoryID, Name, rowguid, ModifiedDate "&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"FRO"& _
+ "M Production.ProductSubcategory"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"WHERE ProductCategoryID = @CatID"
+ Me._commandCollection(1).CommandType = System.Data.CommandType.Text
+ Me._commandCollection(1).Parameters.Add(New System.Data.SqlClient.SqlParameter("@CatID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, 0, 0, "ProductCategoryID", System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
+ End Sub
+
+ _
+ Public Overloads Overridable Function Fill(ByVal dataTable As CatSubCatAdventureWorks_DataDataSet.ProductSubcategoryDataTable) As Integer
+ Me.Adapter.SelectCommand = Me.CommandCollection(0)
+ If (Me.ClearBeforeFill = true) Then
+ dataTable.Clear
+ End If
+ Dim returnValue As Integer = Me.Adapter.Fill(dataTable)
+ Return returnValue
+ End Function
+
+ _
+ Public Overloads Overridable Function GetData() As CatSubCatAdventureWorks_DataDataSet.ProductSubcategoryDataTable
+ Me.Adapter.SelectCommand = Me.CommandCollection(0)
+ Dim dataTable As CatSubCatAdventureWorks_DataDataSet.ProductSubcategoryDataTable = New CatSubCatAdventureWorks_DataDataSet.ProductSubcategoryDataTable
+ Me.Adapter.Fill(dataTable)
+ Return dataTable
+ End Function
+
+ _
+ Public Overloads Overridable Function FillByCatID1(ByVal dataTable As CatSubCatAdventureWorks_DataDataSet.ProductSubcategoryDataTable, ByVal CatID As Integer) As Integer
+ Me.Adapter.SelectCommand = Me.CommandCollection(1)
+ Me.Adapter.SelectCommand.Parameters(0).Value = CType(CatID,Integer)
+ If (Me.ClearBeforeFill = true) Then
+ dataTable.Clear
+ End If
+ Dim returnValue As Integer = Me.Adapter.Fill(dataTable)
+ Return returnValue
+ End Function
+
+ _
+ Public Overloads Overridable Function Update(ByVal dataTable As CatSubCatAdventureWorks_DataDataSet.ProductSubcategoryDataTable) As Integer
+ Return Me.Adapter.Update(dataTable)
+ End Function
+
+ _
+ Public Overloads Overridable Function Update(ByVal dataSet As CatSubCatAdventureWorks_DataDataSet) As Integer
+ Return Me.Adapter.Update(dataSet, "ProductSubcategory")
+ End Function
+
+ _
+ Public Overloads Overridable Function Update(ByVal dataRow As System.Data.DataRow) As Integer
+ Return Me.Adapter.Update(New System.Data.DataRow() {dataRow})
+ End Function
+
+ _
+ Public Overloads Overridable Function Update(ByVal dataRows() As System.Data.DataRow) As Integer
+ Return Me.Adapter.Update(dataRows)
+ End Function
+
+ _
+ Public Overloads Overridable Function Delete(ByVal Original_ProductSubcategoryID As Integer, ByVal Original_ProductCategoryID As Integer, ByVal Original_Name As String, ByVal Original_rowguid As System.Guid, ByVal Original_ModifiedDate As Date) As Integer
+ Me.Adapter.DeleteCommand.Parameters(0).Value = CType(Original_ProductSubcategoryID,Integer)
+ Me.Adapter.DeleteCommand.Parameters(1).Value = CType(Original_ProductCategoryID,Integer)
+ If (Original_Name Is Nothing) Then
+ Throw New System.ArgumentNullException("Original_Name")
+ Else
+ Me.Adapter.DeleteCommand.Parameters(2).Value = CType(Original_Name,String)
+ End If
+ Me.Adapter.DeleteCommand.Parameters(3).Value = CType(Original_rowguid,System.Guid)
+ Me.Adapter.DeleteCommand.Parameters(4).Value = CType(Original_ModifiedDate,Date)
+ Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.DeleteCommand.Connection.State
+ If ((Me.Adapter.DeleteCommand.Connection.State And System.Data.ConnectionState.Open) _
+ <> System.Data.ConnectionState.Open) Then
+ Me.Adapter.DeleteCommand.Connection.Open
+ End If
+ Try
+ Dim returnValue As Integer = Me.Adapter.DeleteCommand.ExecuteNonQuery
+ Return returnValue
+ Finally
+ If (previousConnectionState = System.Data.ConnectionState.Closed) Then
+ Me.Adapter.DeleteCommand.Connection.Close
+ End If
+ End Try
+ End Function
+
+ _
+ Public Overloads Overridable Function Insert(ByVal ProductCategoryID As Integer, ByVal Name As String, ByVal rowguid As System.Guid, ByVal ModifiedDate As Date) As Integer
+ Me.Adapter.InsertCommand.Parameters(0).Value = CType(ProductCategoryID,Integer)
+ If (Name Is Nothing) Then
+ Throw New System.ArgumentNullException("Name")
+ Else
+ Me.Adapter.InsertCommand.Parameters(1).Value = CType(Name,String)
+ End If
+ Me.Adapter.InsertCommand.Parameters(2).Value = CType(rowguid,System.Guid)
+ Me.Adapter.InsertCommand.Parameters(3).Value = CType(ModifiedDate,Date)
+ Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.InsertCommand.Connection.State
+ If ((Me.Adapter.InsertCommand.Connection.State And System.Data.ConnectionState.Open) _
+ <> System.Data.ConnectionState.Open) Then
+ Me.Adapter.InsertCommand.Connection.Open
+ End If
+ Try
+ Dim returnValue As Integer = Me.Adapter.InsertCommand.ExecuteNonQuery
+ Return returnValue
+ Finally
+ If (previousConnectionState = System.Data.ConnectionState.Closed) Then
+ Me.Adapter.InsertCommand.Connection.Close
+ End If
+ End Try
+ End Function
+
+ _
+ Public Overloads Overridable Function Update(ByVal ProductCategoryID As Integer, ByVal Name As String, ByVal rowguid As System.Guid, ByVal ModifiedDate As Date, ByVal Original_ProductSubcategoryID As Integer, ByVal Original_ProductCategoryID As Integer, ByVal Original_Name As String, ByVal Original_rowguid As System.Guid, ByVal Original_ModifiedDate As Date, ByVal ProductSubcategoryID As Integer) As Integer
+ Me.Adapter.UpdateCommand.Parameters(0).Value = CType(ProductCategoryID,Integer)
+ If (Name Is Nothing) Then
+ Throw New System.ArgumentNullException("Name")
+ Else
+ Me.Adapter.UpdateCommand.Parameters(1).Value = CType(Name,String)
+ End If
+ Me.Adapter.UpdateCommand.Parameters(2).Value = CType(rowguid,System.Guid)
+ Me.Adapter.UpdateCommand.Parameters(3).Value = CType(ModifiedDate,Date)
+ Me.Adapter.UpdateCommand.Parameters(4).Value = CType(Original_ProductSubcategoryID,Integer)
+ Me.Adapter.UpdateCommand.Parameters(5).Value = CType(Original_ProductCategoryID,Integer)
+ If (Original_Name Is Nothing) Then
+ Throw New System.ArgumentNullException("Original_Name")
+ Else
+ Me.Adapter.UpdateCommand.Parameters(6).Value = CType(Original_Name,String)
+ End If
+ Me.Adapter.UpdateCommand.Parameters(7).Value = CType(Original_rowguid,System.Guid)
+ Me.Adapter.UpdateCommand.Parameters(8).Value = CType(Original_ModifiedDate,Date)
+ Me.Adapter.UpdateCommand.Parameters(9).Value = CType(ProductSubcategoryID,Integer)
+ Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.UpdateCommand.Connection.State
+ If ((Me.Adapter.UpdateCommand.Connection.State And System.Data.ConnectionState.Open) _
+ <> System.Data.ConnectionState.Open) Then
+ Me.Adapter.UpdateCommand.Connection.Open
+ End If
+ Try
+ Dim returnValue As Integer = Me.Adapter.UpdateCommand.ExecuteNonQuery
+ Return returnValue
+ Finally
+ If (previousConnectionState = System.Data.ConnectionState.Closed) Then
+ Me.Adapter.UpdateCommand.Connection.Close
+ End If
+ End Try
+ End Function
+ End Class
+End Namespace
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.xsc b/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.xsc
new file mode 100644
index 0000000..eaf0fcf
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.xsc
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.xsd b/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.xsd
new file mode 100644
index 0000000..aab6b77
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.xsd
@@ -0,0 +1,239 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DELETE FROM [Production].[ProductCategory] WHERE (([ProductCategoryID] = @Original_ProductCategoryID) AND ([Name] = @Original_Name) AND ([rowguid] = @Original_rowguid) AND ([ModifiedDate] = @Original_ModifiedDate))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ INSERT INTO [Production].[ProductCategory] ([Name], [rowguid], [ModifiedDate]) VALUES (@Name, @rowguid, @ModifiedDate);
+SELECT ProductCategoryID, Name, rowguid, ModifiedDate FROM Production.ProductCategory WHERE (ProductCategoryID = SCOPE_IDENTITY())
+
+
+
+
+
+
+
+
+
+
+
+
+ SELECT ProductCategoryID, Name, rowguid, ModifiedDate FROM Production.ProductCategory
+
+
+
+
+
+
+ UPDATE [Production].[ProductCategory] SET [Name] = @Name, [rowguid] = @rowguid, [ModifiedDate] = @ModifiedDate WHERE (([ProductCategoryID] = @Original_ProductCategoryID) AND ([Name] = @Original_Name) AND ([rowguid] = @Original_rowguid) AND ([ModifiedDate] = @Original_ModifiedDate));
+SELECT ProductCategoryID, Name, rowguid, ModifiedDate FROM Production.ProductCategory WHERE (ProductCategoryID = @ProductCategoryID)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DELETE FROM [Production].[ProductSubcategory] WHERE (([ProductSubcategoryID] = @Original_ProductSubcategoryID) AND ([ProductCategoryID] = @Original_ProductCategoryID) AND ([Name] = @Original_Name) AND ([rowguid] = @Original_rowguid) AND ([ModifiedDate] = @Original_ModifiedDate))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ INSERT INTO [Production].[ProductSubcategory] ([ProductCategoryID], [Name], [rowguid], [ModifiedDate]) VALUES (@ProductCategoryID, @Name, @rowguid, @ModifiedDate);
+SELECT ProductSubcategoryID, ProductCategoryID, Name, rowguid, ModifiedDate FROM Production.ProductSubcategory WHERE (ProductSubcategoryID = SCOPE_IDENTITY())
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SELECT ProductSubcategoryID, ProductCategoryID, Name, rowguid, ModifiedDate FROM Production.ProductSubcategory
+
+
+
+
+
+
+ UPDATE [Production].[ProductSubcategory] SET [ProductCategoryID] = @ProductCategoryID, [Name] = @Name, [rowguid] = @rowguid, [ModifiedDate] = @ModifiedDate WHERE (([ProductSubcategoryID] = @Original_ProductSubcategoryID) AND ([ProductCategoryID] = @Original_ProductCategoryID) AND ([Name] = @Original_Name) AND ([rowguid] = @Original_rowguid) AND ([ModifiedDate] = @Original_ModifiedDate));
+SELECT ProductSubcategoryID, ProductCategoryID, Name, rowguid, ModifiedDate FROM Production.ProductSubcategory WHERE (ProductSubcategoryID = @ProductSubcategoryID)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SELECT ProductSubcategoryID, ProductCategoryID, Name, rowguid, ModifiedDate
+FROM Production.ProductSubcategory
+WHERE ProductCategoryID = @CatID
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.xss b/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.xss
new file mode 100644
index 0000000..a7943ff
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/CatSubCatAdventureWorks_DataDataSet.xss
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+ 307
+ 139
+
+
+ 377
+ 139
+
+
+
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form1.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form1.Designer.vb
new file mode 100644
index 0000000..0380318
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form1.Designer.vb
@@ -0,0 +1,253 @@
+ _
+Partial Class Form1
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
+Me.CatSubCatAdventureWorks_DataDataSet = New WinChap13.CatSubCatAdventureWorks_DataDataSet
+Me.ProductCategoryBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.ProductCategoryTableAdapter = New WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+Me.ProductCategoryBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
+Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox
+Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel
+Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton
+Me.ProductCategoryBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton
+Me.ProductCategoryDataGridView = New System.Windows.Forms.DataGridView
+Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn2 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn3 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn4 = New System.Windows.Forms.DataGridViewTextBoxColumn
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.ProductCategoryBindingNavigator.SuspendLayout()
+CType(Me.ProductCategoryDataGridView, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.SuspendLayout()
+'
+'CatSubCatAdventureWorks_DataDataSet
+'
+Me.CatSubCatAdventureWorks_DataDataSet.DataSetName = "CatSubCatAdventureWorks_DataDataSet"
+Me.CatSubCatAdventureWorks_DataDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'ProductCategoryBindingSource
+'
+Me.ProductCategoryBindingSource.DataMember = "ProductCategory"
+Me.ProductCategoryBindingSource.DataSource = Me.CatSubCatAdventureWorks_DataDataSet
+'
+'ProductCategoryTableAdapter
+'
+Me.ProductCategoryTableAdapter.ClearBeforeFill = True
+'
+'ProductCategoryBindingNavigator
+'
+Me.ProductCategoryBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem
+Me.ProductCategoryBindingNavigator.BindingSource = Me.ProductCategoryBindingSource
+Me.ProductCategoryBindingNavigator.CountItem = Me.BindingNavigatorCountItem
+Me.ProductCategoryBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem
+Me.ProductCategoryBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.ProductCategoryBindingNavigatorSaveItem})
+Me.ProductCategoryBindingNavigator.Location = New System.Drawing.Point(0, 0)
+Me.ProductCategoryBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
+Me.ProductCategoryBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
+Me.ProductCategoryBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
+Me.ProductCategoryBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
+Me.ProductCategoryBindingNavigator.Name = "ProductCategoryBindingNavigator"
+Me.ProductCategoryBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
+Me.ProductCategoryBindingNavigator.Size = New System.Drawing.Size(360, 25)
+Me.ProductCategoryBindingNavigator.TabIndex = 0
+Me.ProductCategoryBindingNavigator.Text = "BindingNavigator1"
+'
+'BindingNavigatorMoveFirstItem
+'
+Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
+Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveFirstItem.Text = "Move first"
+'
+'BindingNavigatorMovePreviousItem
+'
+Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
+Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMovePreviousItem.Text = "Move previous"
+'
+'BindingNavigatorSeparator
+'
+Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorPositionItem
+'
+Me.BindingNavigatorPositionItem.AccessibleName = "Position"
+Me.BindingNavigatorPositionItem.AutoSize = False
+Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
+Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21)
+Me.BindingNavigatorPositionItem.Text = "0"
+Me.BindingNavigatorPositionItem.ToolTipText = "Current position"
+'
+'BindingNavigatorCountItem
+'
+Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
+Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 13)
+Me.BindingNavigatorCountItem.Text = "of {0}"
+Me.BindingNavigatorCountItem.ToolTipText = "Total number of items"
+'
+'BindingNavigatorSeparator1
+'
+Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorMoveNextItem
+'
+Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
+Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveNextItem.Text = "Move next"
+'
+'BindingNavigatorMoveLastItem
+'
+Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
+Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveLastItem.Text = "Move last"
+'
+'BindingNavigatorSeparator2
+'
+Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorAddNewItem
+'
+Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem"
+Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorAddNewItem.Text = "Add new"
+'
+'BindingNavigatorDeleteItem
+'
+Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem"
+Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorDeleteItem.Text = "Delete"
+'
+'ProductCategoryBindingNavigatorSaveItem
+'
+Me.ProductCategoryBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.ProductCategoryBindingNavigatorSaveItem.Image = CType(resources.GetObject("ProductCategoryBindingNavigatorSaveItem.Image"), System.Drawing.Image)
+Me.ProductCategoryBindingNavigatorSaveItem.Name = "ProductCategoryBindingNavigatorSaveItem"
+Me.ProductCategoryBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 23)
+Me.ProductCategoryBindingNavigatorSaveItem.Text = "Save Data"
+'
+'ProductCategoryDataGridView
+'
+Me.ProductCategoryDataGridView.AutoGenerateColumns = False
+Me.ProductCategoryDataGridView.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.DataGridViewTextBoxColumn1, Me.DataGridViewTextBoxColumn2, Me.DataGridViewTextBoxColumn3, Me.DataGridViewTextBoxColumn4})
+Me.ProductCategoryDataGridView.DataSource = Me.ProductCategoryBindingSource
+Me.ProductCategoryDataGridView.Location = New System.Drawing.Point(40, 77)
+Me.ProductCategoryDataGridView.Name = "ProductCategoryDataGridView"
+Me.ProductCategoryDataGridView.Size = New System.Drawing.Size(300, 220)
+Me.ProductCategoryDataGridView.TabIndex = 1
+'
+'DataGridViewTextBoxColumn1
+'
+Me.DataGridViewTextBoxColumn1.DataPropertyName = "ProductCategoryID"
+Me.DataGridViewTextBoxColumn1.HeaderText = "ProductCategoryID"
+Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1"
+Me.DataGridViewTextBoxColumn1.ReadOnly = True
+'
+'DataGridViewTextBoxColumn2
+'
+Me.DataGridViewTextBoxColumn2.DataPropertyName = "Name"
+Me.DataGridViewTextBoxColumn2.HeaderText = "Name"
+Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2"
+'
+'DataGridViewTextBoxColumn3
+'
+Me.DataGridViewTextBoxColumn3.DataPropertyName = "rowguid"
+Me.DataGridViewTextBoxColumn3.HeaderText = "rowguid"
+Me.DataGridViewTextBoxColumn3.Name = "DataGridViewTextBoxColumn3"
+'
+'DataGridViewTextBoxColumn4
+'
+Me.DataGridViewTextBoxColumn4.DataPropertyName = "ModifiedDate"
+Me.DataGridViewTextBoxColumn4.HeaderText = "ModifiedDate"
+Me.DataGridViewTextBoxColumn4.Name = "DataGridViewTextBoxColumn4"
+'
+'Form1
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(360, 317)
+Me.Controls.Add(Me.ProductCategoryDataGridView)
+Me.Controls.Add(Me.ProductCategoryBindingNavigator)
+Me.Name = "Form1"
+Me.Text = "Form1"
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ProductCategoryBindingNavigator.ResumeLayout(False)
+Me.ProductCategoryBindingNavigator.PerformLayout()
+CType(Me.ProductCategoryDataGridView, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents CatSubCatAdventureWorks_DataDataSet As WinChap13.CatSubCatAdventureWorks_DataDataSet
+ Friend WithEvents ProductCategoryBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents ProductCategoryTableAdapter As WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+ Friend WithEvents ProductCategoryBindingNavigator As System.Windows.Forms.BindingNavigator
+ Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents ProductCategoryBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents ProductCategoryDataGridView As System.Windows.Forms.DataGridView
+ Friend WithEvents DataGridViewTextBoxColumn1 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn2 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn3 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn4 As System.Windows.Forms.DataGridViewTextBoxColumn
+
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form1.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form1.resx
new file mode 100644
index 0000000..1fdec5b
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form1.resx
@@ -0,0 +1,218 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 271, 17
+
+
+ 17, 54
+
+
+ 217, 54
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0
+ 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q
+ /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/
+ /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p
+ QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/
+ O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk
+ GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o
+ w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3
+ MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg
+ YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU
+ hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V
+ hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72
+ tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD
+ HEVvQ/IAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0
+ oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+
+ ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D
+ Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF
+ 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY
+ Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA
+ AElFTkSuQmCC
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy
+ ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v
+ kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP
+ Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ
+ FGCYkuTLEQAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0
+ oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/
+ ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D
+ W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg
+ gg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU
+ oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7
+ PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc
+ MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce
+ uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm
+ F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm
+ x8MAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L
+ k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz
+ V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3
+ yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W
+ YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y
+ C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C
+ 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp
+ HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs
+ NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy
+ Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv
+ f/R3bGg6a0rM640AAAAASUVORK5CYII=
+
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form1.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form1.vb
new file mode 100644
index 0000000..c9fe308
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form1.vb
@@ -0,0 +1,15 @@
+Public Class Form1
+
+Private Sub ProductCategoryBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductCategoryBindingNavigatorSaveItem.Click
+Me.Validate()
+Me.ProductCategoryBindingSource.EndEdit()
+Me.ProductCategoryTableAdapter.Update(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+End Sub
+
+Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'CatSubCatAdventureWorks_DataDataSet.ProductCategory' table. You can move, or remove it, as needed.
+Me.ProductCategoryTableAdapter.Fill(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+End Sub
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form10.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form10.Designer.vb
new file mode 100644
index 0000000..a4c0936
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form10.Designer.vb
@@ -0,0 +1,174 @@
+ _
+Partial Class Form10
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Dim TitleLabel As System.Windows.Forms.Label
+Dim TitleSalesLabel As System.Windows.Forms.Label
+Me.ListBox1 = New System.Windows.Forms.ListBox
+Me.PubsDataSet = New WinChap13.pubsDataSet
+Me.VTitleSalesBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.VTitleSalesTableAdapter = New WinChap13.pubsDataSetTableAdapters.vTitleSalesTableAdapter
+Me.SalesForATitleIDBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.SalesForATitleIDTableAdapter = New WinChap13.pubsDataSetTableAdapters.SalesForATitleIDTableAdapter
+Me.FillToolStrip = New System.Windows.Forms.ToolStrip
+Me.TitleidToolStripLabel = New System.Windows.Forms.ToolStripLabel
+Me.TitleidToolStripTextBox = New System.Windows.Forms.ToolStripTextBox
+Me.FillToolStripButton = New System.Windows.Forms.ToolStripButton
+Me.TitleTextBox = New System.Windows.Forms.TextBox
+Me.TitleSalesTextBox = New System.Windows.Forms.TextBox
+TitleLabel = New System.Windows.Forms.Label
+TitleSalesLabel = New System.Windows.Forms.Label
+CType(Me.PubsDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.VTitleSalesBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.SalesForATitleIDBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.FillToolStrip.SuspendLayout()
+Me.SuspendLayout()
+'
+'ListBox1
+'
+Me.ListBox1.DataSource = Me.VTitleSalesBindingSource
+Me.ListBox1.DisplayMember = "title"
+Me.ListBox1.FormattingEnabled = True
+Me.ListBox1.Location = New System.Drawing.Point(12, 39)
+Me.ListBox1.Name = "ListBox1"
+Me.ListBox1.Size = New System.Drawing.Size(267, 121)
+Me.ListBox1.TabIndex = 0
+Me.ListBox1.ValueMember = "title_id"
+'
+'PubsDataSet
+'
+Me.PubsDataSet.DataSetName = "pubsDataSet"
+Me.PubsDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'VTitleSalesBindingSource
+'
+Me.VTitleSalesBindingSource.DataMember = "vTitleSales"
+Me.VTitleSalesBindingSource.DataSource = Me.PubsDataSet
+'
+'VTitleSalesTableAdapter
+'
+Me.VTitleSalesTableAdapter.ClearBeforeFill = True
+'
+'SalesForATitleIDBindingSource
+'
+Me.SalesForATitleIDBindingSource.DataMember = "SalesForATitleID"
+Me.SalesForATitleIDBindingSource.DataSource = Me.PubsDataSet
+'
+'SalesForATitleIDTableAdapter
+'
+Me.SalesForATitleIDTableAdapter.ClearBeforeFill = True
+'
+'FillToolStrip
+'
+Me.FillToolStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TitleidToolStripLabel, Me.TitleidToolStripTextBox, Me.FillToolStripButton})
+Me.FillToolStrip.Location = New System.Drawing.Point(0, 0)
+Me.FillToolStrip.Name = "FillToolStrip"
+Me.FillToolStrip.Size = New System.Drawing.Size(299, 25)
+Me.FillToolStrip.TabIndex = 1
+Me.FillToolStrip.Text = "FillToolStrip"
+'
+'TitleidToolStripLabel
+'
+Me.TitleidToolStripLabel.Name = "TitleidToolStripLabel"
+Me.TitleidToolStripLabel.Size = New System.Drawing.Size(37, 22)
+Me.TitleidToolStripLabel.Text = "titleid:"
+'
+'TitleidToolStripTextBox
+'
+Me.TitleidToolStripTextBox.Name = "TitleidToolStripTextBox"
+Me.TitleidToolStripTextBox.Size = New System.Drawing.Size(100, 21)
+'
+'FillToolStripButton
+'
+Me.FillToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
+Me.FillToolStripButton.Name = "FillToolStripButton"
+Me.FillToolStripButton.Size = New System.Drawing.Size(23, 17)
+Me.FillToolStripButton.Text = "Fill"
+'
+'TitleLabel
+'
+TitleLabel.AutoSize = True
+TitleLabel.Location = New System.Drawing.Point(17, 182)
+TitleLabel.Name = "TitleLabel"
+TitleLabel.Size = New System.Drawing.Size(26, 13)
+TitleLabel.TabIndex = 2
+TitleLabel.Text = "title:"
+'
+'TitleTextBox
+'
+Me.TitleTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.SalesForATitleIDBindingSource, "title", True))
+Me.TitleTextBox.Location = New System.Drawing.Point(82, 179)
+Me.TitleTextBox.Name = "TitleTextBox"
+Me.TitleTextBox.Size = New System.Drawing.Size(100, 20)
+Me.TitleTextBox.TabIndex = 3
+'
+'TitleSalesLabel
+'
+TitleSalesLabel.AutoSize = True
+TitleSalesLabel.Location = New System.Drawing.Point(17, 208)
+TitleSalesLabel.Name = "TitleSalesLabel"
+TitleSalesLabel.Size = New System.Drawing.Size(59, 13)
+TitleSalesLabel.TabIndex = 4
+TitleSalesLabel.Text = "Title Sales:"
+'
+'TitleSalesTextBox
+'
+Me.TitleSalesTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.SalesForATitleIDBindingSource, "TitleSales", True))
+Me.TitleSalesTextBox.Location = New System.Drawing.Point(82, 205)
+Me.TitleSalesTextBox.Name = "TitleSalesTextBox"
+Me.TitleSalesTextBox.Size = New System.Drawing.Size(100, 20)
+Me.TitleSalesTextBox.TabIndex = 5
+'
+'Form10
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(299, 266)
+Me.Controls.Add(TitleLabel)
+Me.Controls.Add(Me.TitleTextBox)
+Me.Controls.Add(TitleSalesLabel)
+Me.Controls.Add(Me.TitleSalesTextBox)
+Me.Controls.Add(Me.FillToolStrip)
+Me.Controls.Add(Me.ListBox1)
+Me.Name = "Form10"
+Me.Text = "Form10"
+CType(Me.PubsDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.VTitleSalesBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.SalesForATitleIDBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+Me.FillToolStrip.ResumeLayout(False)
+Me.FillToolStrip.PerformLayout()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
+ Friend WithEvents PubsDataSet As WinChap13.pubsDataSet
+ Friend WithEvents VTitleSalesBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents VTitleSalesTableAdapter As WinChap13.pubsDataSetTableAdapters.vTitleSalesTableAdapter
+ Friend WithEvents SalesForATitleIDBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents SalesForATitleIDTableAdapter As WinChap13.pubsDataSetTableAdapters.SalesForATitleIDTableAdapter
+ Friend WithEvents FillToolStrip As System.Windows.Forms.ToolStrip
+ Friend WithEvents TitleidToolStripLabel As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents TitleidToolStripTextBox As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents FillToolStripButton As System.Windows.Forms.ToolStripButton
+ Friend WithEvents TitleTextBox As System.Windows.Forms.TextBox
+ Friend WithEvents TitleSalesTextBox As System.Windows.Forms.TextBox
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form10.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form10.resx
new file mode 100644
index 0000000..43a58fc
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form10.resx
@@ -0,0 +1,150 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 131, 17
+
+
+ 17, 17
+
+
+ 131, 17
+
+
+ 17, 17
+
+
+ 307, 17
+
+
+ 479, 17
+
+
+ 17, 54
+
+
+ 217, 54
+
+
+ False
+
+
+ False
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form10.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form10.vb
new file mode 100644
index 0000000..03ff7f8
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form10.vb
@@ -0,0 +1,52 @@
+Public Class Form10
+Dim bolClosed, bolShown As Boolean
+
+ Private Sub Form9_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
+ bolClosed = True
+ End Sub
+ Private Sub Form10_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
+ bolShown = True
+ End Sub
+Private Sub Form10_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'PubsDataSet.vTitleSales' table. You can move, or remove it, as needed.
+Me.VTitleSalesTableAdapter.Fill(Me.PubsDataSet.vTitleSales)
+
+ RunStoredProc()
+
+ Me.FillToolStrip.Visible = False
+ Dim intLBDisp As Integer = (Me.ListBox1.Left + Me.ListBox1.Width)
+ Me.TitleTextBox.Width += intLBDisp - _
+ (Me.TitleTextBox.Left + Me.TitleTextBox.Width)
+ Me.TitleSalesTextBox.Width += intLBDisp - _
+ (Me.TitleSalesTextBox.Left + Me.TitleSalesTextBox.Width)
+
+End Sub
+
+'Private Sub FillToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillToolStripButton.Click
+'Try
+' Me.SalesForATitleIDTableAdapter.Fill(Me.PubsDataSet.SalesForATitleID, TitleidToolStripTextBox.Text)
+'Catch ex As System.Exception
+' System.Windows.Forms.MessageBox.Show(ex.Message)
+'End Try
+
+'End Sub
+
+ Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
+
+ Try
+ RunStoredProc()
+ Catch ex As Exception
+ If bolShown = True And bolClosed = False Then
+ MessageBox.Show(ex.ToString)
+ End If
+ End Try
+
+ End Sub
+
+ Sub RunStoredProc()
+ Me.SalesForATitleIDTableAdapter.Fill( _
+ Me.PubsDataSet.SalesForATitleID, _
+ Me.ListBox1.SelectedValue.ToString)
+ End Sub
+
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form11.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form11.Designer.vb
new file mode 100644
index 0000000..c997af2
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form11.Designer.vb
@@ -0,0 +1,265 @@
+ _
+Partial Class Form11
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form11))
+Me.NorthwindDataSet = New WinChap13.NorthwindDataSet
+Me.CustomersBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.CustomersTableAdapter = New WinChap13.NorthwindDataSetTableAdapters.CustomersTableAdapter
+Me.CustomersBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
+Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox
+Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel
+Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton
+Me.CustomersBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton
+Me.CustomersDataGridView = New System.Windows.Forms.DataGridView
+Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn2 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn3 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.Button2 = New System.Windows.Forms.Button
+Me.Button1 = New System.Windows.Forms.Button
+CType(Me.NorthwindDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.CustomersBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.CustomersBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.CustomersBindingNavigator.SuspendLayout()
+CType(Me.CustomersDataGridView, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.SuspendLayout()
+'
+'NorthwindDataSet
+'
+Me.NorthwindDataSet.DataSetName = "NorthwindDataSet"
+Me.NorthwindDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'CustomersBindingSource
+'
+Me.CustomersBindingSource.DataMember = "Customers"
+Me.CustomersBindingSource.DataSource = Me.NorthwindDataSet
+'
+'CustomersTableAdapter
+'
+Me.CustomersTableAdapter.ClearBeforeFill = True
+'
+'CustomersBindingNavigator
+'
+Me.CustomersBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem
+Me.CustomersBindingNavigator.BindingSource = Me.CustomersBindingSource
+Me.CustomersBindingNavigator.CountItem = Me.BindingNavigatorCountItem
+Me.CustomersBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem
+Me.CustomersBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.CustomersBindingNavigatorSaveItem})
+Me.CustomersBindingNavigator.Location = New System.Drawing.Point(0, 0)
+Me.CustomersBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
+Me.CustomersBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
+Me.CustomersBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
+Me.CustomersBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
+Me.CustomersBindingNavigator.Name = "CustomersBindingNavigator"
+Me.CustomersBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
+Me.CustomersBindingNavigator.Size = New System.Drawing.Size(367, 25)
+Me.CustomersBindingNavigator.TabIndex = 0
+Me.CustomersBindingNavigator.Text = "BindingNavigator1"
+'
+'BindingNavigatorMoveFirstItem
+'
+Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
+Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveFirstItem.Text = "Move first"
+'
+'BindingNavigatorMovePreviousItem
+'
+Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
+Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMovePreviousItem.Text = "Move previous"
+'
+'BindingNavigatorSeparator
+'
+Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorPositionItem
+'
+Me.BindingNavigatorPositionItem.AccessibleName = "Position"
+Me.BindingNavigatorPositionItem.AutoSize = False
+Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
+Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21)
+Me.BindingNavigatorPositionItem.Text = "0"
+Me.BindingNavigatorPositionItem.ToolTipText = "Current position"
+'
+'BindingNavigatorCountItem
+'
+Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
+Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 13)
+Me.BindingNavigatorCountItem.Text = "of {0}"
+Me.BindingNavigatorCountItem.ToolTipText = "Total number of items"
+'
+'BindingNavigatorSeparator1
+'
+Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorMoveNextItem
+'
+Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
+Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveNextItem.Text = "Move next"
+'
+'BindingNavigatorMoveLastItem
+'
+Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
+Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveLastItem.Text = "Move last"
+'
+'BindingNavigatorSeparator2
+'
+Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorAddNewItem
+'
+Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem"
+Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorAddNewItem.Text = "Add new"
+'
+'BindingNavigatorDeleteItem
+'
+Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem"
+Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorDeleteItem.Text = "Delete"
+'
+'CustomersBindingNavigatorSaveItem
+'
+Me.CustomersBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.CustomersBindingNavigatorSaveItem.Image = CType(resources.GetObject("CustomersBindingNavigatorSaveItem.Image"), System.Drawing.Image)
+Me.CustomersBindingNavigatorSaveItem.Name = "CustomersBindingNavigatorSaveItem"
+Me.CustomersBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 23)
+Me.CustomersBindingNavigatorSaveItem.Text = "Save Data"
+'
+'CustomersDataGridView
+'
+Me.CustomersDataGridView.AutoGenerateColumns = False
+Me.CustomersDataGridView.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.DataGridViewTextBoxColumn1, Me.DataGridViewTextBoxColumn2, Me.DataGridViewTextBoxColumn3})
+Me.CustomersDataGridView.DataSource = Me.CustomersBindingSource
+Me.CustomersDataGridView.Location = New System.Drawing.Point(12, 76)
+Me.CustomersDataGridView.Name = "CustomersDataGridView"
+Me.CustomersDataGridView.Size = New System.Drawing.Size(343, 220)
+Me.CustomersDataGridView.TabIndex = 1
+'
+'DataGridViewTextBoxColumn1
+'
+Me.DataGridViewTextBoxColumn1.DataPropertyName = "CustomerID"
+Me.DataGridViewTextBoxColumn1.HeaderText = "CustomerID"
+Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1"
+'
+'DataGridViewTextBoxColumn2
+'
+Me.DataGridViewTextBoxColumn2.DataPropertyName = "CompanyName"
+Me.DataGridViewTextBoxColumn2.HeaderText = "CompanyName"
+Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2"
+'
+'DataGridViewTextBoxColumn3
+'
+Me.DataGridViewTextBoxColumn3.DataPropertyName = "ContactName"
+Me.DataGridViewTextBoxColumn3.HeaderText = "ContactName"
+Me.DataGridViewTextBoxColumn3.Name = "DataGridViewTextBoxColumn3"
+'
+'Button2
+'
+Me.Button2.Location = New System.Drawing.Point(94, 47)
+Me.Button2.Name = "Button2"
+Me.Button2.Size = New System.Drawing.Size(75, 23)
+Me.Button2.TabIndex = 5
+Me.Button2.Text = "Button2"
+'
+'Button1
+'
+Me.Button1.Location = New System.Drawing.Point(12, 47)
+Me.Button1.Name = "Button1"
+Me.Button1.Size = New System.Drawing.Size(75, 23)
+Me.Button1.TabIndex = 4
+Me.Button1.Text = "Button1"
+'
+'Form11
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(367, 308)
+Me.Controls.Add(Me.Button2)
+Me.Controls.Add(Me.Button1)
+Me.Controls.Add(Me.CustomersDataGridView)
+Me.Controls.Add(Me.CustomersBindingNavigator)
+Me.Name = "Form11"
+Me.Text = "Form11"
+CType(Me.NorthwindDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.CustomersBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.CustomersBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
+Me.CustomersBindingNavigator.ResumeLayout(False)
+Me.CustomersBindingNavigator.PerformLayout()
+CType(Me.CustomersDataGridView, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents NorthwindDataSet As WinChap13.NorthwindDataSet
+ Friend WithEvents CustomersBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents CustomersTableAdapter As WinChap13.NorthwindDataSetTableAdapters.CustomersTableAdapter
+ Friend WithEvents CustomersBindingNavigator As System.Windows.Forms.BindingNavigator
+ Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents CustomersBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents CustomersDataGridView As System.Windows.Forms.DataGridView
+ Friend WithEvents DataGridViewTextBoxColumn1 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn2 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn3 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents Button2 As System.Windows.Forms.Button
+ Friend WithEvents Button1 As System.Windows.Forms.Button
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form11.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form11.resx
new file mode 100644
index 0000000..8e27875
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form11.resx
@@ -0,0 +1,218 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 159, 17
+
+
+ 334, 17
+
+
+ 504, 17
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0
+ 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q
+ /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/
+ /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p
+ QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/
+ O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk
+ GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o
+ w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3
+ MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg
+ YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU
+ hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V
+ hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72
+ tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD
+ HEVvQ/IAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0
+ oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+
+ ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D
+ Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF
+ 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY
+ Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA
+ AElFTkSuQmCC
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy
+ ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v
+ kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP
+ Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ
+ FGCYkuTLEQAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0
+ oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/
+ ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D
+ W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg
+ gg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU
+ oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7
+ PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc
+ MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce
+ uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm
+ F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm
+ x8MAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L
+ k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz
+ V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3
+ yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W
+ YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y
+ C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C
+ 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp
+ HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs
+ NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy
+ Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv
+ f/R3bGg6a0rM640AAAAASUVORK5CYII=
+
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form11.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form11.vb
new file mode 100644
index 0000000..e9ee9cc
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form11.vb
@@ -0,0 +1,34 @@
+Public Class Form11
+
+Private Sub CustomersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomersBindingNavigatorSaveItem.Click
+Me.Validate()
+Me.CustomersBindingSource.EndEdit()
+Me.CustomersTableAdapter.Update(Me.NorthwindDataSet.Customers)
+
+End Sub
+
+Private Sub Form11_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'NorthwindDataSet.Customers' table. You can move, or remove it, as needed.
+Me.CustomersTableAdapter.Fill(Me.NorthwindDataSet.Customers)
+
+ Me.CustomersBindingNavigator.Visible = False
+ Me.Button1.Text = "Update"
+ Me.Button2.Text = "Refresh"
+' Me.CustomersDataGridView.Columns("CustomerID").Width = 65
+ Me.CustomersDataGridView.Columns(0).Width = 65
+End Sub
+
+ Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
+ Try
+ Me.CustomersTableAdapter.Update(Me.NorthwindDataSet.Customers)
+ Catch ex As System.Data.DBConcurrencyException
+ Me.CustomersTableAdapter.Fill(Me.NorthwindDataSet.Customers)
+ MessageBox.Show("Please enter your changes again and click Update.")
+ End Try
+ End Sub
+
+ Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
+ Me.CustomersTableAdapter.Fill(Me.NorthwindDataSet.Customers)
+ End Sub
+
+End Class
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form2.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form2.Designer.vb
new file mode 100644
index 0000000..6c53084
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form2.Designer.vb
@@ -0,0 +1,296 @@
+ _
+Partial Class Form2
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form2))
+Dim ProductCategoryIDLabel As System.Windows.Forms.Label
+Dim NameLabel As System.Windows.Forms.Label
+Dim RowguidLabel As System.Windows.Forms.Label
+Dim ModifiedDateLabel As System.Windows.Forms.Label
+Me.CatSubCatAdventureWorks_DataDataSet = New WinChap13.CatSubCatAdventureWorks_DataDataSet
+Me.ProductCategoryBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.ProductCategoryTableAdapter = New WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+Me.ProductCategoryBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
+Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox
+Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel
+Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton
+Me.ProductCategoryBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton
+Me.ProductCategoryIDTextBox = New System.Windows.Forms.TextBox
+Me.NameTextBox = New System.Windows.Forms.TextBox
+Me.RowguidTextBox = New System.Windows.Forms.TextBox
+Me.ModifiedDateDateTimePicker = New System.Windows.Forms.DateTimePicker
+ProductCategoryIDLabel = New System.Windows.Forms.Label
+NameLabel = New System.Windows.Forms.Label
+RowguidLabel = New System.Windows.Forms.Label
+ModifiedDateLabel = New System.Windows.Forms.Label
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.ProductCategoryBindingNavigator.SuspendLayout()
+Me.SuspendLayout()
+'
+'CatSubCatAdventureWorks_DataDataSet
+'
+Me.CatSubCatAdventureWorks_DataDataSet.DataSetName = "CatSubCatAdventureWorks_DataDataSet"
+Me.CatSubCatAdventureWorks_DataDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'ProductCategoryBindingSource
+'
+Me.ProductCategoryBindingSource.DataMember = "ProductCategory"
+Me.ProductCategoryBindingSource.DataSource = Me.CatSubCatAdventureWorks_DataDataSet
+'
+'ProductCategoryTableAdapter
+'
+Me.ProductCategoryTableAdapter.ClearBeforeFill = True
+'
+'ProductCategoryBindingNavigator
+'
+Me.ProductCategoryBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem
+Me.ProductCategoryBindingNavigator.BindingSource = Me.ProductCategoryBindingSource
+Me.ProductCategoryBindingNavigator.CountItem = Me.BindingNavigatorCountItem
+Me.ProductCategoryBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem
+Me.ProductCategoryBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.ProductCategoryBindingNavigatorSaveItem})
+Me.ProductCategoryBindingNavigator.Location = New System.Drawing.Point(0, 0)
+Me.ProductCategoryBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
+Me.ProductCategoryBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
+Me.ProductCategoryBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
+Me.ProductCategoryBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
+Me.ProductCategoryBindingNavigator.Name = "ProductCategoryBindingNavigator"
+Me.ProductCategoryBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
+Me.ProductCategoryBindingNavigator.Size = New System.Drawing.Size(356, 25)
+Me.ProductCategoryBindingNavigator.TabIndex = 0
+Me.ProductCategoryBindingNavigator.Text = "BindingNavigator1"
+'
+'BindingNavigatorMoveFirstItem
+'
+Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
+Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveFirstItem.Text = "Move first"
+'
+'BindingNavigatorMovePreviousItem
+'
+Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
+Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMovePreviousItem.Text = "Move previous"
+'
+'BindingNavigatorSeparator
+'
+Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorPositionItem
+'
+Me.BindingNavigatorPositionItem.AccessibleName = "Position"
+Me.BindingNavigatorPositionItem.AutoSize = False
+Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
+Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21)
+Me.BindingNavigatorPositionItem.Text = "0"
+Me.BindingNavigatorPositionItem.ToolTipText = "Current position"
+'
+'BindingNavigatorCountItem
+'
+Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
+Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 13)
+Me.BindingNavigatorCountItem.Text = "of {0}"
+Me.BindingNavigatorCountItem.ToolTipText = "Total number of items"
+'
+'BindingNavigatorSeparator1
+'
+Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorMoveNextItem
+'
+Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
+Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveNextItem.Text = "Move next"
+'
+'BindingNavigatorMoveLastItem
+'
+Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
+Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveLastItem.Text = "Move last"
+'
+'BindingNavigatorSeparator2
+'
+Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorAddNewItem
+'
+Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem"
+Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorAddNewItem.Text = "Add new"
+'
+'BindingNavigatorDeleteItem
+'
+Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem"
+Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorDeleteItem.Text = "Delete"
+'
+'ProductCategoryBindingNavigatorSaveItem
+'
+Me.ProductCategoryBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.ProductCategoryBindingNavigatorSaveItem.Image = CType(resources.GetObject("ProductCategoryBindingNavigatorSaveItem.Image"), System.Drawing.Image)
+Me.ProductCategoryBindingNavigatorSaveItem.Name = "ProductCategoryBindingNavigatorSaveItem"
+Me.ProductCategoryBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 23)
+Me.ProductCategoryBindingNavigatorSaveItem.Text = "Save Data"
+'
+'ProductCategoryIDLabel
+'
+ProductCategoryIDLabel.AutoSize = True
+ProductCategoryIDLabel.Location = New System.Drawing.Point(32, 61)
+ProductCategoryIDLabel.Name = "ProductCategoryIDLabel"
+ProductCategoryIDLabel.Size = New System.Drawing.Size(106, 13)
+ProductCategoryIDLabel.TabIndex = 1
+ProductCategoryIDLabel.Text = "Product Category ID:"
+'
+'ProductCategoryIDTextBox
+'
+Me.ProductCategoryIDTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.ProductCategoryBindingSource, "ProductCategoryID", True))
+Me.ProductCategoryIDTextBox.Location = New System.Drawing.Point(144, 58)
+Me.ProductCategoryIDTextBox.Name = "ProductCategoryIDTextBox"
+Me.ProductCategoryIDTextBox.Size = New System.Drawing.Size(200, 20)
+Me.ProductCategoryIDTextBox.TabIndex = 2
+'
+'NameLabel
+'
+NameLabel.AutoSize = True
+NameLabel.Location = New System.Drawing.Point(32, 87)
+NameLabel.Name = "NameLabel"
+NameLabel.Size = New System.Drawing.Size(38, 13)
+NameLabel.TabIndex = 3
+NameLabel.Text = "Name:"
+'
+'NameTextBox
+'
+Me.NameTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.ProductCategoryBindingSource, "Name", True))
+Me.NameTextBox.Location = New System.Drawing.Point(144, 84)
+Me.NameTextBox.Name = "NameTextBox"
+Me.NameTextBox.Size = New System.Drawing.Size(200, 20)
+Me.NameTextBox.TabIndex = 4
+'
+'RowguidLabel
+'
+RowguidLabel.AutoSize = True
+RowguidLabel.Location = New System.Drawing.Point(32, 113)
+RowguidLabel.Name = "RowguidLabel"
+RowguidLabel.Size = New System.Drawing.Size(47, 13)
+RowguidLabel.TabIndex = 5
+RowguidLabel.Text = "rowguid:"
+'
+'RowguidTextBox
+'
+Me.RowguidTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.ProductCategoryBindingSource, "rowguid", True))
+Me.RowguidTextBox.Location = New System.Drawing.Point(144, 110)
+Me.RowguidTextBox.Name = "RowguidTextBox"
+Me.RowguidTextBox.Size = New System.Drawing.Size(200, 20)
+Me.RowguidTextBox.TabIndex = 6
+'
+'ModifiedDateLabel
+'
+ModifiedDateLabel.AutoSize = True
+ModifiedDateLabel.Location = New System.Drawing.Point(32, 140)
+ModifiedDateLabel.Name = "ModifiedDateLabel"
+ModifiedDateLabel.Size = New System.Drawing.Size(76, 13)
+ModifiedDateLabel.TabIndex = 7
+ModifiedDateLabel.Text = "Modified Date:"
+'
+'ModifiedDateDateTimePicker
+'
+Me.ModifiedDateDateTimePicker.DataBindings.Add(New System.Windows.Forms.Binding("Value", Me.ProductCategoryBindingSource, "ModifiedDate", True))
+Me.ModifiedDateDateTimePicker.Location = New System.Drawing.Point(144, 136)
+Me.ModifiedDateDateTimePicker.Name = "ModifiedDateDateTimePicker"
+Me.ModifiedDateDateTimePicker.Size = New System.Drawing.Size(200, 20)
+Me.ModifiedDateDateTimePicker.TabIndex = 8
+'
+'Form2
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(356, 266)
+Me.Controls.Add(ProductCategoryIDLabel)
+Me.Controls.Add(Me.ProductCategoryIDTextBox)
+Me.Controls.Add(NameLabel)
+Me.Controls.Add(Me.NameTextBox)
+Me.Controls.Add(RowguidLabel)
+Me.Controls.Add(Me.RowguidTextBox)
+Me.Controls.Add(ModifiedDateLabel)
+Me.Controls.Add(Me.ModifiedDateDateTimePicker)
+Me.Controls.Add(Me.ProductCategoryBindingNavigator)
+Me.Name = "Form2"
+Me.Text = "Form2"
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ProductCategoryBindingNavigator.ResumeLayout(False)
+Me.ProductCategoryBindingNavigator.PerformLayout()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents CatSubCatAdventureWorks_DataDataSet As WinChap13.CatSubCatAdventureWorks_DataDataSet
+ Friend WithEvents ProductCategoryBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents ProductCategoryTableAdapter As WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+ Friend WithEvents ProductCategoryBindingNavigator As System.Windows.Forms.BindingNavigator
+ Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents ProductCategoryBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents ProductCategoryIDTextBox As System.Windows.Forms.TextBox
+ Friend WithEvents NameTextBox As System.Windows.Forms.TextBox
+ Friend WithEvents RowguidTextBox As System.Windows.Forms.TextBox
+ Friend WithEvents ModifiedDateDateTimePicker As System.Windows.Forms.DateTimePicker
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form2.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form2.resx
new file mode 100644
index 0000000..27ef07a
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form2.resx
@@ -0,0 +1,230 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 271, 17
+
+
+ 17, 54
+
+
+ 217, 54
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0
+ 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q
+ /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/
+ /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p
+ QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/
+ O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk
+ GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o
+ w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3
+ MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg
+ YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU
+ hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V
+ hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72
+ tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD
+ HEVvQ/IAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0
+ oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+
+ ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D
+ Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF
+ 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY
+ Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA
+ AElFTkSuQmCC
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy
+ ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v
+ kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP
+ Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ
+ FGCYkuTLEQAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0
+ oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/
+ ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D
+ W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg
+ gg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU
+ oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7
+ PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc
+ MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce
+ uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm
+ F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm
+ x8MAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L
+ k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz
+ V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3
+ yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W
+ YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y
+ C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C
+ 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp
+ HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs
+ NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy
+ Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv
+ f/R3bGg6a0rM640AAAAASUVORK5CYII=
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form2.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form2.vb
new file mode 100644
index 0000000..07da571
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form2.vb
@@ -0,0 +1,15 @@
+Public Class Form2
+
+Private Sub ProductCategoryBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductCategoryBindingNavigatorSaveItem.Click
+Me.Validate()
+Me.ProductCategoryBindingSource.EndEdit()
+Me.ProductCategoryTableAdapter.Update(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+End Sub
+
+Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'CatSubCatAdventureWorks_DataDataSet.ProductCategory' table. You can move, or remove it, as needed.
+Me.ProductCategoryTableAdapter.Fill(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+End Sub
+End Class
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form3.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form3.Designer.vb
new file mode 100644
index 0000000..c9f0851
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form3.Designer.vb
@@ -0,0 +1,250 @@
+ _
+Partial Class Form3
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form3))
+Dim ProductCategoryIDLabel As System.Windows.Forms.Label
+Dim NameLabel As System.Windows.Forms.Label
+Me.CatSubCatAdventureWorks_DataDataSet = New WinChap13.CatSubCatAdventureWorks_DataDataSet
+Me.ProductCategoryBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.ProductCategoryTableAdapter = New WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+Me.ProductCategoryBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
+Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox
+Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel
+Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton
+Me.ProductCategoryBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton
+Me.ProductCategoryIDTextBox = New System.Windows.Forms.TextBox
+Me.NameTextBox = New System.Windows.Forms.TextBox
+ProductCategoryIDLabel = New System.Windows.Forms.Label
+NameLabel = New System.Windows.Forms.Label
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.ProductCategoryBindingNavigator.SuspendLayout()
+Me.SuspendLayout()
+'
+'CatSubCatAdventureWorks_DataDataSet
+'
+Me.CatSubCatAdventureWorks_DataDataSet.DataSetName = "CatSubCatAdventureWorks_DataDataSet"
+Me.CatSubCatAdventureWorks_DataDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'ProductCategoryBindingSource
+'
+Me.ProductCategoryBindingSource.DataMember = "ProductCategory"
+Me.ProductCategoryBindingSource.DataSource = Me.CatSubCatAdventureWorks_DataDataSet
+'
+'ProductCategoryTableAdapter
+'
+Me.ProductCategoryTableAdapter.ClearBeforeFill = True
+'
+'ProductCategoryBindingNavigator
+'
+Me.ProductCategoryBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem
+Me.ProductCategoryBindingNavigator.BindingSource = Me.ProductCategoryBindingSource
+Me.ProductCategoryBindingNavigator.CountItem = Me.BindingNavigatorCountItem
+Me.ProductCategoryBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem
+Me.ProductCategoryBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.ProductCategoryBindingNavigatorSaveItem})
+Me.ProductCategoryBindingNavigator.Location = New System.Drawing.Point(0, 0)
+Me.ProductCategoryBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
+Me.ProductCategoryBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
+Me.ProductCategoryBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
+Me.ProductCategoryBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
+Me.ProductCategoryBindingNavigator.Name = "ProductCategoryBindingNavigator"
+Me.ProductCategoryBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
+Me.ProductCategoryBindingNavigator.Size = New System.Drawing.Size(292, 25)
+Me.ProductCategoryBindingNavigator.TabIndex = 0
+Me.ProductCategoryBindingNavigator.Text = "BindingNavigator1"
+'
+'BindingNavigatorMoveFirstItem
+'
+Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
+Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveFirstItem.Text = "Move first"
+'
+'BindingNavigatorMovePreviousItem
+'
+Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
+Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMovePreviousItem.Text = "Move previous"
+'
+'BindingNavigatorSeparator
+'
+Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorPositionItem
+'
+Me.BindingNavigatorPositionItem.AccessibleName = "Position"
+Me.BindingNavigatorPositionItem.AutoSize = False
+Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
+Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21)
+Me.BindingNavigatorPositionItem.Text = "0"
+Me.BindingNavigatorPositionItem.ToolTipText = "Current position"
+'
+'BindingNavigatorCountItem
+'
+Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
+Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 13)
+Me.BindingNavigatorCountItem.Text = "of {0}"
+Me.BindingNavigatorCountItem.ToolTipText = "Total number of items"
+'
+'BindingNavigatorSeparator1
+'
+Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorMoveNextItem
+'
+Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
+Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveNextItem.Text = "Move next"
+'
+'BindingNavigatorMoveLastItem
+'
+Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
+Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveLastItem.Text = "Move last"
+'
+'BindingNavigatorSeparator2
+'
+Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorAddNewItem
+'
+Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem"
+Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorAddNewItem.Text = "Add new"
+'
+'BindingNavigatorDeleteItem
+'
+Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem"
+Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorDeleteItem.Text = "Delete"
+'
+'ProductCategoryBindingNavigatorSaveItem
+'
+Me.ProductCategoryBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.ProductCategoryBindingNavigatorSaveItem.Image = CType(resources.GetObject("ProductCategoryBindingNavigatorSaveItem.Image"), System.Drawing.Image)
+Me.ProductCategoryBindingNavigatorSaveItem.Name = "ProductCategoryBindingNavigatorSaveItem"
+Me.ProductCategoryBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 23)
+Me.ProductCategoryBindingNavigatorSaveItem.Text = "Save Data"
+'
+'ProductCategoryIDLabel
+'
+ProductCategoryIDLabel.AutoSize = True
+ProductCategoryIDLabel.Location = New System.Drawing.Point(46, 47)
+ProductCategoryIDLabel.Name = "ProductCategoryIDLabel"
+ProductCategoryIDLabel.Size = New System.Drawing.Size(106, 13)
+ProductCategoryIDLabel.TabIndex = 1
+ProductCategoryIDLabel.Text = "Product Category ID:"
+'
+'ProductCategoryIDTextBox
+'
+Me.ProductCategoryIDTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.ProductCategoryBindingSource, "ProductCategoryID", True))
+Me.ProductCategoryIDTextBox.Location = New System.Drawing.Point(158, 44)
+Me.ProductCategoryIDTextBox.Name = "ProductCategoryIDTextBox"
+Me.ProductCategoryIDTextBox.Size = New System.Drawing.Size(100, 20)
+Me.ProductCategoryIDTextBox.TabIndex = 2
+'
+'NameLabel
+'
+NameLabel.AutoSize = True
+NameLabel.Location = New System.Drawing.Point(114, 73)
+NameLabel.Name = "NameLabel"
+NameLabel.Size = New System.Drawing.Size(38, 13)
+NameLabel.TabIndex = 3
+NameLabel.Text = "Name:"
+'
+'NameTextBox
+'
+Me.NameTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.ProductCategoryBindingSource, "Name", True))
+Me.NameTextBox.Location = New System.Drawing.Point(158, 70)
+Me.NameTextBox.Name = "NameTextBox"
+Me.NameTextBox.Size = New System.Drawing.Size(100, 20)
+Me.NameTextBox.TabIndex = 4
+'
+'Form3
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(292, 266)
+Me.Controls.Add(NameLabel)
+Me.Controls.Add(Me.NameTextBox)
+Me.Controls.Add(ProductCategoryIDLabel)
+Me.Controls.Add(Me.ProductCategoryIDTextBox)
+Me.Controls.Add(Me.ProductCategoryBindingNavigator)
+Me.Name = "Form3"
+Me.Text = "Form3"
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ProductCategoryBindingNavigator.ResumeLayout(False)
+Me.ProductCategoryBindingNavigator.PerformLayout()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents CatSubCatAdventureWorks_DataDataSet As WinChap13.CatSubCatAdventureWorks_DataDataSet
+ Friend WithEvents ProductCategoryBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents ProductCategoryTableAdapter As WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+ Friend WithEvents ProductCategoryBindingNavigator As System.Windows.Forms.BindingNavigator
+ Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents ProductCategoryBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents ProductCategoryIDTextBox As System.Windows.Forms.TextBox
+ Friend WithEvents NameTextBox As System.Windows.Forms.TextBox
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form3.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form3.resx
new file mode 100644
index 0000000..97c18cd
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form3.resx
@@ -0,0 +1,224 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 271, 17
+
+
+ 17, 54
+
+
+ 217, 54
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0
+ 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q
+ /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/
+ /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p
+ QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/
+ O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk
+ GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o
+ w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3
+ MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg
+ YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU
+ hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V
+ hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72
+ tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD
+ HEVvQ/IAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0
+ oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+
+ ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D
+ Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF
+ 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY
+ Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA
+ AElFTkSuQmCC
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy
+ ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v
+ kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP
+ Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ
+ FGCYkuTLEQAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0
+ oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/
+ ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D
+ W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg
+ gg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU
+ oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7
+ PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc
+ MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce
+ uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm
+ F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm
+ x8MAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L
+ k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz
+ V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3
+ yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W
+ YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y
+ C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C
+ 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp
+ HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs
+ NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy
+ Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv
+ f/R3bGg6a0rM640AAAAASUVORK5CYII=
+
+
+
+ False
+
+
+ False
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form3.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form3.vb
new file mode 100644
index 0000000..a66f680
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form3.vb
@@ -0,0 +1,15 @@
+Public Class Form3
+
+Private Sub ProductCategoryBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductCategoryBindingNavigatorSaveItem.Click
+Me.Validate()
+Me.ProductCategoryBindingSource.EndEdit()
+Me.ProductCategoryTableAdapter.Update(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+End Sub
+
+Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'CatSubCatAdventureWorks_DataDataSet.ProductCategory' table. You can move, or remove it, as needed.
+Me.ProductCategoryTableAdapter.Fill(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+End Sub
+End Class
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form4.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form4.Designer.vb
new file mode 100644
index 0000000..7033cde
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form4.Designer.vb
@@ -0,0 +1,236 @@
+ _
+Partial Class Form4
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form4))
+Me.CatSubCatAdventureWorks_DataDataSet = New WinChap13.CatSubCatAdventureWorks_DataDataSet
+Me.ProductCategoryBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.ProductCategoryTableAdapter = New WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+Me.ProductCategoryBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
+Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox
+Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel
+Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton
+Me.ProductCategoryBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton
+Me.ProductCategoryDataGridView = New System.Windows.Forms.DataGridView
+Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn2 = New System.Windows.Forms.DataGridViewTextBoxColumn
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.ProductCategoryBindingNavigator.SuspendLayout()
+CType(Me.ProductCategoryDataGridView, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.SuspendLayout()
+'
+'CatSubCatAdventureWorks_DataDataSet
+'
+Me.CatSubCatAdventureWorks_DataDataSet.DataSetName = "CatSubCatAdventureWorks_DataDataSet"
+Me.CatSubCatAdventureWorks_DataDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'ProductCategoryBindingSource
+'
+Me.ProductCategoryBindingSource.DataMember = "ProductCategory"
+Me.ProductCategoryBindingSource.DataSource = Me.CatSubCatAdventureWorks_DataDataSet
+'
+'ProductCategoryTableAdapter
+'
+Me.ProductCategoryTableAdapter.ClearBeforeFill = True
+'
+'ProductCategoryBindingNavigator
+'
+Me.ProductCategoryBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem
+Me.ProductCategoryBindingNavigator.BindingSource = Me.ProductCategoryBindingSource
+Me.ProductCategoryBindingNavigator.CountItem = Me.BindingNavigatorCountItem
+Me.ProductCategoryBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem
+Me.ProductCategoryBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.ProductCategoryBindingNavigatorSaveItem})
+Me.ProductCategoryBindingNavigator.Location = New System.Drawing.Point(0, 0)
+Me.ProductCategoryBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
+Me.ProductCategoryBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
+Me.ProductCategoryBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
+Me.ProductCategoryBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
+Me.ProductCategoryBindingNavigator.Name = "ProductCategoryBindingNavigator"
+Me.ProductCategoryBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
+Me.ProductCategoryBindingNavigator.Size = New System.Drawing.Size(374, 25)
+Me.ProductCategoryBindingNavigator.TabIndex = 0
+Me.ProductCategoryBindingNavigator.Text = "BindingNavigator1"
+'
+'BindingNavigatorMoveFirstItem
+'
+Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
+Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveFirstItem.Text = "Move first"
+'
+'BindingNavigatorMovePreviousItem
+'
+Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
+Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMovePreviousItem.Text = "Move previous"
+'
+'BindingNavigatorSeparator
+'
+Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorPositionItem
+'
+Me.BindingNavigatorPositionItem.AccessibleName = "Position"
+Me.BindingNavigatorPositionItem.AutoSize = False
+Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
+Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21)
+Me.BindingNavigatorPositionItem.Text = "0"
+Me.BindingNavigatorPositionItem.ToolTipText = "Current position"
+'
+'BindingNavigatorCountItem
+'
+Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
+Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 13)
+Me.BindingNavigatorCountItem.Text = "of {0}"
+Me.BindingNavigatorCountItem.ToolTipText = "Total number of items"
+'
+'BindingNavigatorSeparator1
+'
+Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorMoveNextItem
+'
+Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
+Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveNextItem.Text = "Move next"
+'
+'BindingNavigatorMoveLastItem
+'
+Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
+Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveLastItem.Text = "Move last"
+'
+'BindingNavigatorSeparator2
+'
+Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorAddNewItem
+'
+Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem"
+Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorAddNewItem.Text = "Add new"
+'
+'BindingNavigatorDeleteItem
+'
+Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem"
+Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorDeleteItem.Text = "Delete"
+'
+'ProductCategoryBindingNavigatorSaveItem
+'
+Me.ProductCategoryBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.ProductCategoryBindingNavigatorSaveItem.Image = CType(resources.GetObject("ProductCategoryBindingNavigatorSaveItem.Image"), System.Drawing.Image)
+Me.ProductCategoryBindingNavigatorSaveItem.Name = "ProductCategoryBindingNavigatorSaveItem"
+Me.ProductCategoryBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 23)
+Me.ProductCategoryBindingNavigatorSaveItem.Text = "Save Data"
+'
+'ProductCategoryDataGridView
+'
+Me.ProductCategoryDataGridView.AutoGenerateColumns = False
+Me.ProductCategoryDataGridView.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.DataGridViewTextBoxColumn1, Me.DataGridViewTextBoxColumn2})
+Me.ProductCategoryDataGridView.DataSource = Me.ProductCategoryBindingSource
+Me.ProductCategoryDataGridView.Location = New System.Drawing.Point(29, 52)
+Me.ProductCategoryDataGridView.Name = "ProductCategoryDataGridView"
+Me.ProductCategoryDataGridView.Size = New System.Drawing.Size(300, 220)
+Me.ProductCategoryDataGridView.TabIndex = 1
+'
+'DataGridViewTextBoxColumn1
+'
+Me.DataGridViewTextBoxColumn1.DataPropertyName = "ProductCategoryID"
+Me.DataGridViewTextBoxColumn1.HeaderText = "ProductCategoryID"
+Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1"
+Me.DataGridViewTextBoxColumn1.ReadOnly = True
+'
+'DataGridViewTextBoxColumn2
+'
+Me.DataGridViewTextBoxColumn2.DataPropertyName = "Name"
+Me.DataGridViewTextBoxColumn2.HeaderText = "Name"
+Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2"
+'
+'Form4
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(374, 312)
+Me.Controls.Add(Me.ProductCategoryDataGridView)
+Me.Controls.Add(Me.ProductCategoryBindingNavigator)
+Me.Name = "Form4"
+Me.Text = "Form4"
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ProductCategoryBindingNavigator.ResumeLayout(False)
+Me.ProductCategoryBindingNavigator.PerformLayout()
+CType(Me.ProductCategoryDataGridView, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents CatSubCatAdventureWorks_DataDataSet As WinChap13.CatSubCatAdventureWorks_DataDataSet
+ Friend WithEvents ProductCategoryBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents ProductCategoryTableAdapter As WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+ Friend WithEvents ProductCategoryBindingNavigator As System.Windows.Forms.BindingNavigator
+ Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents ProductCategoryBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents ProductCategoryDataGridView As System.Windows.Forms.DataGridView
+ Friend WithEvents DataGridViewTextBoxColumn1 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn2 As System.Windows.Forms.DataGridViewTextBoxColumn
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form4.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form4.resx
new file mode 100644
index 0000000..1fdec5b
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form4.resx
@@ -0,0 +1,218 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 271, 17
+
+
+ 17, 54
+
+
+ 217, 54
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0
+ 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q
+ /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/
+ /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p
+ QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/
+ O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk
+ GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o
+ w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3
+ MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg
+ YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU
+ hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V
+ hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72
+ tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD
+ HEVvQ/IAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0
+ oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+
+ ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D
+ Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF
+ 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY
+ Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA
+ AElFTkSuQmCC
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy
+ ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v
+ kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP
+ Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ
+ FGCYkuTLEQAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0
+ oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/
+ ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D
+ W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg
+ gg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU
+ oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7
+ PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc
+ MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce
+ uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm
+ F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm
+ x8MAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L
+ k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz
+ V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3
+ yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W
+ YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y
+ C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C
+ 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp
+ HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs
+ NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy
+ Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv
+ f/R3bGg6a0rM640AAAAASUVORK5CYII=
+
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form4.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form4.vb
new file mode 100644
index 0000000..0672587
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form4.vb
@@ -0,0 +1,15 @@
+Public Class Form4
+
+Private Sub ProductCategoryBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductCategoryBindingNavigatorSaveItem.Click
+Me.Validate()
+Me.ProductCategoryBindingSource.EndEdit()
+Me.ProductCategoryTableAdapter.Update(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+End Sub
+
+Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'CatSubCatAdventureWorks_DataDataSet.ProductCategory' table. You can move, or remove it, as needed.
+Me.ProductCategoryTableAdapter.Fill(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+End Sub
+End Class
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form5.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form5.Designer.vb
new file mode 100644
index 0000000..d56271e
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form5.Designer.vb
@@ -0,0 +1,258 @@
+ _
+Partial Class Form5
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form5))
+Me.PubsDataSet = New WinChap13.pubsDataSet
+Me.TitlesBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.TitlesTableAdapter = New WinChap13.pubsDataSetTableAdapters.titlesTableAdapter
+Me.TitlesBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
+Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox
+Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel
+Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton
+Me.TitlesBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton
+Me.TitlesDataGridView = New System.Windows.Forms.DataGridView
+Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn2 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn3 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn10 = New System.Windows.Forms.DataGridViewTextBoxColumn
+CType(Me.PubsDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.TitlesBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.TitlesBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.TitlesBindingNavigator.SuspendLayout()
+CType(Me.TitlesDataGridView, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.SuspendLayout()
+'
+'PubsDataSet
+'
+Me.PubsDataSet.DataSetName = "pubsDataSet"
+Me.PubsDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'TitlesBindingSource
+'
+Me.TitlesBindingSource.DataMember = "titles"
+Me.TitlesBindingSource.DataSource = Me.PubsDataSet
+'
+'TitlesTableAdapter
+'
+Me.TitlesTableAdapter.ClearBeforeFill = True
+'
+'TitlesBindingNavigator
+'
+Me.TitlesBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem
+Me.TitlesBindingNavigator.BindingSource = Me.TitlesBindingSource
+Me.TitlesBindingNavigator.CountItem = Me.BindingNavigatorCountItem
+Me.TitlesBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem
+Me.TitlesBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.TitlesBindingNavigatorSaveItem})
+Me.TitlesBindingNavigator.Location = New System.Drawing.Point(0, 0)
+Me.TitlesBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
+Me.TitlesBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
+Me.TitlesBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
+Me.TitlesBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
+Me.TitlesBindingNavigator.Name = "TitlesBindingNavigator"
+Me.TitlesBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
+Me.TitlesBindingNavigator.Size = New System.Drawing.Size(358, 25)
+Me.TitlesBindingNavigator.TabIndex = 0
+Me.TitlesBindingNavigator.Text = "BindingNavigator1"
+'
+'BindingNavigatorMoveFirstItem
+'
+Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
+Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveFirstItem.Text = "Move first"
+'
+'BindingNavigatorMovePreviousItem
+'
+Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
+Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMovePreviousItem.Text = "Move previous"
+'
+'BindingNavigatorSeparator
+'
+Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorPositionItem
+'
+Me.BindingNavigatorPositionItem.AccessibleName = "Position"
+Me.BindingNavigatorPositionItem.AutoSize = False
+Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
+Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21)
+Me.BindingNavigatorPositionItem.Text = "0"
+Me.BindingNavigatorPositionItem.ToolTipText = "Current position"
+'
+'BindingNavigatorCountItem
+'
+Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
+Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 13)
+Me.BindingNavigatorCountItem.Text = "of {0}"
+Me.BindingNavigatorCountItem.ToolTipText = "Total number of items"
+'
+'BindingNavigatorSeparator1
+'
+Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorMoveNextItem
+'
+Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
+Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveNextItem.Text = "Move next"
+'
+'BindingNavigatorMoveLastItem
+'
+Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
+Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveLastItem.Text = "Move last"
+'
+'BindingNavigatorSeparator2
+'
+Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorAddNewItem
+'
+Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem"
+Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorAddNewItem.Text = "Add new"
+'
+'BindingNavigatorDeleteItem
+'
+Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem"
+Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorDeleteItem.Text = "Delete"
+'
+'TitlesBindingNavigatorSaveItem
+'
+Me.TitlesBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.TitlesBindingNavigatorSaveItem.Image = CType(resources.GetObject("TitlesBindingNavigatorSaveItem.Image"), System.Drawing.Image)
+Me.TitlesBindingNavigatorSaveItem.Name = "TitlesBindingNavigatorSaveItem"
+Me.TitlesBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 23)
+Me.TitlesBindingNavigatorSaveItem.Text = "Save Data"
+'
+'TitlesDataGridView
+'
+Me.TitlesDataGridView.AllowUserToAddRows = False
+Me.TitlesDataGridView.AllowUserToDeleteRows = False
+Me.TitlesDataGridView.AutoGenerateColumns = False
+Me.TitlesDataGridView.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.DataGridViewTextBoxColumn1, Me.DataGridViewTextBoxColumn2, Me.DataGridViewTextBoxColumn3, Me.DataGridViewTextBoxColumn10})
+Me.TitlesDataGridView.DataSource = Me.TitlesBindingSource
+Me.TitlesDataGridView.Location = New System.Drawing.Point(31, 67)
+Me.TitlesDataGridView.Name = "TitlesDataGridView"
+Me.TitlesDataGridView.ReadOnly = True
+Me.TitlesDataGridView.Size = New System.Drawing.Size(300, 220)
+Me.TitlesDataGridView.TabIndex = 1
+'
+'DataGridViewTextBoxColumn1
+'
+Me.DataGridViewTextBoxColumn1.DataPropertyName = "title_id"
+Me.DataGridViewTextBoxColumn1.HeaderText = "title_id"
+Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1"
+Me.DataGridViewTextBoxColumn1.ReadOnly = True
+'
+'DataGridViewTextBoxColumn2
+'
+Me.DataGridViewTextBoxColumn2.DataPropertyName = "title"
+Me.DataGridViewTextBoxColumn2.HeaderText = "title"
+Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2"
+Me.DataGridViewTextBoxColumn2.ReadOnly = True
+'
+'DataGridViewTextBoxColumn3
+'
+Me.DataGridViewTextBoxColumn3.DataPropertyName = "type"
+Me.DataGridViewTextBoxColumn3.HeaderText = "type"
+Me.DataGridViewTextBoxColumn3.Name = "DataGridViewTextBoxColumn3"
+Me.DataGridViewTextBoxColumn3.ReadOnly = True
+'
+'DataGridViewTextBoxColumn10
+'
+Me.DataGridViewTextBoxColumn10.DataPropertyName = "pubdate"
+Me.DataGridViewTextBoxColumn10.HeaderText = "pubdate"
+Me.DataGridViewTextBoxColumn10.Name = "DataGridViewTextBoxColumn10"
+Me.DataGridViewTextBoxColumn10.ReadOnly = True
+'
+'Form5
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(358, 299)
+Me.Controls.Add(Me.TitlesDataGridView)
+Me.Controls.Add(Me.TitlesBindingNavigator)
+Me.Name = "Form5"
+Me.Text = "Form5"
+CType(Me.PubsDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.TitlesBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.TitlesBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
+Me.TitlesBindingNavigator.ResumeLayout(False)
+Me.TitlesBindingNavigator.PerformLayout()
+CType(Me.TitlesDataGridView, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents PubsDataSet As WinChap13.pubsDataSet
+ Friend WithEvents TitlesBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents TitlesTableAdapter As WinChap13.pubsDataSetTableAdapters.titlesTableAdapter
+ Friend WithEvents TitlesBindingNavigator As System.Windows.Forms.BindingNavigator
+ Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents TitlesBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents TitlesDataGridView As System.Windows.Forms.DataGridView
+ Friend WithEvents DataGridViewTextBoxColumn1 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn2 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn3 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn10 As System.Windows.Forms.DataGridViewTextBoxColumn
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form5.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form5.resx
new file mode 100644
index 0000000..abc71f9
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form5.resx
@@ -0,0 +1,218 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 131, 17
+
+
+ 280, 17
+
+
+ 424, 17
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0
+ 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q
+ /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/
+ /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p
+ QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/
+ O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk
+ GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o
+ w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3
+ MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg
+ YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU
+ hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V
+ hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72
+ tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD
+ HEVvQ/IAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0
+ oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+
+ ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D
+ Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF
+ 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY
+ Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA
+ AElFTkSuQmCC
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy
+ ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v
+ kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP
+ Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ
+ FGCYkuTLEQAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0
+ oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/
+ ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D
+ W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg
+ gg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU
+ oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7
+ PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc
+ MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce
+ uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm
+ F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm
+ x8MAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L
+ k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz
+ V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3
+ yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W
+ YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y
+ C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C
+ 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp
+ HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs
+ NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy
+ Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv
+ f/R3bGg6a0rM640AAAAASUVORK5CYII=
+
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form5.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form5.vb
new file mode 100644
index 0000000..f220546
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form5.vb
@@ -0,0 +1,15 @@
+Public Class Form5
+
+Private Sub TitlesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TitlesBindingNavigatorSaveItem.Click
+Me.Validate()
+Me.TitlesBindingSource.EndEdit()
+Me.TitlesTableAdapter.Update(Me.PubsDataSet.titles)
+
+End Sub
+
+Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'PubsDataSet.titles' table. You can move, or remove it, as needed.
+Me.TitlesTableAdapter.Fill(Me.PubsDataSet.titles)
+
+End Sub
+End Class
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form6.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form6.Designer.vb
new file mode 100644
index 0000000..4512075
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form6.Designer.vb
@@ -0,0 +1,226 @@
+ _
+Partial Class Form6
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form6))
+Me.PubsDataSet = New WinChap13.pubsDataSet
+Me.TitlesBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.TitlesTableAdapter = New WinChap13.pubsDataSetTableAdapters.titlesTableAdapter
+Me.TitlesBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
+Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox
+Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel
+Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator
+Me.TitlesDataGridView = New System.Windows.Forms.DataGridView
+Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn2 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn3 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn10 = New System.Windows.Forms.DataGridViewTextBoxColumn
+CType(Me.PubsDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.TitlesBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.TitlesBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.TitlesBindingNavigator.SuspendLayout()
+CType(Me.TitlesDataGridView, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.SuspendLayout()
+'
+'PubsDataSet
+'
+Me.PubsDataSet.DataSetName = "pubsDataSet"
+Me.PubsDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'TitlesBindingSource
+'
+Me.TitlesBindingSource.DataMember = "titles"
+Me.TitlesBindingSource.DataSource = Me.PubsDataSet
+'
+'TitlesTableAdapter
+'
+Me.TitlesTableAdapter.ClearBeforeFill = True
+'
+'TitlesBindingNavigator
+'
+Me.TitlesBindingNavigator.AddNewItem = Nothing
+Me.TitlesBindingNavigator.BindingSource = Me.TitlesBindingSource
+Me.TitlesBindingNavigator.CountItem = Me.BindingNavigatorCountItem
+Me.TitlesBindingNavigator.DeleteItem = Nothing
+Me.TitlesBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2})
+Me.TitlesBindingNavigator.Location = New System.Drawing.Point(0, 0)
+Me.TitlesBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
+Me.TitlesBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
+Me.TitlesBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
+Me.TitlesBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
+Me.TitlesBindingNavigator.Name = "TitlesBindingNavigator"
+Me.TitlesBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
+Me.TitlesBindingNavigator.Size = New System.Drawing.Size(370, 25)
+Me.TitlesBindingNavigator.TabIndex = 0
+Me.TitlesBindingNavigator.Text = "BindingNavigator1"
+'
+'BindingNavigatorMoveFirstItem
+'
+Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
+Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveFirstItem.Text = "Move first"
+'
+'BindingNavigatorMovePreviousItem
+'
+Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
+Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMovePreviousItem.Text = "Move previous"
+'
+'BindingNavigatorSeparator
+'
+Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorPositionItem
+'
+Me.BindingNavigatorPositionItem.AccessibleName = "Position"
+Me.BindingNavigatorPositionItem.AutoSize = False
+Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
+Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21)
+Me.BindingNavigatorPositionItem.Text = "0"
+Me.BindingNavigatorPositionItem.ToolTipText = "Current position"
+'
+'BindingNavigatorCountItem
+'
+Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
+Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 22)
+Me.BindingNavigatorCountItem.Text = "of {0}"
+Me.BindingNavigatorCountItem.ToolTipText = "Total number of items"
+'
+'BindingNavigatorSeparator1
+'
+Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorMoveNextItem
+'
+Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
+Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveNextItem.Text = "Move next"
+'
+'BindingNavigatorMoveLastItem
+'
+Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
+Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveLastItem.Text = "Move last"
+'
+'BindingNavigatorSeparator2
+'
+Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 25)
+'
+'TitlesDataGridView
+'
+Me.TitlesDataGridView.AllowUserToAddRows = False
+Me.TitlesDataGridView.AllowUserToDeleteRows = False
+Me.TitlesDataGridView.AutoGenerateColumns = False
+Me.TitlesDataGridView.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.DataGridViewTextBoxColumn1, Me.DataGridViewTextBoxColumn2, Me.DataGridViewTextBoxColumn3, Me.DataGridViewTextBoxColumn10})
+Me.TitlesDataGridView.DataSource = Me.TitlesBindingSource
+Me.TitlesDataGridView.Location = New System.Drawing.Point(39, 74)
+Me.TitlesDataGridView.Name = "TitlesDataGridView"
+Me.TitlesDataGridView.ReadOnly = True
+Me.TitlesDataGridView.Size = New System.Drawing.Size(300, 220)
+Me.TitlesDataGridView.TabIndex = 1
+'
+'DataGridViewTextBoxColumn1
+'
+Me.DataGridViewTextBoxColumn1.DataPropertyName = "title_id"
+Me.DataGridViewTextBoxColumn1.HeaderText = "title_id"
+Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1"
+Me.DataGridViewTextBoxColumn1.ReadOnly = True
+'
+'DataGridViewTextBoxColumn2
+'
+Me.DataGridViewTextBoxColumn2.DataPropertyName = "title"
+Me.DataGridViewTextBoxColumn2.HeaderText = "title"
+Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2"
+Me.DataGridViewTextBoxColumn2.ReadOnly = True
+'
+'DataGridViewTextBoxColumn3
+'
+Me.DataGridViewTextBoxColumn3.DataPropertyName = "type"
+Me.DataGridViewTextBoxColumn3.HeaderText = "type"
+Me.DataGridViewTextBoxColumn3.Name = "DataGridViewTextBoxColumn3"
+Me.DataGridViewTextBoxColumn3.ReadOnly = True
+'
+'DataGridViewTextBoxColumn10
+'
+Me.DataGridViewTextBoxColumn10.DataPropertyName = "pubdate"
+Me.DataGridViewTextBoxColumn10.HeaderText = "pubdate"
+Me.DataGridViewTextBoxColumn10.Name = "DataGridViewTextBoxColumn10"
+Me.DataGridViewTextBoxColumn10.ReadOnly = True
+'
+'Form6
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(370, 306)
+Me.Controls.Add(Me.TitlesDataGridView)
+Me.Controls.Add(Me.TitlesBindingNavigator)
+Me.Name = "Form6"
+Me.Text = "Form6"
+CType(Me.PubsDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.TitlesBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.TitlesBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
+Me.TitlesBindingNavigator.ResumeLayout(False)
+Me.TitlesBindingNavigator.PerformLayout()
+CType(Me.TitlesDataGridView, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents PubsDataSet As WinChap13.pubsDataSet
+ Friend WithEvents TitlesBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents TitlesTableAdapter As WinChap13.pubsDataSetTableAdapters.titlesTableAdapter
+ Friend WithEvents TitlesBindingNavigator As System.Windows.Forms.BindingNavigator
+ Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents TitlesDataGridView As System.Windows.Forms.DataGridView
+ Friend WithEvents DataGridViewTextBoxColumn1 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn2 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn3 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn10 As System.Windows.Forms.DataGridViewTextBoxColumn
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form6.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form6.resx
new file mode 100644
index 0000000..3d4927e
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form6.resx
@@ -0,0 +1,177 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 131, 17
+
+
+ 280, 17
+
+
+ 424, 17
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0
+ oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+
+ ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D
+ Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF
+ 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY
+ Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA
+ AElFTkSuQmCC
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy
+ ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v
+ kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP
+ Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ
+ FGCYkuTLEQAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0
+ oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/
+ ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D
+ W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg
+ gg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU
+ oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7
+ PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc
+ MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce
+ uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm
+ F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm
+ x8MAAAAASUVORK5CYII=
+
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form6.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form6.vb
new file mode 100644
index 0000000..0c88903
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form6.vb
@@ -0,0 +1,15 @@
+Public Class Form6
+
+Private Sub TitlesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
+Me.Validate()
+Me.TitlesBindingSource.EndEdit()
+Me.TitlesTableAdapter.Update(Me.PubsDataSet.titles)
+
+End Sub
+
+Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'PubsDataSet.titles' table. You can move, or remove it, as needed.
+Me.TitlesTableAdapter.Fill(Me.PubsDataSet.titles)
+
+End Sub
+End Class
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form7.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form7.Designer.vb
new file mode 100644
index 0000000..673b922
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form7.Designer.vb
@@ -0,0 +1,284 @@
+ _
+Partial Class Form7
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form7))
+Dim NameLabel As System.Windows.Forms.Label
+Me.CatSubCatAdventureWorks_DataDataSet = New WinChap13.CatSubCatAdventureWorks_DataDataSet
+Me.ProductCategoryBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.ProductCategoryTableAdapter = New WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+Me.ProductCategoryBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
+Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox
+Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel
+Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton
+Me.ProductCategoryBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton
+Me.NameListBox = New System.Windows.Forms.ListBox
+Me.ProductCategoryBindingSource1 = New System.Windows.Forms.BindingSource(Me.components)
+Me.Label2 = New System.Windows.Forms.Label
+Me.Label1 = New System.Windows.Forms.Label
+Me.TextBox2 = New System.Windows.Forms.TextBox
+Me.TextBox1 = New System.Windows.Forms.TextBox
+NameLabel = New System.Windows.Forms.Label
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.ProductCategoryBindingNavigator.SuspendLayout()
+CType(Me.ProductCategoryBindingSource1, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.SuspendLayout()
+'
+'CatSubCatAdventureWorks_DataDataSet
+'
+Me.CatSubCatAdventureWorks_DataDataSet.DataSetName = "CatSubCatAdventureWorks_DataDataSet"
+Me.CatSubCatAdventureWorks_DataDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'ProductCategoryBindingSource
+'
+Me.ProductCategoryBindingSource.DataMember = "ProductCategory"
+Me.ProductCategoryBindingSource.DataSource = Me.CatSubCatAdventureWorks_DataDataSet
+'
+'ProductCategoryTableAdapter
+'
+Me.ProductCategoryTableAdapter.ClearBeforeFill = True
+'
+'ProductCategoryBindingNavigator
+'
+Me.ProductCategoryBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem
+Me.ProductCategoryBindingNavigator.BindingSource = Me.ProductCategoryBindingSource
+Me.ProductCategoryBindingNavigator.CountItem = Me.BindingNavigatorCountItem
+Me.ProductCategoryBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem
+Me.ProductCategoryBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.ProductCategoryBindingNavigatorSaveItem})
+Me.ProductCategoryBindingNavigator.Location = New System.Drawing.Point(0, 0)
+Me.ProductCategoryBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
+Me.ProductCategoryBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
+Me.ProductCategoryBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
+Me.ProductCategoryBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
+Me.ProductCategoryBindingNavigator.Name = "ProductCategoryBindingNavigator"
+Me.ProductCategoryBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
+Me.ProductCategoryBindingNavigator.Size = New System.Drawing.Size(292, 25)
+Me.ProductCategoryBindingNavigator.TabIndex = 0
+Me.ProductCategoryBindingNavigator.Text = "BindingNavigator1"
+'
+'BindingNavigatorMoveFirstItem
+'
+Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
+Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveFirstItem.Text = "Move first"
+'
+'BindingNavigatorMovePreviousItem
+'
+Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
+Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMovePreviousItem.Text = "Move previous"
+'
+'BindingNavigatorSeparator
+'
+Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorPositionItem
+'
+Me.BindingNavigatorPositionItem.AccessibleName = "Position"
+Me.BindingNavigatorPositionItem.AutoSize = False
+Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
+Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21)
+Me.BindingNavigatorPositionItem.Text = "0"
+Me.BindingNavigatorPositionItem.ToolTipText = "Current position"
+'
+'BindingNavigatorCountItem
+'
+Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
+Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 13)
+Me.BindingNavigatorCountItem.Text = "of {0}"
+Me.BindingNavigatorCountItem.ToolTipText = "Total number of items"
+'
+'BindingNavigatorSeparator1
+'
+Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorMoveNextItem
+'
+Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
+Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveNextItem.Text = "Move next"
+'
+'BindingNavigatorMoveLastItem
+'
+Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
+Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorMoveLastItem.Text = "Move last"
+'
+'BindingNavigatorSeparator2
+'
+Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 6)
+'
+'BindingNavigatorAddNewItem
+'
+Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem"
+Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorAddNewItem.Text = "Add new"
+'
+'BindingNavigatorDeleteItem
+'
+Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem"
+Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 20)
+Me.BindingNavigatorDeleteItem.Text = "Delete"
+'
+'ProductCategoryBindingNavigatorSaveItem
+'
+Me.ProductCategoryBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.ProductCategoryBindingNavigatorSaveItem.Image = CType(resources.GetObject("ProductCategoryBindingNavigatorSaveItem.Image"), System.Drawing.Image)
+Me.ProductCategoryBindingNavigatorSaveItem.Name = "ProductCategoryBindingNavigatorSaveItem"
+Me.ProductCategoryBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 23)
+Me.ProductCategoryBindingNavigatorSaveItem.Text = "Save Data"
+'
+'NameLabel
+'
+NameLabel.AutoSize = True
+NameLabel.Location = New System.Drawing.Point(14, 46)
+NameLabel.Name = "NameLabel"
+NameLabel.Size = New System.Drawing.Size(38, 13)
+NameLabel.TabIndex = 1
+NameLabel.Text = "Name:"
+'
+'NameListBox
+'
+Me.NameListBox.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.ProductCategoryBindingSource, "Name", True))
+Me.NameListBox.DataSource = Me.ProductCategoryBindingSource1
+Me.NameListBox.DisplayMember = "Name"
+Me.NameListBox.FormattingEnabled = True
+Me.NameListBox.Location = New System.Drawing.Point(58, 46)
+Me.NameListBox.Name = "NameListBox"
+Me.NameListBox.Size = New System.Drawing.Size(120, 95)
+Me.NameListBox.TabIndex = 2
+Me.NameListBox.ValueMember = "ProductCategoryID"
+'
+'ProductCategoryBindingSource1
+'
+Me.ProductCategoryBindingSource1.DataMember = "ProductCategory"
+Me.ProductCategoryBindingSource1.DataSource = Me.CatSubCatAdventureWorks_DataDataSet
+'
+'Label2
+'
+Me.Label2.AutoSize = True
+Me.Label2.Location = New System.Drawing.Point(78, 207)
+Me.Label2.Name = "Label2"
+Me.Label2.Size = New System.Drawing.Size(39, 13)
+Me.Label2.TabIndex = 20
+Me.Label2.Text = "Label2"
+'
+'Label1
+'
+Me.Label1.AutoSize = True
+Me.Label1.Location = New System.Drawing.Point(78, 181)
+Me.Label1.Name = "Label1"
+Me.Label1.Size = New System.Drawing.Size(39, 13)
+Me.Label1.TabIndex = 19
+Me.Label1.Text = "Label1"
+'
+'TextBox2
+'
+Me.TextBox2.Location = New System.Drawing.Point(160, 200)
+Me.TextBox2.Name = "TextBox2"
+Me.TextBox2.Size = New System.Drawing.Size(100, 20)
+Me.TextBox2.TabIndex = 18
+'
+'TextBox1
+'
+Me.TextBox1.Location = New System.Drawing.Point(160, 174)
+Me.TextBox1.Name = "TextBox1"
+Me.TextBox1.Size = New System.Drawing.Size(100, 20)
+Me.TextBox1.TabIndex = 17
+'
+'Form7
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(292, 266)
+Me.Controls.Add(Me.Label2)
+Me.Controls.Add(Me.Label1)
+Me.Controls.Add(Me.TextBox2)
+Me.Controls.Add(Me.TextBox1)
+Me.Controls.Add(NameLabel)
+Me.Controls.Add(Me.NameListBox)
+Me.Controls.Add(Me.ProductCategoryBindingNavigator)
+Me.Name = "Form7"
+Me.Text = "Form7"
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ProductCategoryBindingNavigator.ResumeLayout(False)
+Me.ProductCategoryBindingNavigator.PerformLayout()
+CType(Me.ProductCategoryBindingSource1, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents CatSubCatAdventureWorks_DataDataSet As WinChap13.CatSubCatAdventureWorks_DataDataSet
+ Friend WithEvents ProductCategoryBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents ProductCategoryTableAdapter As WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+ Friend WithEvents ProductCategoryBindingNavigator As System.Windows.Forms.BindingNavigator
+ Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents ProductCategoryBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents NameListBox As System.Windows.Forms.ListBox
+ Friend WithEvents ProductCategoryBindingSource1 As System.Windows.Forms.BindingSource
+ Friend WithEvents Label2 As System.Windows.Forms.Label
+ Friend WithEvents Label1 As System.Windows.Forms.Label
+ Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
+ Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form7.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form7.resx
new file mode 100644
index 0000000..75d159e
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form7.resx
@@ -0,0 +1,227 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 271, 17
+
+
+ 476, 17
+
+
+ 17, 54
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0
+ 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q
+ /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/
+ /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p
+ QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/
+ O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk
+ GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o
+ w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3
+ MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg
+ YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU
+ hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V
+ hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72
+ tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD
+ HEVvQ/IAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0
+ oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+
+ ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D
+ Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF
+ 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY
+ Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA
+ AElFTkSuQmCC
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy
+ ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v
+ kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP
+ Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ
+ FGCYkuTLEQAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0
+ oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/
+ ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D
+ W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg
+ gg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU
+ oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7
+ PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc
+ MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce
+ uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm
+ F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm
+ x8MAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L
+ k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz
+ V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3
+ yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W
+ YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y
+ C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C
+ 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp
+ HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs
+ NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy
+ Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv
+ f/R3bGg6a0rM640AAAAASUVORK5CYII=
+
+
+
+ False
+
+
+ 236, 54
+
+
+ 236, 54
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form7.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form7.vb
new file mode 100644
index 0000000..82316f7
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form7.vb
@@ -0,0 +1,45 @@
+Public Class Form7
+ Dim bolClosed As Boolean
+
+ Private Sub Form7_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
+ bolClosed = True
+ End Sub
+
+Private Sub ProductCategoryBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductCategoryBindingNavigatorSaveItem.Click
+Me.Validate()
+Me.ProductCategoryBindingSource.EndEdit()
+Me.ProductCategoryTableAdapter.Update(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+End Sub
+
+Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'CatSubCatAdventureWorks_DataDataSet.ProductCategory' table. You can move, or remove it, as needed.
+Me.ProductCategoryTableAdapter.Fill(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+
+ UpdateTextBoxes()
+
+ Me.Label1.Text = "SelectedValue:"
+ Me.Label2.Text = "SelectedIndex:"
+ Me.ProductCategoryBindingNavigator.Visible = False
+
+End Sub
+
+ Sub UpdateTextBoxes()
+ Try
+ Me.TextBox1.Text = Me.NameListBox.SelectedValue.ToString
+ Me.TextBox2.Text = Me.NameListBox.SelectedIndex.ToString
+ Catch ex As Exception
+ If bolClosed = False Then
+ MessageBox.Show(ex.Message)
+ Else
+ 'Test diagnostic output; do not run normally
+ 'MessageBox.Show(ex.Message)
+ End If
+ End Try
+ End Sub
+
+ Private Sub NameListBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NameListBox.SelectedIndexChanged
+ UpdateTextBoxes()
+ End Sub
+End Class
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form8.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form8.Designer.vb
new file mode 100644
index 0000000..6a66ba0
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form8.Designer.vb
@@ -0,0 +1,299 @@
+ _
+Partial Class Form8
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form8))
+Me.ProductSubcategoryBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
+Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox
+Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel
+Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator
+Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton
+Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton
+Me.ProductSubcategoryBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton
+Me.ProductSubcategoryDataGridView = New System.Windows.Forms.DataGridView
+Me.FillByCatID1ToolStrip = New System.Windows.Forms.ToolStrip
+Me.CatIDToolStripLabel = New System.Windows.Forms.ToolStripLabel
+Me.CatIDToolStripTextBox = New System.Windows.Forms.ToolStripTextBox
+Me.FillByCatID1ToolStripButton = New System.Windows.Forms.ToolStripButton
+Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn2 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn3 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn4 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.DataGridViewTextBoxColumn5 = New System.Windows.Forms.DataGridViewTextBoxColumn
+Me.ProductSubcategoryBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.CatSubCatAdventureWorks_DataDataSet = New WinChap13.CatSubCatAdventureWorks_DataDataSet
+Me.ProductSubcategoryTableAdapter = New WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductSubcategoryTableAdapter
+CType(Me.ProductSubcategoryBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.ProductSubcategoryBindingNavigator.SuspendLayout()
+CType(Me.ProductSubcategoryDataGridView, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.FillByCatID1ToolStrip.SuspendLayout()
+CType(Me.ProductSubcategoryBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.SuspendLayout()
+'
+'ProductSubcategoryBindingNavigator
+'
+Me.ProductSubcategoryBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem
+Me.ProductSubcategoryBindingNavigator.BindingSource = Me.ProductSubcategoryBindingSource
+Me.ProductSubcategoryBindingNavigator.CountItem = Me.BindingNavigatorCountItem
+Me.ProductSubcategoryBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem
+Me.ProductSubcategoryBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.ProductSubcategoryBindingNavigatorSaveItem})
+Me.ProductSubcategoryBindingNavigator.Location = New System.Drawing.Point(0, 0)
+Me.ProductSubcategoryBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
+Me.ProductSubcategoryBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
+Me.ProductSubcategoryBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
+Me.ProductSubcategoryBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
+Me.ProductSubcategoryBindingNavigator.Name = "ProductSubcategoryBindingNavigator"
+Me.ProductSubcategoryBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
+Me.ProductSubcategoryBindingNavigator.Size = New System.Drawing.Size(367, 25)
+Me.ProductSubcategoryBindingNavigator.TabIndex = 0
+Me.ProductSubcategoryBindingNavigator.Text = "BindingNavigator1"
+'
+'BindingNavigatorMoveFirstItem
+'
+Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
+Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveFirstItem.Text = "Move first"
+'
+'BindingNavigatorMovePreviousItem
+'
+Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
+Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMovePreviousItem.Text = "Move previous"
+'
+'BindingNavigatorSeparator
+'
+Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorPositionItem
+'
+Me.BindingNavigatorPositionItem.AccessibleName = "Position"
+Me.BindingNavigatorPositionItem.AutoSize = False
+Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
+Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21)
+Me.BindingNavigatorPositionItem.Text = "0"
+Me.BindingNavigatorPositionItem.ToolTipText = "Current position"
+'
+'BindingNavigatorCountItem
+'
+Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
+Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 22)
+Me.BindingNavigatorCountItem.Text = "of {0}"
+Me.BindingNavigatorCountItem.ToolTipText = "Total number of items"
+'
+'BindingNavigatorSeparator1
+'
+Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorMoveNextItem
+'
+Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
+Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveNextItem.Text = "Move next"
+'
+'BindingNavigatorMoveLastItem
+'
+Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
+Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorMoveLastItem.Text = "Move last"
+'
+'BindingNavigatorSeparator2
+'
+Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator"
+Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 25)
+'
+'BindingNavigatorAddNewItem
+'
+Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem"
+Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorAddNewItem.Text = "Add new"
+'
+'BindingNavigatorDeleteItem
+'
+Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image)
+Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem"
+Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True
+Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 22)
+Me.BindingNavigatorDeleteItem.Text = "Delete"
+'
+'ProductSubcategoryBindingNavigatorSaveItem
+'
+Me.ProductSubcategoryBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
+Me.ProductSubcategoryBindingNavigatorSaveItem.Image = CType(resources.GetObject("ProductSubcategoryBindingNavigatorSaveItem.Image"), System.Drawing.Image)
+Me.ProductSubcategoryBindingNavigatorSaveItem.Name = "ProductSubcategoryBindingNavigatorSaveItem"
+Me.ProductSubcategoryBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 22)
+Me.ProductSubcategoryBindingNavigatorSaveItem.Text = "Save Data"
+'
+'ProductSubcategoryDataGridView
+'
+Me.ProductSubcategoryDataGridView.AutoGenerateColumns = False
+Me.ProductSubcategoryDataGridView.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.DataGridViewTextBoxColumn1, Me.DataGridViewTextBoxColumn2, Me.DataGridViewTextBoxColumn3, Me.DataGridViewTextBoxColumn4, Me.DataGridViewTextBoxColumn5})
+Me.ProductSubcategoryDataGridView.DataSource = Me.ProductSubcategoryBindingSource
+Me.ProductSubcategoryDataGridView.Location = New System.Drawing.Point(12, 79)
+Me.ProductSubcategoryDataGridView.Name = "ProductSubcategoryDataGridView"
+Me.ProductSubcategoryDataGridView.Size = New System.Drawing.Size(300, 220)
+Me.ProductSubcategoryDataGridView.TabIndex = 1
+'
+'FillByCatID1ToolStrip
+'
+Me.FillByCatID1ToolStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.CatIDToolStripLabel, Me.CatIDToolStripTextBox, Me.FillByCatID1ToolStripButton})
+Me.FillByCatID1ToolStrip.Location = New System.Drawing.Point(0, 25)
+Me.FillByCatID1ToolStrip.Name = "FillByCatID1ToolStrip"
+Me.FillByCatID1ToolStrip.Size = New System.Drawing.Size(367, 25)
+Me.FillByCatID1ToolStrip.TabIndex = 2
+Me.FillByCatID1ToolStrip.Text = "FillByCatID1ToolStrip"
+'
+'CatIDToolStripLabel
+'
+Me.CatIDToolStripLabel.Name = "CatIDToolStripLabel"
+Me.CatIDToolStripLabel.Size = New System.Drawing.Size(39, 22)
+Me.CatIDToolStripLabel.Text = "CatID:"
+'
+'CatIDToolStripTextBox
+'
+Me.CatIDToolStripTextBox.Name = "CatIDToolStripTextBox"
+Me.CatIDToolStripTextBox.Size = New System.Drawing.Size(100, 25)
+'
+'FillByCatID1ToolStripButton
+'
+Me.FillByCatID1ToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
+Me.FillByCatID1ToolStripButton.Name = "FillByCatID1ToolStripButton"
+Me.FillByCatID1ToolStripButton.Size = New System.Drawing.Size(69, 22)
+Me.FillByCatID1ToolStripButton.Text = "FillByCatID1"
+'
+'DataGridViewTextBoxColumn1
+'
+Me.DataGridViewTextBoxColumn1.DataPropertyName = "ProductSubcategoryID"
+Me.DataGridViewTextBoxColumn1.HeaderText = "ProductSubcategoryID"
+Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1"
+Me.DataGridViewTextBoxColumn1.ReadOnly = True
+'
+'DataGridViewTextBoxColumn2
+'
+Me.DataGridViewTextBoxColumn2.DataPropertyName = "ProductCategoryID"
+Me.DataGridViewTextBoxColumn2.HeaderText = "ProductCategoryID"
+Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2"
+'
+'DataGridViewTextBoxColumn3
+'
+Me.DataGridViewTextBoxColumn3.DataPropertyName = "Name"
+Me.DataGridViewTextBoxColumn3.HeaderText = "Name"
+Me.DataGridViewTextBoxColumn3.Name = "DataGridViewTextBoxColumn3"
+'
+'DataGridViewTextBoxColumn4
+'
+Me.DataGridViewTextBoxColumn4.DataPropertyName = "rowguid"
+Me.DataGridViewTextBoxColumn4.HeaderText = "rowguid"
+Me.DataGridViewTextBoxColumn4.Name = "DataGridViewTextBoxColumn4"
+'
+'DataGridViewTextBoxColumn5
+'
+Me.DataGridViewTextBoxColumn5.DataPropertyName = "ModifiedDate"
+Me.DataGridViewTextBoxColumn5.HeaderText = "ModifiedDate"
+Me.DataGridViewTextBoxColumn5.Name = "DataGridViewTextBoxColumn5"
+'
+'ProductSubcategoryBindingSource
+'
+Me.ProductSubcategoryBindingSource.DataMember = "ProductSubcategory"
+Me.ProductSubcategoryBindingSource.DataSource = Me.CatSubCatAdventureWorks_DataDataSet
+'
+'CatSubCatAdventureWorks_DataDataSet
+'
+Me.CatSubCatAdventureWorks_DataDataSet.DataSetName = "CatSubCatAdventureWorks_DataDataSet"
+Me.CatSubCatAdventureWorks_DataDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'ProductSubcategoryTableAdapter
+'
+Me.ProductSubcategoryTableAdapter.ClearBeforeFill = True
+'
+'Form8
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(367, 320)
+Me.Controls.Add(Me.FillByCatID1ToolStrip)
+Me.Controls.Add(Me.ProductSubcategoryDataGridView)
+Me.Controls.Add(Me.ProductSubcategoryBindingNavigator)
+Me.Name = "Form8"
+Me.Text = "Form8"
+CType(Me.ProductSubcategoryBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ProductSubcategoryBindingNavigator.ResumeLayout(False)
+Me.ProductSubcategoryBindingNavigator.PerformLayout()
+CType(Me.ProductSubcategoryDataGridView, System.ComponentModel.ISupportInitialize).EndInit()
+Me.FillByCatID1ToolStrip.ResumeLayout(False)
+Me.FillByCatID1ToolStrip.PerformLayout()
+CType(Me.ProductSubcategoryBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents CatSubCatAdventureWorks_DataDataSet As WinChap13.CatSubCatAdventureWorks_DataDataSet
+ Friend WithEvents ProductSubcategoryBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents ProductSubcategoryTableAdapter As WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductSubcategoryTableAdapter
+ Friend WithEvents ProductSubcategoryBindingNavigator As System.Windows.Forms.BindingNavigator
+ Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
+ Friend WithEvents ProductSubcategoryBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton
+ Friend WithEvents ProductSubcategoryDataGridView As System.Windows.Forms.DataGridView
+ Friend WithEvents DataGridViewTextBoxColumn1 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn2 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn3 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn4 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents DataGridViewTextBoxColumn5 As System.Windows.Forms.DataGridViewTextBoxColumn
+ Friend WithEvents FillByCatID1ToolStrip As System.Windows.Forms.ToolStrip
+ Friend WithEvents CatIDToolStripLabel As System.Windows.Forms.ToolStripLabel
+ Friend WithEvents CatIDToolStripTextBox As System.Windows.Forms.ToolStripTextBox
+ Friend WithEvents FillByCatID1ToolStripButton As System.Windows.Forms.ToolStripButton
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form8.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form8.resx
new file mode 100644
index 0000000..7a690e0
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form8.resx
@@ -0,0 +1,221 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 54
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0
+ 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q
+ /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/
+ /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p
+ QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/
+ O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk
+ GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg==
+
+
+
+ 271, 17
+
+
+ 17, 17
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o
+ w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3
+ MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg
+ YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU
+ hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V
+ hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72
+ tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD
+ HEVvQ/IAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0
+ oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+
+ ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D
+ Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF
+ 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY
+ Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA
+ AElFTkSuQmCC
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy
+ ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v
+ kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP
+ Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ
+ FGCYkuTLEQAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0
+ oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/
+ ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D
+ W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg
+ gg==
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU
+ oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7
+ PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc
+ MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce
+ uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm
+ F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm
+ x8MAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L
+ k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz
+ V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3
+ yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W
+ YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y
+ C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C
+ 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp
+ HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs
+ NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy
+ Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv
+ f/R3bGg6a0rM640AAAAASUVORK5CYII=
+
+
+
+ 253, 54
+
+
+ 493, 17
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form8.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form8.vb
new file mode 100644
index 0000000..70292e2
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form8.vb
@@ -0,0 +1,26 @@
+Public Class Form8
+
+Private Sub ProductSubcategoryBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductSubcategoryBindingNavigatorSaveItem.Click
+Me.Validate()
+Me.ProductSubcategoryBindingSource.EndEdit()
+Me.ProductSubcategoryTableAdapter.Update(Me.CatSubCatAdventureWorks_DataDataSet.ProductSubcategory)
+
+End Sub
+
+Private Sub Form8_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'CatSubCatAdventureWorks_DataDataSet.ProductSubcategory' table. You can move, or remove it, as needed.
+Me.ProductSubcategoryTableAdapter.Fill(Me.CatSubCatAdventureWorks_DataDataSet.ProductSubcategory)
+
+ Me.ProductSubcategoryDataGridView. _
+ Columns("ProductSubcategoryID").MinimumWidth = 115
+End Sub
+
+Private Sub FillByCatID1ToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillByCatID1ToolStripButton.Click
+Try
+ Me.ProductSubcategoryTableAdapter.FillByCatID1(Me.CatSubCatAdventureWorks_DataDataSet.ProductSubcategory, CType(CatIDToolStripTextBox.Text, Integer))
+Catch ex As System.Exception
+ System.Windows.Forms.MessageBox.Show(ex.Message)
+End Try
+
+End Sub
+End Class
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form9.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form9.Designer.vb
new file mode 100644
index 0000000..aa896eb
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form9.Designer.vb
@@ -0,0 +1,138 @@
+ _
+Partial Class Form9
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+Me.components = New System.ComponentModel.Container
+Me.Label1 = New System.Windows.Forms.Label
+Me.ListBox1 = New System.Windows.Forms.ListBox
+Me.ListBox2 = New System.Windows.Forms.ListBox
+Me.Label2 = New System.Windows.Forms.Label
+Me.Button1 = New System.Windows.Forms.Button
+Me.CatSubCatAdventureWorks_DataDataSet = New WinChap13.CatSubCatAdventureWorks_DataDataSet
+Me.ProductCategoryBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.ProductCategoryTableAdapter = New WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+Me.ProductSubcategoryBindingSource = New System.Windows.Forms.BindingSource(Me.components)
+Me.ProductSubcategoryTableAdapter = New WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductSubcategoryTableAdapter
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+CType(Me.ProductSubcategoryBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
+Me.SuspendLayout()
+'
+'Label1
+'
+Me.Label1.AutoSize = True
+Me.Label1.Location = New System.Drawing.Point(13, 41)
+Me.Label1.Name = "Label1"
+Me.Label1.Size = New System.Drawing.Size(39, 13)
+Me.Label1.TabIndex = 0
+Me.Label1.Text = "Label1"
+'
+'ListBox1
+'
+Me.ListBox1.DataSource = Me.ProductCategoryBindingSource
+Me.ListBox1.DisplayMember = "Name"
+Me.ListBox1.FormattingEnabled = True
+Me.ListBox1.Location = New System.Drawing.Point(13, 58)
+Me.ListBox1.Name = "ListBox1"
+Me.ListBox1.Size = New System.Drawing.Size(120, 95)
+Me.ListBox1.TabIndex = 1
+Me.ListBox1.ValueMember = "ProductCategoryID"
+'
+'ListBox2
+'
+Me.ListBox2.DataSource = Me.ProductSubcategoryBindingSource
+Me.ListBox2.DisplayMember = "Name"
+Me.ListBox2.FormattingEnabled = True
+Me.ListBox2.Location = New System.Drawing.Point(160, 58)
+Me.ListBox2.Name = "ListBox2"
+Me.ListBox2.Size = New System.Drawing.Size(120, 199)
+Me.ListBox2.TabIndex = 2
+'
+'Label2
+'
+Me.Label2.AutoSize = True
+Me.Label2.Location = New System.Drawing.Point(160, 40)
+Me.Label2.Name = "Label2"
+Me.Label2.Size = New System.Drawing.Size(39, 13)
+Me.Label2.TabIndex = 3
+Me.Label2.Text = "Label2"
+'
+'Button1
+'
+Me.Button1.Location = New System.Drawing.Point(163, 12)
+Me.Button1.Name = "Button1"
+Me.Button1.Size = New System.Drawing.Size(75, 23)
+Me.Button1.TabIndex = 4
+Me.Button1.Text = "Button1"
+Me.Button1.UseVisualStyleBackColor = True
+'
+'CatSubCatAdventureWorks_DataDataSet
+'
+Me.CatSubCatAdventureWorks_DataDataSet.DataSetName = "CatSubCatAdventureWorks_DataDataSet"
+Me.CatSubCatAdventureWorks_DataDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+'
+'ProductCategoryBindingSource
+'
+Me.ProductCategoryBindingSource.DataMember = "ProductCategory"
+Me.ProductCategoryBindingSource.DataSource = Me.CatSubCatAdventureWorks_DataDataSet
+'
+'ProductCategoryTableAdapter
+'
+Me.ProductCategoryTableAdapter.ClearBeforeFill = True
+'
+'ProductSubcategoryBindingSource
+'
+Me.ProductSubcategoryBindingSource.DataMember = "ProductSubcategory"
+Me.ProductSubcategoryBindingSource.DataSource = Me.CatSubCatAdventureWorks_DataDataSet
+'
+'ProductSubcategoryTableAdapter
+'
+Me.ProductSubcategoryTableAdapter.ClearBeforeFill = True
+'
+'Form9
+'
+Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+Me.ClientSize = New System.Drawing.Size(292, 266)
+Me.Controls.Add(Me.Button1)
+Me.Controls.Add(Me.Label2)
+Me.Controls.Add(Me.ListBox2)
+Me.Controls.Add(Me.ListBox1)
+Me.Controls.Add(Me.Label1)
+Me.Name = "Form9"
+Me.Text = "Form9"
+CType(Me.CatSubCatAdventureWorks_DataDataSet, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductCategoryBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+CType(Me.ProductSubcategoryBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
+Me.ResumeLayout(False)
+Me.PerformLayout()
+
+End Sub
+ Friend WithEvents Label1 As System.Windows.Forms.Label
+ Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
+ Friend WithEvents ListBox2 As System.Windows.Forms.ListBox
+ Friend WithEvents Label2 As System.Windows.Forms.Label
+ Friend WithEvents Button1 As System.Windows.Forms.Button
+ Friend WithEvents CatSubCatAdventureWorks_DataDataSet As WinChap13.CatSubCatAdventureWorks_DataDataSet
+ Friend WithEvents ProductCategoryBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents ProductCategoryTableAdapter As WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductCategoryTableAdapter
+ Friend WithEvents ProductSubcategoryBindingSource As System.Windows.Forms.BindingSource
+ Friend WithEvents ProductSubcategoryTableAdapter As WinChap13.CatSubCatAdventureWorks_DataDataSetTableAdapters.ProductSubcategoryTableAdapter
+End Class
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form9.resx b/WinCh13/Chapter13/WinChap13/WinChap13/Form9.resx
new file mode 100644
index 0000000..a61a619
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form9.resx
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 271, 17
+
+
+ 17, 54
+
+
+ 17, 17
+
+
+ 476, 17
+
+
+ 17, 54
+
+
+ 239, 54
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/Form9.vb b/WinCh13/Chapter13/WinChap13/WinChap13/Form9.vb
new file mode 100644
index 0000000..41d7ed3
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/Form9.vb
@@ -0,0 +1,40 @@
+Public Class Form9
+
+Private Sub Form9_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
+'TODO: This line of code loads data into the 'CatSubCatAdventureWorks_DataDataSet.ProductSubcategory' table. You can move, or remove it, as needed.
+Me.ProductSubcategoryTableAdapter.Fill(Me.CatSubCatAdventureWorks_DataDataSet.ProductSubcategory)
+'TODO: This line of code loads data into the 'CatSubCatAdventureWorks_DataDataSet.ProductCategory' table. You can move, or remove it, as needed.
+Me.ProductCategoryTableAdapter.Fill(Me.CatSubCatAdventureWorks_DataDataSet.ProductCategory)
+
+ UpdateListBox2()
+
+ Me.Label1.Text = "Pick a category"
+ Me.Label2.Text = "To show its products"
+ Me.Button1.Text = "Show all products"
+ Me.Button1.Width = Me.ListBox2.Width
+ Me.Button1.Left = Me.ListBox2.Left
+ Me.Button1.BackColor = Color.Transparent
+
+End Sub
+
+Sub UpdateListBox2()
+
+ Me.ProductSubcategoryTableAdapter.FillByCatID1( _
+ Me.CatSubCatAdventureWorks_DataDataSet.ProductSubcategory, _
+ CInt(Me.ListBox1.SelectedValue))
+
+ 'Shows System.Convert.ToInt32 syntax to replace CInt syntax
+ 'Me.ProductSubcategoryTableAdapter.FillByCatID1( _
+ 'Me.CatSubCatAdventureWorks_DataDataSet.ProductSubcategory,
+ 'System.Convert.ToInt32(Me.ListBox1.SelectedValue))
+End Sub
+
+Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
+ Me.ProductSubcategoryTableAdapter.Fill( _
+ Me.CatSubCatAdventureWorks_DataDataSet.ProductSubcategory)
+End Sub
+
+Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
+ UpdateListBox2()
+End Sub
+End Class
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Application.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Application.Designer.vb
new file mode 100644
index 0000000..7b12182
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Application.Designer.vb
@@ -0,0 +1,38 @@
+'------------------------------------------------------------------------------
+'
+' This code was generated by a tool.
+' Runtime Version:2.0.50727.42
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+'
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+
+Namespace My
+
+ 'NOTE: This file is auto-generated; do not modify it directly. To make changes,
+ ' or if you encounter build errors in this file, go to the Project Designer
+ ' (go to Project Properties or double-click the My Project node in
+ ' Solution Explorer), and make changes on the Application tab.
+ '
+ Partial Friend Class MyApplication
+
+ _
+ Public Sub New()
+ MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
+ Me.IsSingleInstance = false
+ Me.EnableVisualStyles = true
+ Me.SaveMySettingsOnExit = true
+ Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
+ End Sub
+
+ _
+ Protected Overrides Sub OnCreateMainForm()
+ Me.MainForm = Global.WinChap13.Form1
+ End Sub
+ End Class
+End Namespace
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Application.myapp b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Application.myapp
new file mode 100644
index 0000000..0f12f32
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Application.myapp
@@ -0,0 +1,10 @@
+
+
+ true
+ Form1
+ false
+ 0
+ true
+ 0
+ true
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/My Project/AssemblyInfo.vb b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/AssemblyInfo.vb
new file mode 100644
index 0000000..d9aba67
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/AssemblyInfo.vb
@@ -0,0 +1,35 @@
+Imports System
+Imports System.Reflection
+Imports System.Runtime.InteropServices
+
+' General Information about an assembly is controlled through the following
+' set of attributes. Change these attribute values to modify the information
+' associated with an assembly.
+
+' Review the values of the assembly attributes
+
+
+
+
+
+
+
+
+
+
+'The following GUID is for the ID of the typelib if this project is exposed to COM
+
+
+' Version information for an assembly consists of the following four values:
+'
+' Major Version
+' Minor Version
+' Build Number
+' Revision
+'
+' You can specify all the values or you can default the Build and Revision Numbers
+' by using the '*' as shown below:
+'
+
+
+
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Resources.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Resources.Designer.vb
new file mode 100644
index 0000000..23fea4f
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Resources.Designer.vb
@@ -0,0 +1,63 @@
+'------------------------------------------------------------------------------
+'
+' This code was generated by a tool.
+' Runtime Version:2.0.50727.42
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+'
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+Imports System
+
+Namespace My.Resources
+
+ 'This class was auto-generated by the StronglyTypedResourceBuilder
+ 'class via a tool like ResGen or Visual Studio.
+ 'To add or remove a member, edit your .ResX file then rerun ResGen
+ 'with the /str option, or rebuild your VS project.
+ '''
+ ''' A strongly-typed resource class, for looking up localized strings, etc.
+ '''
+ _
+ Friend Module Resources
+
+ Private resourceMan As Global.System.Resources.ResourceManager
+
+ Private resourceCulture As Global.System.Globalization.CultureInfo
+
+ '''
+ ''' Returns the cached ResourceManager instance used by this class.
+ '''
+ _
+ Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
+ Get
+ If Object.ReferenceEquals(resourceMan, Nothing) Then
+ Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("WinChap13.Resources", GetType(Resources).Assembly)
+ resourceMan = temp
+ End If
+ Return resourceMan
+ End Get
+ End Property
+
+ '''
+ ''' Overrides the current thread's CurrentUICulture property for all
+ ''' resource lookups using this strongly typed resource class.
+ '''
+ _
+ Friend Property Culture() As Global.System.Globalization.CultureInfo
+ Get
+ Return resourceCulture
+ End Get
+ Set
+ resourceCulture = value
+ End Set
+ End Property
+ End Module
+End Namespace
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Resources.resx b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Settings.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Settings.Designer.vb
new file mode 100644
index 0000000..acc4703
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Settings.Designer.vb
@@ -0,0 +1,107 @@
+'------------------------------------------------------------------------------
+'
+' This code was generated by a tool.
+' Runtime Version:2.0.50727.42
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+'
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+
+Namespace My
+
+ _
+ Partial Friend NotInheritable Class MySettings
+ Inherits Global.System.Configuration.ApplicationSettingsBase
+
+ Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings)
+
+#Region "My.Settings Auto-Save Functionality"
+#If _MyType = "WindowsForms" Then
+ Private Shared addedHandler As Boolean
+
+ Private Shared addedHandlerLockObject As New Object
+
+ _
+ Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
+ If My.Application.SaveMySettingsOnExit Then
+ My.Settings.Save()
+ End If
+ End Sub
+#End If
+#End Region
+
+ Public Shared ReadOnly Property [Default]() As MySettings
+ Get
+
+#If _MyType = "WindowsForms" Then
+ If Not addedHandler Then
+ SyncLock addedHandlerLockObject
+ If Not addedHandler Then
+ AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
+ addedHandler = True
+ End If
+ End SyncLock
+ End If
+#End If
+ Return defaultInstance
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property AdventureWorks_DataConnectionString() As String
+ Get
+ Return CType(Me("AdventureWorks_DataConnectionString"),String)
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property pubsConnectionString() As String
+ Get
+ Return CType(Me("pubsConnectionString"),String)
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property NorthwindConnectionString() As String
+ Get
+ Return CType(Me("NorthwindConnectionString"),String)
+ End Get
+ End Property
+ End Class
+End Namespace
+
+Namespace My
+
+ _
+ Friend Module MySettingsProperty
+
+ _
+ Friend ReadOnly Property Settings() As Global.WinChap13.My.MySettings
+ Get
+ Return Global.WinChap13.My.MySettings.Default
+ End Get
+ End Property
+ End Module
+End Namespace
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Settings.settings b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Settings.settings
new file mode 100644
index 0000000..2808772
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/My Project/Settings.settings
@@ -0,0 +1,30 @@
+
+
+
+
+
+ <?xml version="1.0" encoding="utf-16"?>
+<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <ConnectionString>Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True</ConnectionString>
+ <ProviderName>System.Data.SqlClient</ProviderName>
+</SerializableConnectionString>
+ Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True
+
+
+ <?xml version="1.0" encoding="utf-16"?>
+<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <ConnectionString>Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\pubs.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True</ConnectionString>
+ <ProviderName>System.Data.SqlClient</ProviderName>
+</SerializableConnectionString>
+ Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\pubs.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True
+
+
+ <?xml version="1.0" encoding="utf-16"?>
+<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <ConnectionString>Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb"</ConnectionString>
+ <ProviderName>System.Data.OleDb</ProviderName>
+</SerializableConnectionString>
+ Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb"
+
+
+
\ No newline at end of file
diff --git a/WinCh13/Chapter13/WinChap13/WinChap13/NorthwindDataSet.Designer.vb b/WinCh13/Chapter13/WinChap13/WinChap13/NorthwindDataSet.Designer.vb
new file mode 100644
index 0000000..3125479
--- /dev/null
+++ b/WinCh13/Chapter13/WinChap13/WinChap13/NorthwindDataSet.Designer.vb
@@ -0,0 +1,1449 @@
+'------------------------------------------------------------------------------
+'
+' This code was generated by a tool.
+' Runtime Version:2.0.50727.42
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+'
+'------------------------------------------------------------------------------
+
+Option Strict Off
+Option Explicit On
+
+Imports System
+
+
+ _
+Partial Public Class NorthwindDataSet
+ Inherits System.Data.DataSet
+
+ Private tableCustomers As CustomersDataTable
+
+ Private _schemaSerializationMode As System.Data.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+
+ _
+ Public Sub New()
+ MyBase.New
+ Me.BeginInit
+ Me.InitClass
+ Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
+ AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler
+ AddHandler MyBase.Relations.CollectionChanged, schemaChangedHandler
+ Me.EndInit
+ End Sub
+
+ _
+ Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)
+ MyBase.New(info, context, false)
+ If (Me.IsBinarySerialized(info, context) = true) Then
+ Me.InitVars(false)
+ Dim schemaChangedHandler1 As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
+ AddHandler Me.Tables.CollectionChanged, schemaChangedHandler1
+ AddHandler Me.Relations.CollectionChanged, schemaChangedHandler1
+ Return
+ End If
+ Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(String)),String)
+ If (Me.DetermineSchemaSerializationMode(info, context) = System.Data.SchemaSerializationMode.IncludeSchema) Then
+ Dim ds As System.Data.DataSet = New System.Data.DataSet
+ ds.ReadXmlSchema(New System.Xml.XmlTextReader(New System.IO.StringReader(strSchema)))
+ If (Not (ds.Tables("Customers")) Is Nothing) Then
+ MyBase.Tables.Add(New CustomersDataTable(ds.Tables("Customers")))
+ End If
+ Me.DataSetName = ds.DataSetName
+ Me.Prefix = ds.Prefix
+ Me.Namespace = ds.Namespace
+ Me.Locale = ds.Locale
+ Me.CaseSensitive = ds.CaseSensitive
+ Me.EnforceConstraints = ds.EnforceConstraints
+ Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
+ Me.InitVars
+ Else
+ Me.ReadXmlSchema(New System.Xml.XmlTextReader(New System.IO.StringReader(strSchema)))
+ End If
+ Me.GetSerializationData(info, context)
+ Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
+ AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler
+ AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
+ End Sub
+
+ _
+ Public ReadOnly Property Customers() As CustomersDataTable
+ Get
+ Return Me.tableCustomers
+ End Get
+ End Property
+
+ _
+ Public Overrides Property SchemaSerializationMode() As System.Data.SchemaSerializationMode
+ Get
+ Return Me._schemaSerializationMode
+ End Get
+ Set
+ Me._schemaSerializationMode = value
+ End Set
+ End Property
+
+ _
+ Public Shadows ReadOnly Property Tables() As System.Data.DataTableCollection
+ Get
+ Return MyBase.Tables
+ End Get
+ End Property
+
+ _
+ Public Shadows ReadOnly Property Relations() As System.Data.DataRelationCollection
+ Get
+ Return MyBase.Relations
+ End Get
+ End Property
+
+ _
+ Protected Overrides Sub InitializeDerivedDataSet()
+ Me.BeginInit
+ Me.InitClass
+ Me.EndInit
+ End Sub
+
+ _
+ Public Overrides Function Clone() As System.Data.DataSet
+ Dim cln As NorthwindDataSet = CType(MyBase.Clone,NorthwindDataSet)
+ cln.InitVars
+ cln.SchemaSerializationMode = Me.SchemaSerializationMode
+ Return cln
+ End Function
+
+ _
+ Protected Overrides Function ShouldSerializeTables() As Boolean
+ Return false
+ End Function
+
+ _
+ Protected Overrides Function ShouldSerializeRelations() As Boolean
+ Return false
+ End Function
+
+ _
+ Protected Overrides Sub ReadXmlSerializable(ByVal reader As System.Xml.XmlReader)
+ If (Me.DetermineSchemaSerializationMode(reader) = System.Data.SchemaSerializationMode.IncludeSchema) Then
+ Me.Reset
+ Dim ds As System.Data.DataSet = New System.Data.DataSet
+ ds.ReadXml(reader)
+ If (Not (ds.Tables("Customers")) Is Nothing) Then
+ MyBase.Tables.Add(New CustomersDataTable(ds.Tables("Customers")))
+ End If
+ Me.DataSetName = ds.DataSetName
+ Me.Prefix = ds.Prefix
+ Me.Namespace = ds.Namespace
+ Me.Locale = ds.Locale
+ Me.CaseSensitive = ds.CaseSensitive
+ Me.EnforceConstraints = ds.EnforceConstraints
+ Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
+ Me.InitVars
+ Else
+ Me.ReadXml(reader)
+ Me.InitVars
+ End If
+ End Sub
+
+ _
+ Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchema
+ Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
+ Me.WriteXmlSchema(New System.Xml.XmlTextWriter(stream, Nothing))
+ stream.Position = 0
+ Return System.Xml.Schema.XmlSchema.Read(New System.Xml.XmlTextReader(stream), Nothing)
+ End Function
+
+ _
+ Friend Overloads Sub InitVars()
+ Me.InitVars(true)
+ End Sub
+
+ _
+ Friend Overloads Sub InitVars(ByVal initTable As Boolean)
+ Me.tableCustomers = CType(MyBase.Tables("Customers"),CustomersDataTable)
+ If (initTable = true) Then
+ If (Not (Me.tableCustomers) Is Nothing) Then
+ Me.tableCustomers.InitVars
+ End If
+ End If
+ End Sub
+
+ _
+ Private Sub InitClass()
+ Me.DataSetName = "NorthwindDataSet"
+ Me.Prefix = ""
+ Me.Namespace = "http://tempuri.org/NorthwindDataSet.xsd"
+ Me.EnforceConstraints = true
+ Me.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
+ Me.tableCustomers = New CustomersDataTable
+ MyBase.Tables.Add(Me.tableCustomers)
+ End Sub
+
+ _
+ Private Function ShouldSerializeCustomers() As Boolean
+ Return false
+ End Function
+
+ _
+ Private Sub SchemaChanged(ByVal sender As Object, ByVal e As System.ComponentModel.CollectionChangeEventArgs)
+ If (e.Action = System.ComponentModel.CollectionChangeAction.Remove) Then
+ Me.InitVars
+ End If
+ End Sub
+
+ _
+ Public Shared Function GetTypedDataSetSchema(ByVal xs As System.Xml.Schema.XmlSchemaSet) As System.Xml.Schema.XmlSchemaComplexType
+ Dim ds As NorthwindDataSet = New NorthwindDataSet
+ Dim type As System.Xml.Schema.XmlSchemaComplexType = New System.Xml.Schema.XmlSchemaComplexType
+ Dim sequence As System.Xml.Schema.XmlSchemaSequence = New System.Xml.Schema.XmlSchemaSequence
+ xs.Add(ds.GetSchemaSerializable)
+ Dim any As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny
+ any.Namespace = ds.Namespace
+ sequence.Items.Add(any)
+ type.Particle = sequence
+ Return type
+ End Function
+
+ Public Delegate Sub CustomersRowChangeEventHandler(ByVal sender As Object, ByVal e As CustomersRowChangeEvent)
+
+ _
+ Partial Public Class CustomersDataTable
+ Inherits System.Data.DataTable
+ Implements System.Collections.IEnumerable
+
+ Private columnCustomerID As System.Data.DataColumn
+
+ Private columnCompanyName As System.Data.DataColumn
+
+ Private columnContactName As System.Data.DataColumn
+
+ Private columnContactTitle As System.Data.DataColumn
+
+ Private columnAddress As System.Data.DataColumn
+
+ Private columnCity As System.Data.DataColumn
+
+ Private columnRegion As System.Data.DataColumn
+
+ Private columnPostalCode As System.Data.DataColumn
+
+ Private columnCountry As System.Data.DataColumn
+
+ Private columnPhone As System.Data.DataColumn
+
+ Private columnFax As System.Data.DataColumn
+
+ _
+ Public Sub New()
+ MyBase.New
+ Me.TableName = "Customers"
+ Me.BeginInit
+ Me.InitClass
+ Me.EndInit
+ End Sub
+
+ _
+ Friend Sub New(ByVal table As System.Data.DataTable)
+ MyBase.New
+ Me.TableName = table.TableName
+ If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
+ Me.CaseSensitive = table.CaseSensitive
+ End If
+ If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
+ Me.Locale = table.Locale
+ End If
+ If (table.Namespace <> table.DataSet.Namespace) Then
+ Me.Namespace = table.Namespace
+ End If
+ Me.Prefix = table.Prefix
+ Me.MinimumCapacity = table.MinimumCapacity
+ End Sub
+
+ _
+ Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)
+ MyBase.New(info, context)
+ Me.InitVars
+ End Sub
+
+ _
+ Public ReadOnly Property CustomerIDColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnCustomerID
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property CompanyNameColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnCompanyName
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property ContactNameColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnContactName
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property ContactTitleColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnContactTitle
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property AddressColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnAddress
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property CityColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnCity
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property RegionColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnRegion
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property PostalCodeColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnPostalCode
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property CountryColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnCountry
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property PhoneColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnPhone
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property FaxColumn() As System.Data.DataColumn
+ Get
+ Return Me.columnFax
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property Count() As Integer
+ Get
+ Return Me.Rows.Count
+ End Get
+ End Property
+
+ _
+ Public Default ReadOnly Property Item(ByVal index As Integer) As CustomersRow
+ Get
+ Return CType(Me.Rows(index),CustomersRow)
+ End Get
+ End Property
+
+ Public Event CustomersRowChanging As CustomersRowChangeEventHandler
+
+ Public Event CustomersRowChanged As CustomersRowChangeEventHandler
+
+ Public Event CustomersRowDeleting As CustomersRowChangeEventHandler
+
+ Public Event CustomersRowDeleted As CustomersRowChangeEventHandler
+
+ _
+ Public Overloads Sub AddCustomersRow(ByVal row As CustomersRow)
+ Me.Rows.Add(row)
+ End Sub
+
+ _
+ Public Overloads Function AddCustomersRow(ByVal CustomerID As String, ByVal CompanyName As String, ByVal ContactName As String, ByVal ContactTitle As String, ByVal Address As String, ByVal City As String, ByVal _Region As String, ByVal PostalCode As String, ByVal Country As String, ByVal Phone As String, ByVal Fax As String) As CustomersRow
+ Dim rowCustomersRow As CustomersRow = CType(Me.NewRow,CustomersRow)
+ rowCustomersRow.ItemArray = New Object() {CustomerID, CompanyName, ContactName, ContactTitle, Address, City, _Region, PostalCode, Country, Phone, Fax}
+ Me.Rows.Add(rowCustomersRow)
+ Return rowCustomersRow
+ End Function
+
+ _
+ Public Function FindByCustomerID(ByVal CustomerID As String) As CustomersRow
+ Return CType(Me.Rows.Find(New Object() {CustomerID}),CustomersRow)
+ End Function
+
+ _
+ Public Overridable Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
+ Return Me.Rows.GetEnumerator
+ End Function
+
+ _
+ Public Overrides Function Clone() As System.Data.DataTable
+ Dim cln As CustomersDataTable = CType(MyBase.Clone,CustomersDataTable)
+ cln.InitVars
+ Return cln
+ End Function
+
+ _
+ Protected Overrides Function CreateInstance() As System.Data.DataTable
+ Return New CustomersDataTable
+ End Function
+
+ _
+ Friend Sub InitVars()
+ Me.columnCustomerID = MyBase.Columns("CustomerID")
+ Me.columnCompanyName = MyBase.Columns("CompanyName")
+ Me.columnContactName = MyBase.Columns("ContactName")
+ Me.columnContactTitle = MyBase.Columns("ContactTitle")
+ Me.columnAddress = MyBase.Columns("Address")
+ Me.columnCity = MyBase.Columns("City")
+ Me.columnRegion = MyBase.Columns("Region")
+ Me.columnPostalCode = MyBase.Columns("PostalCode")
+ Me.columnCountry = MyBase.Columns("Country")
+ Me.columnPhone = MyBase.Columns("Phone")
+ Me.columnFax = MyBase.Columns("Fax")
+ End Sub
+
+ _
+ Private Sub InitClass()
+ Me.columnCustomerID = New System.Data.DataColumn("CustomerID", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnCustomerID)
+ Me.columnCompanyName = New System.Data.DataColumn("CompanyName", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnCompanyName)
+ Me.columnContactName = New System.Data.DataColumn("ContactName", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnContactName)
+ Me.columnContactTitle = New System.Data.DataColumn("ContactTitle", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnContactTitle)
+ Me.columnAddress = New System.Data.DataColumn("Address", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnAddress)
+ Me.columnCity = New System.Data.DataColumn("City", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnCity)
+ Me.columnRegion = New System.Data.DataColumn("Region", GetType(String), Nothing, System.Data.MappingType.Element)
+ Me.columnRegion.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "_Region")
+ Me.columnRegion.ExtendedProperties.Add("Generator_UserColumnName", "Region")
+ MyBase.Columns.Add(Me.columnRegion)
+ Me.columnPostalCode = New System.Data.DataColumn("PostalCode", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnPostalCode)
+ Me.columnCountry = New System.Data.DataColumn("Country", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnCountry)
+ Me.columnPhone = New System.Data.DataColumn("Phone", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnPhone)
+ Me.columnFax = New System.Data.DataColumn("Fax", GetType(String), Nothing, System.Data.MappingType.Element)
+ MyBase.Columns.Add(Me.columnFax)
+ Me.Constraints.Add(New System.Data.UniqueConstraint("Constraint1", New System.Data.DataColumn() {Me.columnCustomerID}, true))
+ Me.columnCustomerID.AllowDBNull = false
+ Me.columnCustomerID.Unique = true
+ Me.columnCustomerID.MaxLength = 5
+ Me.columnCompanyName.MaxLength = 40
+ Me.columnContactName.MaxLength = 30
+ Me.columnContactTitle.MaxLength = 30
+ Me.columnAddress.MaxLength = 60
+ Me.columnCity.MaxLength = 15
+ Me.columnRegion.MaxLength = 15
+ Me.columnPostalCode.MaxLength = 10
+ Me.columnCountry.MaxLength = 15
+ Me.columnPhone.MaxLength = 24
+ Me.columnFax.MaxLength = 24
+ End Sub
+
+ _
+ Public Function NewCustomersRow() As CustomersRow
+ Return CType(Me.NewRow,CustomersRow)
+ End Function
+
+ _
+ Protected Overrides Function NewRowFromBuilder(ByVal builder As System.Data.DataRowBuilder) As System.Data.DataRow
+ Return New CustomersRow(builder)
+ End Function
+
+ _
+ Protected Overrides Function GetRowType() As System.Type
+ Return GetType(CustomersRow)
+ End Function
+
+ _
+ Protected Overrides Sub OnRowChanged(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowChanged(e)
+ If (Not (Me.CustomersRowChangedEvent) Is Nothing) Then
+ RaiseEvent CustomersRowChanged(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Protected Overrides Sub OnRowChanging(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowChanging(e)
+ If (Not (Me.CustomersRowChangingEvent) Is Nothing) Then
+ RaiseEvent CustomersRowChanging(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Protected Overrides Sub OnRowDeleted(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowDeleted(e)
+ If (Not (Me.CustomersRowDeletedEvent) Is Nothing) Then
+ RaiseEvent CustomersRowDeleted(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Protected Overrides Sub OnRowDeleting(ByVal e As System.Data.DataRowChangeEventArgs)
+ MyBase.OnRowDeleting(e)
+ If (Not (Me.CustomersRowDeletingEvent) Is Nothing) Then
+ RaiseEvent CustomersRowDeleting(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action))
+ End If
+ End Sub
+
+ _
+ Public Sub RemoveCustomersRow(ByVal row As CustomersRow)
+ Me.Rows.Remove(row)
+ End Sub
+
+ _
+ Public Shared Function GetTypedTableSchema(ByVal xs As System.Xml.Schema.XmlSchemaSet) As System.Xml.Schema.XmlSchemaComplexType
+ Dim type As System.Xml.Schema.XmlSchemaComplexType = New System.Xml.Schema.XmlSchemaComplexType
+ Dim sequence As System.Xml.Schema.XmlSchemaSequence = New System.Xml.Schema.XmlSchemaSequence
+ Dim ds As NorthwindDataSet = New NorthwindDataSet
+ xs.Add(ds.GetSchemaSerializable)
+ Dim any1 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny
+ any1.Namespace = "http://www.w3.org/2001/XMLSchema"
+ any1.MinOccurs = New Decimal(0)
+ any1.MaxOccurs = Decimal.MaxValue
+ any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax
+ sequence.Items.Add(any1)
+ Dim any2 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny
+ any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"
+ any2.MinOccurs = New Decimal(1)
+ any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax
+ sequence.Items.Add(any2)
+ Dim attribute1 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute
+ attribute1.Name = "namespace"
+ attribute1.FixedValue = ds.Namespace
+ type.Attributes.Add(attribute1)
+ Dim attribute2 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute
+ attribute2.Name = "tableTypeName"
+ attribute2.FixedValue = "CustomersDataTable"
+ type.Attributes.Add(attribute2)
+ type.Particle = sequence
+ Return type
+ End Function
+ End Class
+
+ _
+ Partial Public Class CustomersRow
+ Inherits System.Data.DataRow
+
+ Private tableCustomers As CustomersDataTable
+
+ _
+ Friend Sub New(ByVal rb As System.Data.DataRowBuilder)
+ MyBase.New(rb)
+ Me.tableCustomers = CType(Me.Table,CustomersDataTable)
+ End Sub
+
+ _
+ Public Property CustomerID() As String
+ Get
+ Return CType(Me(Me.tableCustomers.CustomerIDColumn),String)
+ End Get
+ Set
+ Me(Me.tableCustomers.CustomerIDColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property CompanyName() As String
+ Get
+ Try
+ Return CType(Me(Me.tableCustomers.CompanyNameColumn),String)
+ Catch e As System.InvalidCastException
+ Throw New System.Data.StrongTypingException("The value for column 'CompanyName' in table 'Customers' is DBNull.", e)
+ End Try
+ End Get
+ Set
+ Me(Me.tableCustomers.CompanyNameColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property ContactName() As String
+ Get
+ Try
+ Return CType(Me(Me.tableCustomers.ContactNameColumn),String)
+ Catch e As System.InvalidCastException
+ Throw New System.Data.StrongTypingException("The value for column 'ContactName' in table 'Customers' is DBNull.", e)
+ End Try
+ End Get
+ Set
+ Me(Me.tableCustomers.ContactNameColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property ContactTitle() As String
+ Get
+ Try
+ Return CType(Me(Me.tableCustomers.ContactTitleColumn),String)
+ Catch e As System.InvalidCastException
+ Throw New System.Data.StrongTypingException("The value for column 'ContactTitle' in table 'Customers' is DBNull.", e)
+ End Try
+ End Get
+ Set
+ Me(Me.tableCustomers.ContactTitleColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property Address() As String
+ Get
+ Try
+ Return CType(Me(Me.tableCustomers.AddressColumn),String)
+ Catch e As System.InvalidCastException
+ Throw New System.Data.StrongTypingException("The value for column 'Address' in table 'Customers' is DBNull.", e)
+ End Try
+ End Get
+ Set
+ Me(Me.tableCustomers.AddressColumn) = value
+ End Set
+ End Property
+
+ _
+ Public Property City() As String
+ Get
+ Try
+ Return CType(Me(Me.tableCustomers.CityColumn),String)
+ Catch e As System.InvalidCastException
+ Throw New System.Data.StrongTypingException("The value for column 'City' in table 'Customers' is DBNull.", e)
+ End Try
+ End Get
+ Set
+ Me(Me.tableCustomers.CityColumn) = value
+ End Set
+ End Property
+
+