diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp.sln b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp.sln new file mode 100644 index 0000000..6104bd8 --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMO Sample CSharp", "SMO Sample CSharp\SMO Sample CSharp.csproj", "{031018D2-8161-4DE4-BFBB-6FBD49C89B6D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {031018D2-8161-4DE4-BFBB-6FBD49C89B6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {031018D2-8161-4DE4-BFBB-6FBD49C89B6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {031018D2-8161-4DE4-BFBB-6FBD49C89B6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {031018D2-8161-4DE4-BFBB-6FBD49C89B6D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp.suo b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp.suo new file mode 100644 index 0000000..0613aab Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp.suo differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Form1.Designer.cs b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Form1.Designer.cs new file mode 100644 index 0000000..0c3e7ba --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Form1.Designer.cs @@ -0,0 +1,105 @@ +namespace SMO_Sample_CSharp +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnConnect = new System.Windows.Forms.Button(); + this.btnClear = new System.Windows.Forms.Button(); + this.listDatabases = new System.Windows.Forms.ListBox(); + this.listTables = new System.Windows.Forms.ListBox(); + this.txtSQLScript = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); +// +// btnConnect +// + this.btnConnect.Location = new System.Drawing.Point(27, 13); + this.btnConnect.Name = "btnConnect"; + this.btnConnect.TabIndex = 0; + this.btnConnect.Text = "&Connect"; + this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click); +// +// btnClear +// + this.btnClear.Location = new System.Drawing.Point(140, 13); + this.btnClear.Name = "btnClear"; + this.btnClear.TabIndex = 1; + this.btnClear.Text = "C&lear"; + this.btnClear.Click += new System.EventHandler(this.btnClear_Click); +// +// listDatabases +// + this.listDatabases.FormattingEnabled = true; + this.listDatabases.Location = new System.Drawing.Point(26, 71); + this.listDatabases.Name = "listDatabases"; + this.listDatabases.Size = new System.Drawing.Size(332, 264); + this.listDatabases.TabIndex = 2; + this.listDatabases.SelectedIndexChanged += new System.EventHandler(this.listDatabases_SelectedIndexChanged); +// +// listTables +// + this.listTables.FormattingEnabled = true; + this.listTables.Location = new System.Drawing.Point(373, 69); + this.listTables.Name = "listTables"; + this.listTables.Size = new System.Drawing.Size(298, 264); + this.listTables.TabIndex = 3; + this.listTables.SelectedIndexChanged += new System.EventHandler(this.listTables_SelectedIndexChanged); +// +// txtSQLScript +// + this.txtSQLScript.AutoSize = false; + this.txtSQLScript.Location = new System.Drawing.Point(29, 350); + this.txtSQLScript.Multiline = true; + this.txtSQLScript.Name = "txtSQLScript"; + this.txtSQLScript.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.txtSQLScript.Size = new System.Drawing.Size(640, 151); + this.txtSQLScript.TabIndex = 4; +// +// Form1 +// + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(700, 513); + this.Controls.Add(this.txtSQLScript); + this.Controls.Add(this.listTables); + this.Controls.Add(this.listDatabases); + this.Controls.Add(this.btnClear); + this.Controls.Add(this.btnConnect); + this.Name = "Form1"; + this.Text = "SMO Sample Application"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button btnConnect; + private System.Windows.Forms.Button btnClear; + private System.Windows.Forms.ListBox listDatabases; + private System.Windows.Forms.ListBox listTables; + private System.Windows.Forms.TextBox txtSQLScript; + } +} + diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Form1.cs b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Form1.cs new file mode 100644 index 0000000..d249d4a --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Form1.cs @@ -0,0 +1,108 @@ +#region Using directives + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Text; +using System.Drawing; +using System.Windows.Forms; +using Microsoft.SqlServer.Management.Smo; +using System.Collections.Specialized; + + +#endregion + +namespace SMO_Sample_CSharp +{ + partial class Form1: Form + { + Server srvSQLServer = new Server(); + //You could also use dynamic arrays here + //with ArrayList + Database[] arrDBs = new Database[100]; + Table[] arrTables = new Table[1000]; + + public Form1() + { + InitializeComponent(); + } + + private void btnConnect_Click(object sender, EventArgs e) + { + listDatabases.Items.Clear(); + listTables.Items.Clear(); + txtSQLScript.Clear(); + ClearArray(); + listDatabases.DisplayMember = "Name"; + + + int i = 0; + foreach(Database tmpdb in srvSQLServer.Databases){ + if (tmpdb.IsSystemObject != true){ + listDatabases.Items.Add(tmpdb.ToString()); + arrDBs[i] = tmpdb; + i++; + } + } + + } + + private void btnClear_Click(object sender, EventArgs e) + { + listDatabases.Items.Clear(); + listTables.Items.Clear(); + txtSQLScript.Clear(); + ClearArray(); + } + + private void ClearArray() + { + for (int i = 0; i < arrDBs.Length; i++) + { + arrDBs[i] = null; + } + for (int i = 0; i < arrTables.Length; i++) + { + arrTables[i] = null; + } + } + + private void listDatabases_SelectedIndexChanged(object sender, EventArgs e) + { + listTables.Items.Clear(); + txtSQLScript.Clear(); + listTables.DisplayMember = "ToString()"; + + Database tmpdb = new Database(); + tmpdb = arrDBs[listDatabases.SelectedIndex]; + + int i = 0; + foreach (Table tmptable in tmpdb.Tables){ + if (tmptable.IsSystemObject != true){ + listTables.Items.Add(tmptable.ToString()); + arrTables[i] = tmptable; + i++; + } + } + } + + private void listTables_SelectedIndexChanged(object sender, EventArgs e) + { + StringCollection sc = new StringCollection(); + + //Get the table's script + sc = arrTables[listTables.SelectedIndex].Script(); + + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < sc.Count; i++) + { + sb.AppendLine(sc[i]); + } + + txtSQLScript.Text = sb.ToString(); + + } + } +} \ No newline at end of file diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Program.cs b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Program.cs new file mode 100644 index 0000000..818e7f0 --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Program.cs @@ -0,0 +1,24 @@ +#region Using directives + +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +#endregion + +namespace SMO_Sample_CSharp +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + //Application.EnableRTLMirroring(); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/AssemblyInfo.cs b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..876f2bb --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +#region Using directives + +using System.Reflection; +using System.Runtime.CompilerServices; + +#endregion + +// 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. +[assembly: AssemblyTitle("SMO_Sample_CSharp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SMO_Sample_CSharp")] +[assembly: AssemblyCopyright("Copyright @ Microsoft 2004")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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 Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Resources.cs b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Resources.cs new file mode 100644 index 0000000..72cdbdf --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Resources.cs @@ -0,0 +1,61 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.40426.20 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SMO_Sample_CSharp.Properties { + using System; + using System.IO; + using System.Resources; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the Strongly Typed Resource Builder + // class via a tool like ResGen or Visual Studio.NET. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + class Resources { + + private static System.Resources.ResourceManager _resMgr; + + private static System.Globalization.CultureInfo _resCulture; + + /*FamANDAssem*/ internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Resources.ResourceManager ResourceManager { + get { + if ((_resMgr == null)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("SMO_Sample_CSharp.Properties.Resources", typeof(Resources).Assembly); + _resMgr = temp; + } + return _resMgr; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Globalization.CultureInfo Culture { + get { + return _resCulture; + } + set { + _resCulture = value; + } + } + } +} diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Resources.resx b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Resources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Settings.cs b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Settings.cs new file mode 100644 index 0000000..fdd5890 --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Settings.cs @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.40426.20 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SMO_Sample_CSharp.Properties { + + + public partial class Settings : System.Configuration.ApplicationSettingsBase { + + private static Settings m_Value; + + private static object m_SyncObject = new object(); + + public static Settings Value { + get { + if ((Settings.m_Value == null)) { + System.Threading.Monitor.Enter(Settings.m_SyncObject); + if ((Settings.m_Value == null)) { + try { + Settings.m_Value = new Settings(); + } + finally { + System.Threading.Monitor.Exit(Settings.m_SyncObject); + } + } + } + return Settings.m_Value; + } + } + } +} diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Settings.settings b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Settings.settings new file mode 100644 index 0000000..4024694 --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/SMO Sample CSharp.csproj b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/SMO Sample CSharp.csproj new file mode 100644 index 0000000..005c433 --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/SMO Sample CSharp.csproj @@ -0,0 +1,79 @@ + + + Debug + 8.0.50727 + 2.0 + {031018D2-8161-4DE4-BFBB-6FBD49C89B6D} + WinExe + SMO_Sample_CSharp + SMO Sample CSharp + 4 + + + true + full + false + .\bin\Debug\ + DEBUG;TRACE + + + false + true + .\bin\Release\ + TRACE + + + + ..\..\..\..\..\..\..\Program Files\Microsoft SQL Server\90\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll + False + + + ..\..\..\..\..\..\..\Program Files\Microsoft SQL Server\90\SDK\Assemblies\Microsoft.SqlServer.Smo.dll + False + + + False + + + False + + + False + + + False + + + False + + + + + Form + + + Form1.cs + + + + + ResXFileCodeGenerator + Resources.cs + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.cs + + + True + Settings.settings + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/SMO Sample CSharp.csproj.user b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/SMO Sample CSharp.csproj.user new file mode 100644 index 0000000..7a89310 --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/SMO Sample CSharp.csproj.user @@ -0,0 +1,7 @@ + + + 8.0.40426 + ProjectFiles + 0 + + \ No newline at end of file diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/Microsoft.SqlServer.BatchParser.dll b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/Microsoft.SqlServer.BatchParser.dll new file mode 100644 index 0000000..e7cc89a Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/Microsoft.SqlServer.BatchParser.dll differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/Microsoft.SqlServer.Replication.dll b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/Microsoft.SqlServer.Replication.dll new file mode 100644 index 0000000..6da20ad Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/Microsoft.SqlServer.Replication.dll differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/SMO Sample CSharp.exe b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/SMO Sample CSharp.exe new file mode 100644 index 0000000..f432657 Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/SMO Sample CSharp.exe differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/SMO Sample CSharp.pdb b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/SMO Sample CSharp.pdb new file mode 100644 index 0000000..7e660bf Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/SMO Sample CSharp.pdb differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/SMO Sample CSharp.vshost.exe b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/SMO Sample CSharp.vshost.exe new file mode 100644 index 0000000..72b0f71 Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/bin/Debug/SMO Sample CSharp.vshost.exe differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/ResGen.cache b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/ResGen.cache new file mode 100644 index 0000000..389fe81 Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/ResGen.cache differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/ResolveAssemblyReference.cache b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..61315be Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO Sample CSharp.csproj.GenerateResource.Cache b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO Sample CSharp.csproj.GenerateResource.Cache new file mode 100644 index 0000000..b9d3b3b Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO Sample CSharp.csproj.GenerateResource.Cache differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO Sample CSharp.exe b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO Sample CSharp.exe new file mode 100644 index 0000000..f432657 Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO Sample CSharp.exe differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO Sample CSharp.pdb b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO Sample CSharp.pdb new file mode 100644 index 0000000..7e660bf Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO Sample CSharp.pdb differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO_Sample_CSharp.Properties.Resources.resources b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO_Sample_CSharp.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/SMO_Sample_CSharp.Properties.Resources.resources differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/TempPE/Properties.Resources.cs.dll b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/TempPE/Properties.Resources.cs.dll new file mode 100644 index 0000000..c6bf711 Binary files /dev/null and b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/Debug/TempPE/Properties.Resources.cs.dll differ diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/SMO Sample CSharp.csproj.FileList.txt b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/SMO Sample CSharp.csproj.FileList.txt new file mode 100644 index 0000000..8f0d553 --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/obj/SMO Sample CSharp.csproj.FileList.txt @@ -0,0 +1,9 @@ +obj\Debug\SMO Sample CSharp.exe +obj\Debug\SMO Sample CSharp.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\SMO_Sample_CSharp.Properties.Resources.resources +obj\Debug\SMO Sample CSharp.csproj.GenerateResource.Cache +.\bin\Debug\SMO Sample CSharp.exe +.\bin\Debug\SMO Sample CSharp.pdb +.\bin\Debug\Microsoft.SqlServer.Replication.dll +.\bin\Debug\Microsoft.SqlServer.BatchParser.dll diff --git a/1590594770-1/Chapter02/SMO Sample CSharp/readme.txt b/1590594770-1/Chapter02/SMO Sample CSharp/readme.txt new file mode 100644 index 0000000..24456a9 --- /dev/null +++ b/1590594770-1/Chapter02/SMO Sample CSharp/readme.txt @@ -0,0 +1,9 @@ +The SMO samples shows you how to use SMO to build administrative applications against SQL Server. + +To run the application, perform the following steps: + +1) Double click the SMO Sample CSharp.sln file to load the application into Visual Studio 2005. + +2) Hit ctrl-F5 to start the application without debugging. + +3) Click the Connect button. You can then Select Databases on the left hand side, tables in those databases on the right hand side and then see the T-SQL to create the table on the bottom. diff --git a/1590594770-1/Chapter03/4770ch03_code.sql b/1590594770-1/Chapter03/4770ch03_code.sql new file mode 100644 index 0000000..82cee5f --- /dev/null +++ b/1590594770-1/Chapter03/4770ch03_code.sql @@ -0,0 +1,1098 @@ +USE AdventureWorks --all of the code is to be executed in adventureworks +GO + +---------------------------------------------------------------------- +-- DML Enhancements - Old-Style Outer Joins Deprecated +---------------------------------------------------------------------- + +--causes error +SELECT * +FROM sales.salesPerson as salesPerson, + sales.salesTerritory as salesTerritory +WHERE salesperson.territoryId *= salesTerritory.territoryId +go + +SELECT * +FROM sales.salesPerson as salesPerson + LEFT OUTER JOIN sales.salesTerritory as salesTerritory + on salesperson.territoryId = salesTerritory.territoryId +go + +SELECT +FROM sales.salesPerson as salesPerson, + sales.salesTerritory as salesTerritory +WHERE salesperson.territoryId = salesTerritory.territoryId +go + + +---------------------------------------------------------------------- +-- DML Enhancements - Common Table Expressions +---------------------------------------------------------------------- +WITH simpleExample as +( + SELECT 'hi' AS columnName +) + +SELECT columnName +FROM simpleExample +GO +SELECT columnName +FROM (SELECT 'hi' AS columnName) AS simpleExample +GO + +--In SQL Server 2000 +SELECT cast(c.LastName + ', ' + c.FirstName as varchar(30)) as SalesPerson + , +--YEAR TO DATE SALES + (SELECT amount + FROM ( SELECT soh.SalesPersonID, sum(sod.LineTotal) as amount + FROM sales.SalesOrderHeader soh + JOIN sales.SalesOrderDetail sod + ON sod.SalesOrderID = soh.SalesOrderID + WHERE soh.Status = 5 -- complete + and soh.OrderDate >= '20040101' + GROUP by soh.SalesPersonID) as YTDSalesPerson + where YTDSalesPerson.salesPersonId = salesperson.SalesPersonID) as YTDSales, + +--PERCENT OF TOTAL + (SELECT amount + FROM (SELECT soh.SalesPersonID, sum(sod.LineTotal) as amount + FROM sales.SalesOrderHeader soh + JOIN sales.SalesOrderDetail sod + ON sod.SalesOrderID = soh.SalesOrderID + WHERE soh.Status = 5 -- complete + and soh.OrderDate >= '20040101' + GROUP by soh.SalesPersonID) as YTDSalesPerson + where YTDSalesPerson.salesPersonId = salesperson.SalesPersonID) / + (SELECT sum(amount) + FROM (SELECT soh.SalesPersonID, sum(sod.LineTotal) as amount + FROM sales.SalesOrderHeader soh + JOIN sales.SalesOrderDetail sod + ON sod.SalesOrderID = soh.SalesOrderID + WHERE soh.Status = 5 -- complete + and soh.OrderDate >= '20040101' + GROUP by soh.SalesPersonID) as YTDSalesPerson + ) as percentOfTotal, + +--COMPARE TO QUOTA + (SELECT amount + FROM (SELECT soh.SalesPersonID, sum(sod.LineTotal) as amount + FROM sales.SalesOrderHeader soh + JOIN sales.SalesOrderDetail sod + ON sod.SalesOrderID = soh.SalesOrderID + WHERE soh.Status = 5 -- complete + and soh.OrderDate >= '20040101' + GROUP by soh.SalesPersonID)as YTDSalesPerson + where YTDSalesPerson.salesPersonId = salesperson.SalesPersonID) - + salesPerson.SalesQuota as MetQuota + + FROM sales.SalesPerson as salesPerson + join HumanResources.Employee as e + on salesPerson.salesPersonId = e.employeeId + join Person.Contact as c + on c.contactId = e.contactId +GO + +-- SQL Server 2005 CTE syntax +WITH YTDSalesPerson +AS +( + SELECT soh.SalesPersonID, sum(sod.LineTotal) as amount + FROM sales.SalesOrderHeader soh + JOIN sales.SalesOrderDetail sod + ON sod.SalesOrderID = soh.SalesOrderID + WHERE soh.Status = 5 -- complete + and soh.OrderDate >= '20040101' + GROUP by soh.SalesPersonID +), +SalesPersonInfo +AS +( + SELECT salesPersonId, SalesQuota as salesQuota, + cast(c.LastName + ', ' + c.FirstName as varchar(30)) as SalesPerson + FROM sales.SalesPerson as s + JOIN HumanResources.Employee as e + on s.salesPersonId = e.employeeId + JOIN Person.Contact as c + on c.contactId = e.contactId +) +SELECT SalesPersonInfo.SalesPerson, + (SELECT amount + FROM YTDSalesPerson + WHERE YTDSalesPerson.salesPersonId = salespersonInfo.SalesPersonID) + as YTDSales, + + (SELECT amount + FROM YTDSalesPerson + WHERE YTDSalesPerson.salesPersonId = salespersonInfo.SalesPersonID) + / (SELECT sum(amount) FROM YTDSalesPerson) as percentOfTotal, + + (SELECT amount + FROM YTDSalesPerson + WHERE YTDSalesPerson.salesPersonId = salespersonInfo.SalesPersonID) - + salesPersonInfo.SalesQuota as MetQuota + +FROM SalesPersonInfo +Go + +WITH YTDSalesPerson +AS +( + SELECT soh.SalesPersonID, sum(sod.LineTotal) as amount + FROM sales.SalesOrderHeader soh + JOIN sales.SalesOrderDetail sod + ON sod.SalesOrderID = soh.SalesOrderID + WHERE soh.Status = 5 -- complete + and soh.OrderDate >= '20040101' + GROUP by soh.SalesPersonID +) +SELECT * +FROM YTDSalesPerson +GO + +-- SQL Server 2000 example of the recursive query + +DECLARE @managerId int +SET @managerId = 140 + + --holds the output treelevel, which lets us isolate a level in the looped query +DECLARE @outTable table (employeeId int, managerId int, treeLevel int) + + --used to hold the level of the tree we are currently at in the loop +DECLARE @treeLevel as int +SET @treelevel = 1 + + --get the top level + INSERT INTO @outTable + SELECT employeeId, managerId, @treelevel as treelevel + FROM HumanResources.employee as employee + WHERE (employee.managerId = @managerId) + + WHILE (1 = 1) --imitates do...until construct + BEGIN + + INSERT INTO @outTable + SELECT employee.employeeId, employee.managerId, + treelevel + 1 as treelevel + FROM HumanResources.employee as employee + JOIN @outTable as ht + ON employee.managerId = ht.employeeId + --this where isolates a given level of the tree + WHERE EXISTS( SELECT * + FROM @outTable AS holdTree + WHERE treelevel = @treelevel + AND employee.managerId = holdtree.employeeId) + + IF @@rowcount = 0 + BEGIN + BREAK + END + + SET @treelevel = @treelevel + 1 + END + +SELECT Employee.EmployeeID,Contact.LastName,Contact.FirstName +FROM HumanResources.Employee as Employee + INNER JOIN @outTable ot + ON Employee.EmployeeID = ot.EmployeeID + INNER JOIN Person.Contact as Contact + ON Contact.contactId = Employee.contactId +go +--recursive query using CTE +-- SQL Server 2005 syntax +DECLARE @managerId int +SET @managerId = 140; + +WITH EmployeeHierarchy (EmployeeId, ManagerId) +AS +( + SELECT EmployeeID, ManagerID + FROM HumanResources.Employee as Employee + WHERE ManagerID=@managerId + + UNION ALL + + SELECT Employee.EmployeeID, Employee.ManagerID + FROM HumanResources.Employee as Employee + INNER JOIN EmployeeHierarchy + on Employee.ManagerID= EmployeeHierarchy.EmployeeID) + +SELECT Employee.EmployeeID,Contact.LastName,Contact.FirstName +FROM HumanResources.Employee as Employee + INNER JOIN EmployeeHierarchy + ON Employee.EmployeeID = EmployeeHierarchy.EmployeeID + INNER JOIN Person.Contact as Contact + ON Contact.contactId = Employee.contactId +GO + +--enhanced version of the CTE query +DECLARE @managerId int +SET @managerId = 140; + +WITH EmployeeHierarchy(EmployeeID, ManagerID, treelevel, heirarchy) +AS +( + SELECT EmployeeID, ManagerID, + 1 as treeevel, CAST(EmployeeId as varchar(max)) as heirarchy + FROM HumanResources.Employee as Employee + WHERE ManagerID=@managerId + + UNION ALL + + SELECT Employee.EmployeeID, Employee.ManagerID, + treelevel + 1 as treelevel, + heirarchy + '\' +cast(Employee.EmployeeId as varchar(20)) as heirarchy + FROM HumanResources.Employee as Employee + INNER JOIN EmployeeHierarchy + on Employee.ManagerID= EmployeeHierarchy.EmployeeID +) + +SELECT Employee.EmployeeID,Contact.LastName,Contact.FirstName, + EmployeeHierarchy.treelevel, EmployeeHierarchy.heirarchy +FROM HumanResources.Employee as Employee + INNER JOIN EmployeeHierarchy + ON Employee.EmployeeID = EmployeeHierarchy.EmployeeID + INNER JOIN Person.Contact as Contact + ON Contact.contactId = employee.contactId +ORDER BY heirarchy +go + +---------------------------------------------------------------------- +-- DML Enhancements - TOP +---------------------------------------------------------------------- + +DECLARE @rowsToReturn int + +SELECT @rowsToReturn = 10 + +SELECT TOP(@rowsToReturn) * --note that TOP requires parentheses to accept + --parameters but not for constant +FROM HumanResources.Employee +GO +CREATE TABLE testTop +( + value int primary Key +) +INSERT TOP (5) into testTop +SELECT * --this derived table returns seven rows +FROM (SELECT 1 as value union SELECT 2 union SELECT 3 union SELECT 4 + union SELECT 5 union SELECT 6 union SELECT 7) as sevenRows +go +SELECT * +FROM testTop +go + +UPDATE TOP (2) testTop +SET value = value * 100 + +SELECT * +FROM testTop +GO +DELETE TOP(3) testTop +go + +select * from testTop +go + +/* this statement does not refer to any actual table +INSERT TOP(10) otherTable (batchTableId, value) +SELECT batchTableId, value +FROM batchTable +WHERE not exists ( SELECT * + FROM otherTable + WHERE otherTable.batchTableId = batchTable.batchTableId) +*/ + +create table top10sales +( + salesOrderId int, + totalDue money +) + +insert TOP (10) top10sales +SELECT salesOrderId, totalDue +FROM sales.salesOrderHeader +ORDER BY totalDue desc +go + +--added +truncate table top10sales +go +INSERT top10sales +SELECT TOP (10) salesOrderId, totalDue +FROM sales.salesOrderHeader +ORDER BY totalDue desc +GO +BEGIN TRANSACTION +DECLARE @rowcount int +SET @rowcount = 100 +WHILE (@rowcount = 100) --if it is less than 100, we are done, greater than 100 + BEGIN --cannot happen + DELETE TOP(100) sales.salesOrderHeader + SET @rowcount = @@rowcount + END +ROLLBACK TRANSACTION --we don't want to actually delete the rows +GO + +---------------------------------------------------------------------- +-- DML Enhancements - FROM Clause extensions +---------------------------------------------------------------------- + +/* causes error +SELECT Product.productNumber, SalesOrderAverage.averageTotal +FROM Production.Product as Product + JOIN ( SELECT AVG(lineTotal) as averageTotal + FROM Sales.SalesOrderDetail as SalesOrderDetail + WHERE product.ProductID=SalesOrderDetail.ProductID + HAVING COUNT(*) > 1 + ) as SalesOrderAverage + +SELECT Product.productNumber, SalesOrderAverage.averageTotal +FROM Production.Product as Product + JOIN dbo.getAverageTotalPerProduct(product.productId) + as SalesOrderAverage + +*/ + +--Cross Apply +SELECT Product.productNumber, SalesOrderAverage.averageTotal +FROM Production.Product as Product + CROSS APPLY ( SELECT AVG(lineTotal) as averageTotal + FROM Sales.SalesOrderDetail as SalesOrderDetail + WHERE product.ProductID=SalesOrderDetail.ProductID + HAVING COUNT(*) > 0 + ) as SalesOrderAverage +go + +CREATE FUNCTION production.getAverageTotalPerProduct +( + @productId int +) +RETURNS @output TABLE (unitPrice decimal(10,4)) +AS + BEGIN + INSERT INTO @output (unitPrice) + SELECT AVG(lineTotal) as averageTotal + FROM Sales.SalesOrderDetail as SalesOrderDetail + WHERE SalesOrderDetail.ProductID = @productId + HAVING COUNT(*) > 0 + + RETURN + END +go +SELECT Product.ProductNumber, AverageSale.UnitPrice +FROM Production.Product as Product + CROSS APPLY + production.getAverageTotalPerProduct(product.productId) + as AverageSale +go + +SELECT Product.ProductNumber, AverageSale.UnitPrice +FROM Production.Product as Product + OUTER APPLY + production.getAverageTotalPerProduct(product.productId) + as AverageSale +GO + +---------------------------------------------------------------------- +-- DML Enhancements - Random Data Sampling +---------------------------------------------------------------------- + +SELECT * +FROM sales.salesOrderDetail TABLESAMPLE SYSTEM (2 PERCENT) +go +SELECT * +FROM sales.salesOrderDetail TABLESAMPLE SYSTEM (500 rows) +go +SELECT * +FROM sales.salesOrderDetail TABLESAMPLE SYSTEM (500 rows) REPEATABLE (123456) +go + +---------------------------------------------------------------------- +-- DML Enhancements - Pivoting Data +---------------------------------------------------------------------- + +CREATE TABLE sales.salesByMonth +( + year char(4), + month char(3), + amount money, + PRIMARY KEY (year, month) +) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Jan', 789.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Feb', 389.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Mar', 8867.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Apr', 778.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','May', 78.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Jun', 9.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Jul', 987.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Aug', 866.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Sep', 7787.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Oct', 85576.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Nov', 855.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2004','Dec', 5878.0000) + +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2005','Jan', 7.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2005','Feb', 6868.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2005','Mar', 688.0000) +INSERT INTO sales.salesByMonth (year, month, amount) +VALUES('2005','Apr', 9897.0000) +go + +SELECT year, + SUM(case when month = 'Jan' then amount else 0 end) AS 'Jan', + SUM(case when month = 'Feb' then amount else 0 end) AS 'Feb', + SUM(case when month = 'Mar' then amount else 0 end) AS 'Mar', + SUM(case when month = 'Apr' then amount else 0 end) AS 'Apr', + SUM(case when month = 'May' then amount else 0 end) AS 'May', + SUM(case when month = 'Jun' then amount else 0 end) AS 'Jun', + SUM(case when month = 'Jul' then amount else 0 end) AS 'Jul', + SUM(case when month = 'Aug' then amount else 0 end) AS 'Aug', + SUM(case when month = 'Sep' then amount else 0 end) AS 'Sep', + SUM(case when month = 'Oct' then amount else 0 end) AS 'Oct', + SUM(case when month = 'Nov' then amount else 0 end) AS 'Nov', + SUM(case when month = 'Dec' then amount else 0 end) AS 'Dec' +FROM sales.salesByMonth +GROUP by year +go +SELECT Year,[Jan],[Feb],[Mar],[Apr],[May],[Jun], + [Jul],[Aug],[Sep],[Oct],[Nov],[Dec] +FROM ( + SELECT year, amount, month + FROM sales.salesByMonth ) AS salesByMonth + PIVOT ( SUM(amount) FOR month IN + ([Jan],[Feb],[Mar],[Apr],[May],[Jun], + [Jul],[Aug],[Sep],[Oct],[Nov],[Dec]) + ) AS ourPivot +ORDER BY Year +go +SELECT [Jan],[Feb],[Mar],[Apr],[May],[Jun], + [Jul],[Aug],[Sep],[Oct],[Nov],[Dec] +FROM ( SELECT amount, month + FROM sales.salesByMonth ) AS salesByMonth + PIVOT ( SUM(amount) FOR month IN + ([Jan],[Feb],[Mar],[Apr],[May],[Jun], + [Jul],[Aug],[Sep],[Oct],[Nov],[Dec]) + ) AS ourPivot +go + +CREATE TABLE Person.ContactProperty +( + ContactPropertyId int identity(1,1) PRIMARY KEY, + ContactId int REFERENCES Person.Contact(ContactId), + PropertyName varchar(20), + PropertyValue sql_variant, + UNIQUE (ContactID, PropertyName) +) + +INSERT Person.ContactProperty (ContactId, PropertyName, PropertyValue) +VALUES(1,'dog name','Fido') +INSERT Person.ContactProperty (ContactId, PropertyName, PropertyValue) +VALUES(1,'hair color','brown') +INSERT Person.ContactProperty (ContactId, PropertyName, PropertyValue) +VALUES(1,'car style','sedan') + +INSERT Person.ContactProperty (ContactId, PropertyName, PropertyValue) +VALUES(2,'dog name','Rufus') +INSERT Person.ContactProperty (ContactId, PropertyName, PropertyValue) +VALUES(2,'hair color','blonde') + +INSERT Person.ContactProperty (ContactId, PropertyName, PropertyValue) +VALUES(3,'dog name','Einstein') +INSERT Person.ContactProperty (ContactId, PropertyName, PropertyValue) +VALUES(3,'car style','coupe') +go +SELECT cast(Contact.FirstName + ' ' + Contact.LastName as varchar(30)) as Name, + ContactProperty.PropertyName, ContactProperty.PropertyValue +FROM Person.Contact as Contact + INNER JOIN Person.ContactProperty as ContactProperty + ON ContactProperty.ContactId = Contact.ContactID +go + +SELECT cast(Contact.FirstName + ' ' + Contact.LastName as varchar(30)) as Name, + pivotColumns.* --demonstrating that * works, it should not + --be done this way in production code +FROM Person.Contact as Contact + INNER JOIN (SELECT ContactId, PropertyName,PropertyValue + FROM Person.ContactProperty as property) + as PivotTable + PIVOT( MAX(PropertyValue) + FOR PropertyName IN ([dog name],[hair color],[car style])) + AS PivotColumns + ON Contact.ContactId = PivotColumns.ContactId +go + +---------------------------------------------------------------------- +-- DML Enhancements - Unpivoting data +---------------------------------------------------------------------- + +SELECT Year,[Jan],[Feb],[Mar],[Apr],[May],[Jun], + [Jul],[Aug],[Sep],[Oct],[Nov],[Dec] +INTO sales.salesByYear +FROM ( + SELECT year, amount, month + FROM sales.salesByMonth ) AS salesByMonth + PIVOT ( SUM(amount) FOR month IN + ([Jan],[Feb],[Mar],[Apr],[May],[Jun], + [Jul],[Aug],[Sep],[Oct],[Nov],[Dec]) + ) AS ourPivot +ORDER BY Year +go + +SELECT Year, cast(Month as char(3)) as Month, Amount +FROM sales.salesByYear + UNPIVOT (Amount FOR Month IN + ([Jan],[Feb],[Mar],[Apr],[May],[Jun], + [Jul],[Aug],[Sep],[Oct],[Nov],[Dec])) as unPivoted +go + +---------------------------------------------------------------------- +-- DML Enhancements - Output +---------------------------------------------------------------------- + +BEGIN TRANSACTION + +DECLARE @changes table (change varchar(2000)) + +UPDATE TOP (10) Person.Contact +SET FirstName = Reverse(FirstName) +OUTPUT 'Was: ''' + DELETED.FirstName + + ''' Is: ''' + INSERTED.FirstName + '''' +INTO @changes + +SELECT * +FROM @changes + +ROLLBACK TRANSACTION + +---------------------------------------------------------------------- +-- DML Enhancements - Ranking functions +---------------------------------------------------------------------- +CREATE VIEW contactSubset +as + Select TOP 20 * + FROM Person.Contact + WHERE FirstName like 'b%' +go + +SELECT FirstName, + ( SELECT count(*) + FROM contactSubset as c + WHERE c.FirstName < contactSubset.FirstName) + 1 as RANK +FROM contactSubset +ORDER BY FirstName +go + +SELECT FirstName, LastName, + ( SELECT count(*) + FROM contactSubset as c + WHERE c.LastName < contactSubset.LastName + OR (c.LastName = contactSubset.LastName + AND c.FirstName< contactSubset.FirstName) + ) + 1 as orderNumber +FROM contactSubset +ORDER BY LastName, FirstName +GO +SELECT FirstName, + ROW_NUMBER() over (order by FirstName) as 'ROW_NUMBER', + RANK() over (order by FirstName) as 'RANK', + DENSE_RANK() over (order by FirstName) as 'DENSE_RANK', + NTILE(4) over (order by FirstName) as 'NTILE(4)' +FROM contactSubSet +ORDER BY FirstName +GO +SELECT FirstName, LastName, + ROW_NUMBER() over (order by FirstName, LastName) as 'ROW_NUMBER', + RANK() over (order by FirstName,LastName) as 'RANK', + DENSE_RANK() over (order by FirstName,LastName) as 'DENSE_RANK', + NTILE(4) over (order by FirstName,LastName) as 'NTILE(4)' +FROM contactSubSet +ORDER BY FirstName +GO +SELECT firstName, + ROW_NUMBER() over (order by FirstName) as ascending, + ROW_NUMBER() over (order by FirstName desc) as descending +FROM contactSubSet +ORDER BY FirstName +GO +SELECT FirstName, LastName, + ROW_NUMBER()over ( partition by FirstName order by lastName) as + 'ROW_NUMBER', + RANK()over ( partition by FirstName order by LastName) as 'RANK', + DENSE_RANK()over ( partition by FirstName order by LastName) as + 'DENSE_RANK', + NTILE(2) over ( partition by FirstName order by LastName) as + 'NTILE(2)' +FROM contactSubSet +ORDER BY FirstName +GO +WITH salesSubset AS +( + SELECT product.name as product, sum(salesOrderDetail.lineTotal) as total + FROM sales.salesOrderDetail as salesOrderDetail + JOIN sales.salesOrderHeader as salesOrderHeader + ON salesOrderHeader.salesOrderId = salesOrderDetail.salesOrderId + JOIN production.product as product + ON product.productId = salesOrderDetail.productId + WHERE orderDate >= '1/1/2004' and orderDate < '1/1/2005' + GROUP BY product.name +) +SELECT * +FROM (SELECT product, total, + RANK() over (order by total desc) as 'RANK', + NTILE(10) over (order by total desc) as 'NTILE(10)' + FROM salesSubset) as productOrders +WHERE [NTILE(10)] = 10 +gO + +---------------------------------------------------------------------- +-- DML Enhancements - EXCEPT and INTERSECT +---------------------------------------------------------------------- +CREATE TABLE projectPerson +( + personId VARCHAR(10), + projectId VARCHAR(10), + PRIMARY KEY (personId, projectId) +) +go + +INSERT INTO projectPerson VALUES ('joeb','projBig') +INSERT INTO projectPerson VALUES ('joeb','projLittle') +INSERT INTO projectPerson VALUES ('fredf','projBig') +INSERT INTO projectPerson VALUES ('homerr','projLittle') +INSERT INTO projectPerson VALUES ('stevegr','projBig') +INSERT INTO projectPerson VALUES ('stevegr','projLittle') +go + +SELECT personId +FROM projectPerson +WHERE projectId = 'projBig' +UNION +SELECT personId +FROM projectPerson +WHERE projectId = 'projLittle' +GO + +--worked only on projectLittle, but not projectBig +SELECT personId +FROM projectPerson as projLittle +WHERE projectId = 'projLittle' + AND NOT EXISTS ( SELECT * + FROM projectPerson as projBig + WHERE projBig.projectId = 'projBig' + and projBig.personId = projLittle.personId) +GO + +--worked only on projectLittle, but not projectBig +SELECT personId +FROM projectPerson +WHERE projectId = 'projLittle' +EXCEPT +SELECT personId +FROM projectPerson +WHERE projectId = 'projBig' +go + +--worked on both projects. +SELECT personId +FROM projectPerson +WHERE projectId = 'projBig' +INTERSECT +SELECT personId +FROM projectPerson +WHERE projectId = 'projLittle' +go + +---------------------------------------------------------------------- +-- DML Enhancements - Synonyms +---------------------------------------------------------------------- +CREATE SYNONYM Emp FOR AdventureWorks.HumanResources.Employee +go +SELECT * from Emp +go +DROP SYNONYM Emp +go +CREATE LOGIN ANDREW WITH PASSWORD = 'ANDREW1' +CREATE USER ANDREW FOR LOGIN ANDREW +go +CREATE SYNONYM synSecure FOR sales.customer +GO +CREATE VIEW viewSecure --as a contrasting example +AS +SELECT * +FROM sales.customer +GO +GRANT SELECT,INSERT,UPDATE,DELETE ON synSecure to ANDREW +GRANT SELECT,INSERT,UPDATE,DELETE ON viewSecure to ANDREW +go +EXECUTE AS LOGIN='ANDREW' +--returns permission error +SELECT * from sales.customer +go +SELECT * from viewSecure +SELECT * from synSecure +go +revert --not in text, reverts back to security context of primary user + +---------------------------------------------------------------------- +-- General Development Enhancements - Error Handling +---------------------------------------------------------------------- +CREATE SCHEMA Entertainment + CREATE TABLE TV + ( + TVid int primary key, + location varchar(20), + diagonalWidth int + CONSTRAINT CKEntertainment_tv_checkWidth CHECK (diagonalWidth >= 30) + ) + +go + +CREATE TABLE dbo.error_log --(adventureworks already has their own error log table) +( + tableName sysname, + userName sysname, + errorNumber int, + errorSeverity int, + errorState int, + errorMessage varchar(4000) +) +GO + +CREATE PROCEDURE entertainment.tv$insert +( + @TVid int, + @location varchar(30), + @diagonalWidth int +) +AS +declare @Error int + + BEGIN TRANSACTION + + --Insert a row + INSERT entertainment.TV (TVid, location, diagonalWidth) + VALUES(@TVid, @location, @diagonalWidth) + + --save @@ERROR so we don't lose it. + SET @Error=@@ERROR + IF @Error<>0 + BEGIN + -- an error has occurred + GOTO ErrorHandler + END + + COMMIT TRANSACTION + +GOTO ExitProc + +ErrorHandler: + -- Rollback the transaction + ROLLBACK TRANSACTION + -- log the error into the errorlog table + INSERT dbo.error_log (tableName, userName, + errorNumber, errorSeverity ,errorState , + errorMessage) + VALUES('TV',suser_sname(),@Error,0,0,'We do not know the message!') +select * from dbo.errorlog + +ExitProc: +GO +exec entertainment.tv$insert @TVid = 1, @location = 'Bed Room', @diagonalWidth = 29 +go +SELECT * FROM dbo.error_log +go +BEGIN TRY + RAISERROR ('Something is amiss',16,1) +END TRY +BEGIN CATCH + select ERROR_NUMBER() as ERROR_NUMBER, + ERROR_SEVERITY() as ERROR_SEVERITY, + ERROR_STATE() as ERROR_STATE, + ERROR_MESSAGE() as ERROR_MESSAGE +END CATCH +go +DELETE FROM entertainment.TV --in case you have added rows +DELETE FROM dbo.error_log +go + +ALTER PROCEDURE entertainment.tv$insert +( + @TVid int, + @location varchar(30), + @diagonalWidth int +) +AS + SET NOCOUNT ON + BEGIN TRY + BEGIN TRANSACTION + INSERT TV (TVid, location, diagonalWidth) + VALUES(@TVid, @location, @diagonalWidth) + COMMIT TRANSACTION + END TRY + BEGIN CATCH + ROLLBACK TRANSACTION + INSERT dbo.error_log (tableName, userName, + errorNumber, errorSeverity ,errorState , + errorMessage) + VALUES('TV',suser_sname(),ERROR_NUMBER(), + ERROR_SEVERITY(), ERROR_STATE(), ERROR_MESSAGE()) + RAISERROR ('Error creating new TV row',16,1) + END CATCH +GO + +exec entertainment.tv$insert @TVid = 1, @location = 'Bed Room', + @diagonalWidth = 29 +GO +SELECT * FROM dbo.error_log +GO + +CREATE PROCEDURE dbo.raise_an_error +AS + BEGIN + BEGIN TRY + raiserror ('Boom, boom, boom, boom',16,1) + END TRY + BEGIN CATCH --just catch it, return it as a select, + --and raise another error + SELECT ERROR_NUMBER() AS ErrorNumber, + ERROR_SEVERITY() AS ErrorSeverity, + ERROR_STATE() as ErrorState, ERROR_LINE() as ErrorLine, + ERROR_PROCEDURE() as ErrorProcedure, + ERROR_MESSAGE() as ErrorMessage + RAISERROR ('Error in procedure raise_an_error',16,1) + END CATCH + END +go +SET NOCOUNT ON +BEGIN TRY + exec raise_an_error --@no_parm = 1 (we will uncomment this for a test + select 'I am never getting here' +END TRY +BEGIN CATCH + SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_SEVERITY() AS ErrorSeverity, + ERROR_STATE() as ErrorState, ERROR_LINE() as ErrorLine, + cast(ERROR_PROCEDURE() as varchar(30)) as ErrorProcedure, + cast(ERROR_MESSAGE() as varchar(40))as ErrorMessage +END CATCH +go +SET NOCOUNT ON +BEGIN TRY + exec raise_an_error @no_parm = 1 + select 'hi' +END TRY +BEGIN CATCH +END CATCH +go +SET NOCOUNT ON +BEGIN TRY + exeec procedure --error here is on purpose! + +END TRY +BEGIN CATCH +END CATCH +go +SET NOCOUNT ON +BEGIN TRY + exec ('seeelect *') + +END TRY +BEGIN CATCH + SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_SEVERITY() AS ErrorSeverity, + ERROR_STATE() as ErrorState, ERROR_LINE() as ErrorLine, + cast(ERROR_PROCEDURE() as varchar(60)) as ErrorProcedure, + cast(ERROR_MESSAGE() as varchar(550))as ErrorMessage +END CATCH +go + +ALTER PROCEDURE entertainment.tv$insert +( + @TVid int, + @location varchar(30), + @diagonalWidth int +) +AS + SET NOCOUNT ON + DECLARE @errorMessage varchar(2000) + BEGIN TRY + BEGIN TRANSACTION + SET @errorMessage = 'Error inserting TV with diagonalWidth / 1' + INSERT TV (TVid, location, diagonalWidth) + VALUES(@TVid, @location, @diagonalWidth) + + --second insert: + SET @errorMessage = 'Error inserting TV with diagonalWidth / 2' + INSERT TV (TVid, location, diagonalWidth) + VALUES(@TVid, @location, @diagonalWidth / 2 ) + + COMMIT TRANSACTION + END TRY + BEGIN CATCH + ROLLBACK TRANSACTION + INSERT dbo.error_log VALUES('TV',suser_sname(), + ERROR_NUMBER(),ERROR_SEVERITY(), + ERROR_STATE(), ERROR_MESSAGE()) + RAISERROR (@errorMessage,16,1) + END CATCH +GO + +exec entertainment.tv$insert @TVid = 10, @location = 'Bed Room', + @diagonalWidth = 29 + +exec entertainment.tv$insert @TVid = 11, @location = 'Bed Room', + @diagonalWidth = 60 + +---------------------------------------------------------------------- +-- General Development Enhancements - .WRITE Extension to the UPDATE Statement +---------------------------------------------------------------------- + +create table testBIGtext +( + testBIGtextId int PRIMARY KEY, + value varchar(max) +) +insert into testBIGtext +values(1,'') +go + +DECLARE @offset int +SET @offset = 0 +WHILE @offset < 26 + BEGIN + UPDATE testBIGtext + --the text I am writing is just starting at the letter A --> char(97) + --and increasing. the offset is the how may we are in the loop + --times the number of bytes we are putting in the string, and again + --the length of the data we are writing + SET value.write(replicate(char(97 + @offset),1000),@offset*1000, 1000) + WHERE testBIGTextId = 1 + + SET @offset = @offset + 1 + END +go +select testBIGtextId, len(value) as CharLength +from testBIGtext +go + +---------------------------------------------------------------------- +-- General Development Enhancements - EXECUTE +---------------------------------------------------------------------- + +--note, if you are not running SQL Server as the default instance, you may +--have to change where I have specified localhost to point to your server instance +EXECUTE sp_addlinkedserver @server='LocalLinkedServer', @srvproduct='', + @provider='SQLOLEDB', @datasrc='.\yukon' + +EXECUTE sp_serveroption 'LocalLinkedServer','RPC OUT',True +go +EXECUTE('SELECT * FROM AdventureWorks.Production.Culture') AT LocalLinkedServer + +EXECUTE sp_dropserver LocalLinkedServer +---------------------------------------------------------------------- +-- General Development Enhancements - Code security enhancements +---------------------------------------------------------------------- + +--this user will be the owner of the primary schema +CREATE LOGIN mainOwner WITH PASSWORD = 'mainOwnery' +CREATE USER mainOwner FOR LOGIN mainOwner +GRANT CREATE SCHEMA to mainOwner +GRANT CREATE TABLE to mainOwner + +--this will be the procedure creator +CREATE LOGIN secondaryOwner WITH PASSWORD = 'secondaryOwnery' +CREATE USER secondaryOwner FOR LOGIN secondaryOwner +GRANT CREATE SCHEMA to secondaryOwner +GRANT CREATE PROCEDURE to secondaryOwner +GRANT CREATE TABLE to secondaryOwner + +--this will be the average user who needs to access data +CREATE LOGIN aveSchlub WITH PASSWORD = 'aveSchluby' +CREATE USER aveSchlub FOR LOGIN aveSchlub +go +EXECUTE AS USER='mainOwner' +Go +CREATE SCHEMA mainOwnersSchema +GO +CREATE TABLE mainOwnersSchema.person +( + personId int constraint PKtestAccess_person primary key, + firstName varchar(20), + lastName varchar(20) +) +GO + +INSERT INTO mainOwnersSchema.person +VALUES (1, 'Paul','McCartney') +INSERT INTO mainOwnersSchema.person +VALUES (2, 'Pete','Townshend') +GO +GRANT SELECT on mainOwnersSchema.person to secondaryOwner +REVERT --we can step back on the stack of principals, + --but we can't change directly to secondaryOwner +go +EXECUTE AS USER = 'secondaryOwner' +go + +CREATE SCHEMA secondaryOwnerSchema +GO +CREATE TABLE secondaryOwnerSchema.otherPerson +( + personId int constraint PKtestAccess_person primary key, + firstName varchar(20), + lastName varchar(20) +) +GO + +INSERT INTO secondaryOwnerSchema.otherPerson +VALUES (1, 'Rocky','Racoon') +INSERT INTO secondaryOwnerSchema.otherPerson +VALUES (2, 'Sally','Simpson') +GO +CREATE PROCEDURE secondaryOwnerSchema.person$asCaller +WITH EXECUTE AS CALLER --this is the default +AS +SELECT personId, firstName, lastName +FROM secondaryOwnerSchema.otherPerson --<-- ownership same as proc +SELECT personId, firstName, lastName +FROM mainOwnersSchema.person --<-- breaks ownership chain +GO + +CREATE PROCEDURE secondaryOwnerSchema.person$asSelf +WITH EXECUTE AS SELF --now this runs in context of secondaryOwner, + --since it created it +AS +SELECT personId, firstName, lastName +FROM secondaryOwnerSchema.otherPerson --<-- ownership same as proc + +SELECT personId, firstName, lastName +FROM mainOwnersSchema.person --<-- breaks ownership chain +GO +GRANT EXECUTE ON secondaryOwnerSchema.person$asCaller to aveSchlub +GRANT EXECUTE ON secondaryOwnerSchema.person$asSelf to aveSchlub +go +REVERT +GO +EXECUTE AS USER = 'aveSchlub' +GO +--this proc is in contet of the caller, in this case, aveSchlub +execute secondaryOwnerSchema.person$asCaller +go +--secondaryOwner, so it works +execute secondaryOwnerSchema.person$asSelf + +o a \ No newline at end of file diff --git a/1590594770-1/Chapter04/01_MetaData.SQL b/1590594770-1/Chapter04/01_MetaData.SQL new file mode 100644 index 0000000..cc2d41d --- /dev/null +++ b/1590594770-1/Chapter04/01_MetaData.SQL @@ -0,0 +1,22 @@ +--Find all columns for all tables + +SELECT + t.name AS theTable, + c.name AS theColumn, + ty.name AS theType +FROM sys.tables t +JOIN sys.columns c ON t.object_id = c.object_id +JOIN sys.types ty ON c.system_type_id = ty.system_type_id + + + +--Find all tables without clustered indexes + + +SELECT + OBJECT_NAME(object_id) AS theTable +FROM sys.indexes +WHERE + type_desc = 'HEAP' + + diff --git a/1590594770-1/Chapter04/02_DDLTriggers.SQL b/1590594770-1/Chapter04/02_DDLTriggers.SQL new file mode 100644 index 0000000..421e6a7 --- /dev/null +++ b/1590594770-1/Chapter04/02_DDLTriggers.SQL @@ -0,0 +1,100 @@ + +--Disallow schema changes in the current database + +CREATE TRIGGER NoChanges +ON DATABASE +FOR DDL_DATABASE_LEVEL_EVENTS +AS + SELECT 'DDL IS NOT ALLOWED IN THE CURRENT DATABASE!' + SELECT 'TO ALLOW DDL, DROP THE NoChanges trigger.' + ROLLBACK + + + +--Find all DDL triggers in the current database + +SELECT + name, + create_date +FROM sys.triggers +WHERE parent_class_desc = 'DATABASE' + + + + +--Find all active triggers in the current database + +SELECT + tr.name, + ev.type_desc +FROM sys.server_triggers tr +JOIN sys.server_trigger_events ev ON tr.object_id = ev.object_id +WHERE tr.is_disabled = 0 + + + + +--Return event information from a DDL trigger + +CREATE TRIGGER ReturnEventData +ON DATABASE +FOR CREATE_TABLE, ALTER_TABLE +AS + DECLARE @eventData XML + SET @eventData = eventdata() + + SELECT + @eventData.query('data(/EVENT_INSTANCE/UserName)') AS UserName, + @eventData.query('data(/EVENT_INSTANCE/ObjectName)') AS ObjectName, + @eventData.query('data(/EVENT_INSTANCE/TSQLCommand/CommandText)') AS CommandText + + + +--Log event information in a DDL trigger + +CREATE TABLE DDLEventLog +( + EventDate DATETIME NOT NULL, + UserName SYSNAME NOT NULL, + ObjectName SYSNAME NOT NULL, + CommandText VARCHAR(MAX) NOT NULL +) +GO + +CREATE TRIGGER ReturnEventData +ON DATABASE +FOR CREATE_TABLE, ALTER_TABLE +AS + DECLARE @eventData XML + SET @eventData = eventdata() + + INSERT DDLEventLog (EventDate, UserName, ObjectName, CommandText) + SELECT + GETDATE() AS EventDate, + @eventData.value('data(/EVENT_INSTANCE/UserName)[1]', 'SYSNAME') + AS UserName, + @eventData.value('data(/EVENT_INSTANCE/ObjectName)[1]', 'SYSNAME') + AS ObjectName, + @eventData.value('data(/EVENT_INSTANCE/TSQLCommand/CommandText)[1]', + 'VARCHAR(MAX)') AS CommandText + + + + +--Keep a certain object from being dropped +CREATE TRIGGER DontDropDontDropMe +ON DATABASE +FOR DROP_TABLE +AS + DECLARE @eventData XML + SET @eventData = eventdata() + + DECLARE @objectName VARCHAR(MAX) + SET @objectName = + CONVERT(VARCHAR(MAX), @eventData.query('data(/EVENT_INSTANCE/ObjectName)')) + + IF @objectName = 'DontDropMe' + BEGIN + PRINT 'You can not drop DontDropMe!' + ROLLBACK + END diff --git a/1590594770-1/Chapter04/03_Indexes.SQL b/1590594770-1/Chapter04/03_Indexes.SQL new file mode 100644 index 0000000..76354cc --- /dev/null +++ b/1590594770-1/Chapter04/03_Indexes.SQL @@ -0,0 +1,150 @@ +--Create an index online + +CREATE INDEX ix_Table +ON Table (Column) +WITH (ONLINE = ON) + + + + +--Create an index, disallowing row-level locks + +CREATE INDEX ix_Table +ON Table (Column) +WITH (ALLOW_ROW_LOCKS = OFF) + + + + +--Create an index, disallowing page-level locks + +CREATE INDEX ix_Table +ON Table (Column) +WITH (ALLOW_PAGE_LOCKS = OFF) + + + + +--Create an index online, disallowing page and row-level locks + +CREATE INDEX ix_Table +ON Table (Column) +WITH (ONLINE = ON, ALLOW_ROW_LOCKS = OFF, ALLOW_PAGE_LOCKS = OFF) + + + + +--Create a test table for included indexes + +CREATE TABLE DatabaseSystems +( + DatabaseSystemId INT, + Name VARCHAR(35), + IsRelational CHAR(1), + IsObjectOriented CHAR(1), + SupportsXML CHAR(1), + FullSpecifications VARCHAR(MAX) +) + +CREATE NONCLUSTERED INDEX IX_Name +ON DatabaseSystems (Name) + + + + + +--Test query for observing execution plans for the DatabaseSystems table + + +SELECT Name, SupportsXML +FROM DatabaseSystems +WHERE Name LIKE ‘S%’ +AND SupportsXML = ‘Y’ + + + + +--Typical covering index + +DROP INDEX IX_Name +CREATE NONCLUSTERED INDEX IX_Name_SupportsXML +ON DatabaseSystems(Name, SupportsXML) + + + + +--Index including one non-key column + +CREATE UNIQUE NONCLUSTERED INDEX IX_Name +ON DatabaseSystems(Name) +INCLUDE (SupportsXML) + + + + +--Index including two non-key columns + +CREATE UNIQUE NONCLUSTERED INDEX IX_Name +ON DatabaseSystems(Name) +INCLUDE (SupportsXML, FullSpecifications) + + + + + +--Find fragmented indexes + +SELECT + OBJECT_NAME(i.object_id) AS TableName, + i.name AS IndexName, + ips.avg_fragmentation_in_percent +FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'DETAILED') ips +JOIN sys.indexes i ON + i.object_id = ips.object_id + AND i.index_id = ips.index_id +WHERE ips.avg_fragmentation_in_percent > 10 + + + + +--Defragment an index + +ALTER INDEX IX_CustomerName +ON Customers +REORGANIZE + + + + + +--Rebuild an index + +ALTER INDEX IX_CustomerName +ON Customers +REBUILD +WITH (ONLINE=ON) + + + + + +--Disable an index + +ALTER INDEX IX_CustomerName +ON Customers +DISABLE + + + + + +--Re-enable an index + +ALTER INDEX IX_CustomerName +ON Customers +REBUILD + + + + + diff --git a/1590594770-1/Chapter04/04_DateCorrelation.SQL b/1590594770-1/Chapter04/04_DateCorrelation.SQL new file mode 100644 index 0000000..bb5076e --- /dev/null +++ b/1590594770-1/Chapter04/04_DateCorrelation.SQL @@ -0,0 +1,16 @@ +--Enable date correlation optimization + +ALTER DATABASE AdventureWorks +SET DATE_CORRELATION_OPTIMIZATION ON + + + + + +--Determine whether date correlation optimization is turned on + +SELECT + Name, + is_date_correlation_on +FROM sys.databases + diff --git a/1590594770-1/Chapter04/05_TertiaryCollation.SQL b/1590594770-1/Chapter04/05_TertiaryCollation.SQL new file mode 100644 index 0000000..ca4eea7 --- /dev/null +++ b/1590594770-1/Chapter04/05_TertiaryCollation.SQL @@ -0,0 +1,17 @@ + +--Using the TERTIARY_WEIGHTS function to make sorts on tertiary collations more efficient + +CREATE TABLE Characters +( + CharacterString CHAR(3) + COLLATE SQL_Latin1_General_CP437_CI_AI, + CharacterWeights AS (TERTIARY_WEIGHTS(CharacterString)) +) + + +CREATE CLUSTERED INDEX IX_Characters +ON Characters +( + CharacterString, + CharacterWeights +) diff --git a/1590594770-1/Chapter04/06_Partitions.SQL b/1590594770-1/Chapter04/06_Partitions.SQL new file mode 100644 index 0000000..7c5e127 --- /dev/null +++ b/1590594770-1/Chapter04/06_Partitions.SQL @@ -0,0 +1,188 @@ +--Creating a partition function + +CREATE PARTITION FUNCTION pf_FiscalQuarter2005 (DATETIME) +AS RANGE RIGHT FOR VALUES +('20050401', '20050701', '20051001', '20060101') + + + + + +--Creating a partition scheme, mapping all partitions to PRIMARY + +CREATE PARTITION SCHEME ps_FiscalQuarter2005_PRIMARY +AS PARTITION pf_FiscalQuarter2005 +ALL TO ([PRIMARY]) + + + + + +--Another partition scheme, mapping partitions to different filegroups + +CREATE PARTITION SCHEME ps_FiscalQuarter2005_Split +AS PARTITION pf_FiscalQuarter2005 +TO (Q1Q2_2005, Q1Q2_2005, Q3Q4_2005, Q3Q4_2005, Q3Q4_2005) + + + + + +--Creating a partitioned table + +CREATE TABLE SalesAmounts +( + SalesAmountId INT NOT NULL PRIMARY KEY NONCLUSTERED, + SalesAmount NUMERIC(9,2) NOT NULL, + SalesDate DATETIME NOT NULL +) +GO + +CREATE CLUSTERED INDEX IX_SalesAmounts_SalesDate +ON SalesAmounts (SalesDate) + ON ps_FiscalQuarter2005_Split (SalesDate) + + + + + +--Creating a partitioned index + +CREATE INDEX IX_Amount +ON SalesAmounts +( + SalesAmount +) +ON ps_FiscalQuarter2005_PRIMARY (SalesDate) + + + + + +--Creating the Visitors table + +CREATE TABLE Visitors +( + VisitorId INT NOT NULL, + VisitDate DATETIME NOT NULL, + CONSTRAINT PK_Visitors + PRIMARY KEY (VisitorId, VisitDate) +) + + + + + +--Modifying the partition scheme on the Visitors table + +SET XACT_ABORT ON + +BEGIN TRANSACTION + ALTER TABLE Visitors + DROP CONSTRAINT PK_Visitors + + ALTER TABLE Visitors + ADD CONSTRAINT PK_Visitors + PRIMARY KEY (VisitorId, VisitDate) + ON ps_FiscalQuarter2005_Split (VisitDate) +COMMIT + + + + + +--Merging a partition range + +ALTER PARTITION FUNCTION +pf_FiscalQuarter2005() +MERGE RANGE ('20051001') + + + + + +--Altering a partition scheme + +ALTER PARTITION SCHEME ps_FiscalQuarter2005_Split +NEXT USED [PRIMARY] + + + + + +--Altering the partition function + +ALTER PARTITION FUNCTION +pf_FiscalQuarter2005() +SPLIT RANGE ('20070101') + + + + + +--Creating the VisitorStaging_2006 table + +CREATE TABLE VisitorStaging_2006 +( + VisitorId INT NOT NULL, + VisitDate DATETIME NOT NULL +) + + + + +--The table must have the same PK as the partitioned table + +ALTER TABLE VisitorStaging_2006 +ADD CONSTRAINT PK_Visitors_2006 + PRIMARY KEY (VisitorId, VisitDate) + + + + + +--Must also create a CHECK constraint to make sure no invalid data is inserted + +ALTER TABLE VisitorStaging_2006 +ADD CONSTRAINT CK_Visitors_06012006_12012007 + CHECK (VisitDate >= '20060101' AND VisitDate < '20070101') + + + + + +--Find the next boundary + +SELECT rv.boundary_id +FROM sys.partition_functions f +JOIN sys.partition_range_values rv ON f.function_id = rv.function_id +WHERE rv.value = CONVERT(datetime, '20070101') + AND f.name = 'pf_FiscalQuarter2005' + + + + +--Switch in the new partition + +ALTER TABLE VisitorStaging_2006 +SWITCH TO Visitors PARTITION 4 + + + + +--Switch out the partition + +ALTER TABLE Visitors +SWITCH PARTITION 4 TO VisitorStaging_2006 + + + + + +--Rebuild only one partition + +ALTER INDEX PK_Visitors +ON Visitors +REBUILD +PARTITION = 4 + diff --git a/1590594770-1/Chapter04/06_TablesAndViews.SQL b/1590594770-1/Chapter04/06_TablesAndViews.SQL new file mode 100644 index 0000000..7623a9f --- /dev/null +++ b/1590594770-1/Chapter04/06_TablesAndViews.SQL @@ -0,0 +1,40 @@ + +--Creating an indexed view with an expression + +CREATE VIEW Sales.OrderTotals +WITH SCHEMABINDING +AS + SELECT + SalesOrderId, + SubTotal + TaxAmt + Freight AS OrderTotal + FROM Sales.SalesOrderHeader +GO + +CREATE UNIQUE CLUSTERED INDEX IX_OrderTotals +ON Sales.OrderTotals +(OrderTotal, SalesOrderId) + + + + +--Persisting a computed column + +ALTER TABLE SalesData + ADD ComplexOutput AS + (dbo.VeryComplexFunction(CustomerId, OrderId)) + PERSISTED + + + + + +--Find all persisted columns + +SELECT OBJECT_NAME(object_id), name +FROM sys.computed_columns +WHERE is_persisted = 1 + + + + + diff --git a/1590594770-1/Chapter04/07_SNAPSHOT_Isolation.SQL b/1590594770-1/Chapter04/07_SNAPSHOT_Isolation.SQL new file mode 100644 index 0000000..b0aa510 --- /dev/null +++ b/1590594770-1/Chapter04/07_SNAPSHOT_Isolation.SQL @@ -0,0 +1,109 @@ +--Enabling SNAPSHOT isolation + +ALTER DATABASE Sales +SET ALLOW_SNAPSHOT_ISOLATION ON + + + + +--Enabling READ COMMITTED SNAPSHOT + +ALTER DATABASE Sales +SET READ_COMMITTED_SNAPSHOT ON + + + + +--Disabling SNAPSHOT isolation + +ALTER DATABASE Sales +SET ALLOW_SNAPSHOT_ISOLATION OFF + + + + +--Determining which databases have SNAPSHOT isolation enabled + +SELECT + name, + snapshot_isolation_state, + is_read_committed_snapshot_on +FROM sys.databases + + + + + +--Create a table to test SNAPSHOT isolation + +CREATE TABLE TestSnapshot +( + ColA INT, + ColB VARCHAR(20) +) + +INSERT TestSnapshot (ColA, ColB) +VALUES (1, 'Original Value') + + + + + +--Begin a SNAPSHOT transaction on one connection + +SET TRANSACTION ISOLATION LEVEL SNAPSHOT + +BEGIN TRANSACTION + +SELECT ColB +FROM TestSnapshot +WHERE ColA = 1 + + + + + +--In another connection, the following UPDATE is issued: + +UPDATE TestSnapshot +SET ColB = 'New Value' +WHERE ColA = 1 + + + + + +--Selecting into a temp table in a SNAPSHOT transaction + +SET TRANSACTION ISOLATION LEVEL SNAPSHOT + +BEGIN TRANSACTION + +SELECT ColB +INTO #Temp +FROM TestSnapshot +WHERE ColA = 1 + + + + +--Updating the table, after the select, on another connection + +UPDATE TestSnapshot +SET ColB = 'New Value' +WHERE ColA = 1 + + + + + +--Back in the first connection, an error will occur + +UPDATE TestSnapshot +SET ColB = 'Even Newer Value' +WHERE ColA = 1 + + + + + diff --git a/1590594770-1/Chapter04/08_DB_SNAPSHOT.SQL b/1590594770-1/Chapter04/08_DB_SNAPSHOT.SQL new file mode 100644 index 0000000..2f86c09 --- /dev/null +++ b/1590594770-1/Chapter04/08_DB_SNAPSHOT.SQL @@ -0,0 +1,19 @@ +--Create a database snapshot + +CREATE DATABASE Sales_Snapshot_20050901 +ON + (NAME = SalesPrimary, + FILENAME = 'F:\Data\SalesPrimary_20040901.ss'), + (NAME = SalesPrimary_01, + FILENAME = 'F:\Data\SalesPrimary_01_20040901.ss') +AS SNAPSHOT OF Sales + + + + + +--Restore from a database snapshot + +RESTORE DATABASE Sales +FROM + DATABASE_SNAPSHOT = Sales_Snapshot_20050901 diff --git a/1590594770-1/Chapter04/09_Integrity.SQL b/1590594770-1/Chapter04/09_Integrity.SQL new file mode 100644 index 0000000..df5e4a7 --- /dev/null +++ b/1590594770-1/Chapter04/09_Integrity.SQL @@ -0,0 +1,21 @@ + +--Determine which databases have page verify checksum turned on + +SELECT name, page_verify_option +FROM sys.databases + + + + +--Put a database into emergency mode + +ALTER DATABASE Sales +SET EMERGENCY + + + + +--Put a database back online + +ALTER DATABASE Sales +SET ONLINE diff --git a/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.sln b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.sln new file mode 100644 index 0000000..0da31d4 --- /dev/null +++ b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProSQLServer2005_Chapter5", "ProSQLServer2005_Chapter5\ProSQLServer2005_Chapter5.csproj", "{70BBCA82-44BA-488A-837C-F87DF0A0E0F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {70BBCA82-44BA-488A-837C-F87DF0A0E0F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70BBCA82-44BA-488A-837C-F87DF0A0E0F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70BBCA82-44BA-488A-837C-F87DF0A0E0F5}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {70BBCA82-44BA-488A-837C-F87DF0A0E0F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70BBCA82-44BA-488A-837C-F87DF0A0E0F5}.Release|Any CPU.Build.0 = Release|Any CPU + {70BBCA82-44BA-488A-837C-F87DF0A0E0F5}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.suo b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.suo new file mode 100644 index 0000000..903b425 Binary files /dev/null and b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.suo differ diff --git a/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/GetSalesPerTerritoryByMonth.cs b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/GetSalesPerTerritoryByMonth.cs new file mode 100644 index 0000000..aea8fe2 --- /dev/null +++ b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/GetSalesPerTerritoryByMonth.cs @@ -0,0 +1,106 @@ +using System; +using System.Data; +using System.Data.Sql; +using Microsoft.SqlServer.Server; +using System.Data.SqlTypes; +using System.Data.SqlClient; + + +public partial class StoredProcedures +{ + [SqlProcedure] + public static void GetSalesPerTerritoryByMonth(SqlDateTime StartDate, + SqlDateTime EndDate) + { + //Get a SqlCommand object + SqlCommand command = new SqlCommand(); + + //Use the context connection + command.Connection = new SqlConnection("Context connection=true"); + command.Connection.Open(); + + //Define the T-SQL to execute + string sql = + "SELECT DISTINCT " + + "CONVERT(CHAR(7), h.OrderDate, 120) AS YYYY_MM " + + "FROM Sales.SalesOrderHeader h " + + "WHERE h.OrderDate BETWEEN @StartDate AND @EndDate " + + "ORDER BY YYYY_MM"; + command.CommandText = sql.ToString(); + + //Assign the StartDate and EndDate parameters + SqlParameter param = + command.Parameters.Add("@StartDate", SqlDbType.DateTime); + param.Value = StartDate; + param = command.Parameters.Add("@EndDate", SqlDbType.DateTime); + param.Value = EndDate; + + //Get the data + SqlDataReader reader = command.ExecuteReader(); + + //Get a StringBuilder object + System.Text.StringBuilder yearsMonths = new System.Text.StringBuilder(); + + //Loop through each row in the reader, adding the value to the StringBuilder + while (reader.Read()) + { + yearsMonths.Append("[" + (string)reader["YYYY_MM"] + "], "); + } + + //Close the reader + reader.Close(); + + if (yearsMonths.Length > 0) + { + //Remove the final comma in the list + yearsMonths.Remove(yearsMonths.Length - 2, 1); + } + else + { + command.CommandText = + "RAISERROR('No data present for the input date range.', 16, 1)"; + try + { + SqlContext.Pipe.ExecuteAndSend(command); + } + catch + { + return; + } + } + + //Define the cross-tab query + sql = + "SELECT TerritoryId, " + + yearsMonths.ToString() + + "FROM " + + "(" + + "SELECT " + + "TerritoryId, " + + "CONVERT(CHAR(7), h.OrderDate, 120) AS YYYY_MM, " + + "d.LineTotal " + + "FROM Sales.SalesOrderHeader h " + + "JOIN Sales.SalesOrderDetail d " + + "ON h.SalesOrderID = d.SalesOrderID " + + "WHERE h.OrderDate BETWEEN @StartDate AND @EndDate " + + ") p " + + "PIVOT " + + "( " + + "SUM (LineTotal) " + + "FOR YYYY_MM IN " + + "( " + + yearsMonths.ToString() + + ") " + + ") AS pvt " + + "ORDER BY TerritoryId"; + + //Set the CommandText + command.CommandText = sql.ToString(); + + //Have the caller execute the cross-tab query + SqlContext.Pipe.ExecuteAndSend(command); + + //Close the connection + command.Connection.Close(); + } +}; diff --git a/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.csproj b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.csproj new file mode 100644 index 0000000..406d4b7 --- /dev/null +++ b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.csproj @@ -0,0 +1,55 @@ + + + + Debug + AnyCPU + {c252feb5-a946-4202-b1d4-9916a0590387};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 8.0.50727 + 2.0 + {70BBCA82-44BA-488A-837C-F87DF0A0E0F5} + Library + false + ProSQLServer2005_Chapter5 + ProSQLServer2005_Chapter5 + + + true + full + false + bin\Debug\ + false + DEBUG;TRACE + 4 + + + false + true + bin\Release\ + false + TRACE + 4 + + + + + + + + + + + + + + + Content + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.csproj.user b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.csproj.user new file mode 100644 index 0000000..9c873c8 --- /dev/null +++ b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5.csproj.user @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/Properties/AssemblyInfo.cs b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4a6f53f --- /dev/null +++ b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Data.Sql; + +// 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. +[assembly: AssemblyTitle("ProSQLServer2005_Chapter5")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ProSQLServer2005_Chapter5")] +[assembly: AssemblyCopyright("Copyright © 2005")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +// +// 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 Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] + diff --git a/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/Test Scripts/Test.sql b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/Test Scripts/Test.sql new file mode 100644 index 0000000..8210d2f --- /dev/null +++ b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/Test Scripts/Test.sql @@ -0,0 +1,35 @@ +-- Examples for queries that exercise different SQL objects implemented by this assembly + +----------------------------------------------------------------------------------------- +-- Stored procedure +----------------------------------------------------------------------------------------- +-- exec StoredProcedureName + + +----------------------------------------------------------------------------------------- +-- User defined function +----------------------------------------------------------------------------------------- +-- select dbo.FunctionName() + + +----------------------------------------------------------------------------------------- +-- User defined type +----------------------------------------------------------------------------------------- +-- CREATE TABLE test_table (col1 UserType) +-- go +-- +-- INSERT INTO test_table VALUES (convert(uri, 'Instantiation String 1')) +-- INSERT INTO test_table VALUES (convert(uri, 'Instantiation String 2')) +-- INSERT INTO test_table VALUES (convert(uri, 'Instantiation String 3')) +-- +-- select col1::method1() from test_table + + + +----------------------------------------------------------------------------------------- +-- User defined type +----------------------------------------------------------------------------------------- +-- select dbo.AggregateName(Column1) from Table1 + + +select 'To run your project, please edit the Test.sql file in your project. This file is located in the Test Scripts folder in the Solution Explorer.' diff --git a/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/obj/ProSQLServer2005_Chapter5.csproj.FileList.txt b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/obj/ProSQLServer2005_Chapter5.csproj.FileList.txt new file mode 100644 index 0000000..7c8486c --- /dev/null +++ b/1590594770-1/Chapter05/ProSQLServer2005_Chapter5/ProSQLServer2005_Chapter5/obj/ProSQLServer2005_Chapter5.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\ProSQLServer2005_Chapter5.dll +bin\Debug\ProSQLServer2005_Chapter5.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\ProSQLServer2005_Chapter5.dll +obj\Debug\ProSQLServer2005_Chapter5.pdb diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.sln b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.sln new file mode 100644 index 0000000..53ab339 --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProSQLServer2005_Chapter6", "ProSQLServer2005_Chapter6\ProSQLServer2005_Chapter6.csproj", "{3CD23FD2-898D-4BB9-9D09-899D217A1025}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3CD23FD2-898D-4BB9-9D09-899D217A1025}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3CD23FD2-898D-4BB9-9D09-899D217A1025}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3CD23FD2-898D-4BB9-9D09-899D217A1025}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {3CD23FD2-898D-4BB9-9D09-899D217A1025}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3CD23FD2-898D-4BB9-9D09-899D217A1025}.Release|Any CPU.Build.0 = Release|Any CPU + {3CD23FD2-898D-4BB9-9D09-899D217A1025}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.suo b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.suo new file mode 100644 index 0000000..1b5d194 Binary files /dev/null and b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.suo differ diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/BinaryCompression.cs b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/BinaryCompression.cs new file mode 100644 index 0000000..77ebe15 --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/BinaryCompression.cs @@ -0,0 +1,52 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using System.Data.SqlTypes; +using Microsoft.SqlServer.Server; +using System.IO; +using System.IO.Compression; + +public partial class UserDefinedFunctions +{ + [Microsoft.SqlServer.Server.SqlFunction] + public static SqlBytes BinaryCompress(SqlBytes inputStream) + { + using (MemoryStream ms = new MemoryStream()) + { + using (GZipStream x = + new GZipStream(ms, CompressionMode.Compress, true)) + { + byte[] inputBytes = (byte[])inputStream.Value; + x.Write(inputBytes, 0, inputBytes.Length); + } + + return (new SqlBytes(ms.ToArray())); + } + } + + + [Microsoft.SqlServer.Server.SqlFunction] + public static SqlBytes BinaryDecompress(SqlBytes inputBinary) + { + byte[] inputBytes = (byte[])inputBinary.Value; + + using (MemoryStream memStreamIn = new MemoryStream(inputBytes)) + { + using (GZipStream s = + new GZipStream(memStreamIn, CompressionMode.Decompress)) + { + using (MemoryStream memStreamOut = new MemoryStream()) + { + for (int num = s.ReadByte(); num != -1; num = s.ReadByte()) + { + memStreamOut.WriteByte((byte)num); + } + + return (new SqlBytes(memStreamOut.ToArray())); + } + } + } + } + +}; + diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/GetDepartments.cs b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/GetDepartments.cs new file mode 100644 index 0000000..8d1609d --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/GetDepartments.cs @@ -0,0 +1,39 @@ +using System; +using System.Data; +using System.Data.Sql; +using System.Data.SqlTypes; +using System.Data.SqlClient; +using Microsoft.SqlServer.Server; +using System.Collections; + +public partial class UserDefinedFunctions +{ + [Microsoft.SqlServer.Server.SqlFunction( + DataAccess = DataAccessKind.Read, + FillRowMethodName = "GetNextDepartment", + TableDefinition = "Name NVARCHAR(50), GroupName NVARCHAR(50)")] + public static IEnumerable GetDepartments() + { + using (SqlConnection conn = + new SqlConnection("context connection=true;")) + { + string sql = + "SELECT Name, GroupName FROM HumanResources.Department"; + conn.Open(); + SqlCommand comm = new SqlCommand(sql, conn); + SqlDataAdapter adaptor = new SqlDataAdapter(comm); + DataSet dSet = new DataSet(); + adaptor.Fill(dSet); + return (dSet.Tables[0].Rows); + } + } + + public static void GetNextDepartment(object row, + out string name, + out string groupName) + { + DataRow theRow = (DataRow)row; + name = (string)theRow["Name"]; + groupName = (string)theRow["GroupName"]; + } +}; diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/GetTableFromStringArray.cs b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/GetTableFromStringArray.cs new file mode 100644 index 0000000..8a2c74e --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/GetTableFromStringArray.cs @@ -0,0 +1,23 @@ +using System; +using System.Data; +using System.Data.Sql; +using System.Data.SqlTypes; +using Microsoft.SqlServer.Server; +using System.Collections; + +public partial class UserDefinedFunctions +{ + [Microsoft.SqlServer.Server.SqlFunction(FillRowMethodName = "GetNextString", + TableDefinition = "StringCol NVARCHAR(MAX)")] + public static IEnumerable GetTableFromStringArray(StringArray strings) + { + string csv = strings.ToString(); + string[] arr = csv.Split(','); + return arr; + } + + public static void GetNextString(object row, out string theString) + { + theString = (string)row; + } +}; diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/PhoneNumber.cs b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/PhoneNumber.cs new file mode 100644 index 0000000..2fdd9f0 --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/PhoneNumber.cs @@ -0,0 +1,103 @@ +using System; +using System.Data; +using System.Data.Sql; +using System.Data.SqlTypes; +using Microsoft.SqlServer.Server; +using System.Text; +using System.Text.RegularExpressions; + +[Serializable] +[Microsoft.SqlServer.Server.SqlUserDefinedType(Format.UserDefined, +IsByteOrdered = true, +IsFixedLength = false, +MaxByteSize = 11)] +public struct PhoneNumber : INullable, IBinarySerialize +{ + public override string ToString() + { + return this.number; + } + + public bool IsNull + { + get + { + if (this.number == "") + return true; + else + return false; + } + } + + public static PhoneNumber Null + { + get + { + PhoneNumber h = new PhoneNumber(); + h.number = ""; + return h; + } + } + + public static PhoneNumber Parse(SqlString s) + { + if (s.IsNull) + return Null; + PhoneNumber u = new PhoneNumber(); + + //Call the Number property for assigning the value + u.Number = s; + return u; + } + + // Public mutator for the number + public SqlString Number + { + get + { + return new SqlString(this.number); + } + set + { + //If null, don't process any further + if (value == "") + { + this.number = ""; + return; + } + + //Match groups of 1 or more digits + Regex regex = new Regex("[0-9]*"); + MatchCollection matches = regex.Matches((string)value); + + StringBuilder result = new StringBuilder(); + + foreach (Match match in matches) + { + result.Append(match.Value); + } + + if (result.Length == 10) + this.number = result.ToString(); + else + throw new ArgumentException("Phone numbers must be 10 digits."); + } + } + + // The phone number + private string number; + + #region IBinarySerialize Members + + public void Read(System.IO.BinaryReader r) + { + this.number = r.ReadString(); + } + + public void Write(System.IO.BinaryWriter w) + { + w.Write(number); + } + + #endregion +} \ No newline at end of file diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.csproj b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.csproj new file mode 100644 index 0000000..f09abb7 --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.csproj @@ -0,0 +1,62 @@ + + + + Debug + AnyCPU + {c252feb5-a946-4202-b1d4-9916a0590387};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 8.0.50727 + 2.0 + {3CD23FD2-898D-4BB9-9D09-899D217A1025} + Library + false + ProSQLServer2005_Chapter6 + ProSQLServer2005_Chapter6 + + + true + full + false + bin\Debug\ + false + DEBUG;TRACE + 4 + + + false + true + bin\Release\ + false + TRACE + 4 + + + + + + + + + + + + + + + + + + + + + + Content + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.csproj.user b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.csproj.user new file mode 100644 index 0000000..4259145 --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6.csproj.user @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/Properties/AssemblyInfo.cs b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0dace24 --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Data.Sql; + +// 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. +[assembly: AssemblyTitle("ProSQLServer2005_Chapter6")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ProSQLServer2005_Chapter6")] +[assembly: AssemblyCopyright("Copyright © 2005")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +// +// 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 Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] + diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/StringArray.cs b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/StringArray.cs new file mode 100644 index 0000000..856d499 --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/StringArray.cs @@ -0,0 +1,136 @@ +using System; +using System.Data; +using System.Data.Sql; +using System.Data.SqlTypes; +using Microsoft.SqlServer.Server; +using System.Collections.Generic; + +[Serializable] +[Microsoft.SqlServer.Server.SqlUserDefinedType( + Format.UserDefined, + IsByteOrdered = false, + IsFixedLength = false, + MaxByteSize = 8000)] +public struct StringArray : INullable, IBinarySerialize +{ + public override string ToString() + { + // Replace the followng code with your code + if (this.IsNull) + return ""; + else + return String.Join(",", (string[])this.arr.ToArray()); + } + + public bool IsNull + { + get + { + return (this.arr == null); + } + } + + public static StringArray Null + { + get + { + StringArray h = new StringArray(); + return h; + } + } + + public static StringArray Parse(SqlString s) + { + if (s.IsNull) + return Null; + + StringArray u = new StringArray(); + + string[] strings = ((string)s).Split(','); + + for (int i = 0; i < strings.Length; i++) + { + strings[i] = strings[i].Trim(); + } + + u.arr = new List(strings.Length); + + foreach (string str in strings) + { + if (str != "") + u.arr.Add(str); + } + + return u; + } + + public SqlInt32 Count + { + get + { + if (this.IsNull) + return SqlInt32.Null; + else + return (SqlInt32)(this.arr.Count); + } + } + + public SqlString GetAt(int Index) + { + return (SqlString)(string)(this.arr[Index]); + } + + public StringArray AddString(SqlString str) + { + if (this.IsNull) + this.arr = new List(1); + + this.arr.Add((string)str); + + return (this); + } + + public StringArray RemoveAt(int Index) + { + this.arr.RemoveAt(Index); + return this; + } + + // The actual array + private List arr; + + #region IBinarySerialize Members + + public void Read(System.IO.BinaryReader r) + { + int count = r.ReadInt32(); + if (count > -1) + { + this.arr = new List(count); + + for (int i = 0; i < count; i++) + { + this.arr.Add(r.ReadString()); + } + } + } + + public void Write(System.IO.BinaryWriter w) + { + if (this.IsNull) + { + w.Write(-1); + } + else + { + w.Write(this.arr.Count); + + foreach (string str in this.arr) + { + w.Write(str); + } + } + } + + #endregion +} diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/Test Scripts/Test.sql b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/Test Scripts/Test.sql new file mode 100644 index 0000000..8210d2f --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/Test Scripts/Test.sql @@ -0,0 +1,35 @@ +-- Examples for queries that exercise different SQL objects implemented by this assembly + +----------------------------------------------------------------------------------------- +-- Stored procedure +----------------------------------------------------------------------------------------- +-- exec StoredProcedureName + + +----------------------------------------------------------------------------------------- +-- User defined function +----------------------------------------------------------------------------------------- +-- select dbo.FunctionName() + + +----------------------------------------------------------------------------------------- +-- User defined type +----------------------------------------------------------------------------------------- +-- CREATE TABLE test_table (col1 UserType) +-- go +-- +-- INSERT INTO test_table VALUES (convert(uri, 'Instantiation String 1')) +-- INSERT INTO test_table VALUES (convert(uri, 'Instantiation String 2')) +-- INSERT INTO test_table VALUES (convert(uri, 'Instantiation String 3')) +-- +-- select col1::method1() from test_table + + + +----------------------------------------------------------------------------------------- +-- User defined type +----------------------------------------------------------------------------------------- +-- select dbo.AggregateName(Column1) from Table1 + + +select 'To run your project, please edit the Test.sql file in your project. This file is located in the Test Scripts folder in the Solution Explorer.' diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/TrimmedMean.cs b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/TrimmedMean.cs new file mode 100644 index 0000000..b60f2b1 --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/TrimmedMean.cs @@ -0,0 +1,63 @@ +using System; +using System.Data; +using System.Data.Sql; +using System.Data.SqlTypes; +using Microsoft.SqlServer.Server; + + +[Serializable] +[Microsoft.SqlServer.Server.SqlUserDefinedAggregate(Format.Native)] +public struct TrimmedMean +{ + public void Init() + { + this.numValues = 0; + this.totalValue = 0; + this.minValue = SqlMoney.MaxValue; + this.maxValue = SqlMoney.MinValue; + } + + public void Accumulate(SqlMoney Value) + { + if (!Value.IsNull) + { + this.numValues++; + this.totalValue += Value; + if (Value < this.minValue) + this.minValue = Value; + if (Value > this.maxValue) + this.maxValue = Value; + } + } + + public void Merge(TrimmedMean Group) + { + if (Group.numValues > 0) + { + this.numValues += Group.numValues; + this.totalValue += Group.totalValue; + if (Group.minValue < this.minValue) + this.minValue = Group.minValue; + if (Group.maxValue > this.maxValue) + this.maxValue = Group.maxValue; + } + } + + public SqlMoney Terminate() + { + if (this.numValues < 3) + return (SqlMoney.Null); + else + { + this.numValues -= 2; + this.totalValue -= this.minValue; + this.totalValue -= this.maxValue; + return (this.totalValue / this.numValues); + } + } + + private int numValues; + private SqlMoney totalValue; + private SqlMoney minValue; + private SqlMoney maxValue; +} diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/ValidateYear.cs b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/ValidateYear.cs new file mode 100644 index 0000000..f864329 --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/ValidateYear.cs @@ -0,0 +1,59 @@ +using System; +using System.Data; +using System.Data.Sql; +using Microsoft.SqlServer.Server; +using System.Data.SqlClient; + +public partial class Triggers +{ + // Enter existing table or view for the target and uncomment the attribute line + [Microsoft.SqlServer.Server.SqlTrigger( + Name = "ValidateYear", + Target = "HumanResources.Department", + Event = "FOR INSERT")] + public static void ValidateYear() + { + SqlConnection conn = + new SqlConnection("context connection=true"); + + //Define the query + string sql = + "SELECT COUNT(*) " + + "FROM INSERTED " + + "WHERE YEAR(ModifiedDate) <> 2005"; + + SqlCommand comm = + new SqlCommand(sql, conn); + + //Open the connection + conn.Open(); + + //Get the number of bad rows + int numBadRows = (int)comm.ExecuteScalar(); + + if (numBadRows > 0) + { + //Get the SqlPipe + SqlPipe pipe = SqlContext.Pipe; + + //Rollback and raise an error + comm.CommandText = + "RAISERROR('Modified Date must fall in 2005', 11, 1)"; + + //Send the error + try + { + pipe.ExecuteAndSend(comm); + } + catch + { + //do nothing + } + + System.Transactions.Transaction.Current.Rollback(); + } + + //Close the connection + conn.Close(); + } +} diff --git a/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/obj/ProSQLServer2005_Chapter6.csproj.FileList.txt b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/obj/ProSQLServer2005_Chapter6.csproj.FileList.txt new file mode 100644 index 0000000..36565a4 --- /dev/null +++ b/1590594770-1/Chapter06/ProSQLServer2005_Chapter6/ProSQLServer2005_Chapter6/obj/ProSQLServer2005_Chapter6.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\ProSQLServer2005_Chapter6.dll +bin\Debug\ProSQLServer2005_Chapter6.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\ProSQLServer2005_Chapter6.dll +obj\Debug\ProSQLServer2005_Chapter6.pdb diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/AuthorsXMLNew.xml b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/AuthorsXMLNew.xml new file mode 100644 index 0000000..129ac05 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/AuthorsXMLNew.xml @@ -0,0 +1,3 @@ +172-32-1176WhiteJohnson408 496-7223
10932 Bigge Rd.
Menlo ParkCA940251
213-46-8915GreenMarjorie415 986-7020
309 63rd St. #411
OaklandCA946181
238-95-7766CarsonCheryl415 548-7723
589 Darwin Ln.
BerkeleyCA947051
267-41-2394O'LearyMichael408 286-2428
22 Cleveland Av. #14
San JoseCA951281
274-80-9391StraightDean415 834-2919
5420 College Av.
OaklandCA946091
341-22-1782SmithMeander913 843-0462
10 Mississippi Dr.
LawrenceKS660440
409-56-7008BennetAbraham415 658-9932
6223 Bateman St.
BerkeleyCA947051
427-17-2319DullAnn415 836-7128
3410 Blonde St.
Palo AltoCA943011
472-27-2349GringlesbyBurt707 938-6445
PO + Box 792
CoveloCA954281
486-29-1786LocksleyCharlene415 585-4620
18 Broadway Av.
San FranciscoCA941301
527-72-3246GreeneMorningstar615 297-2723
22 Graybar House Rd.
NashvilleTN372150
648-92-1872Blotchet-HallsReginald503 745-6402
55 Hillsdale Bl.
CorvallisOR973301
672-71-3249YokomotoAkiko415 935-4228
3 Silver Ct.
Walnut CreekCA945951
712-45-1867del CastilloInnes615 996-8275
2286 Cram Pl. #86
Ann ArborMI481051
722-51-5454DeFranceMichel219 547-9982
3 Balding Pl.
GaryIN464031
724-08-9931StringerDirk415 843-2991
5420 Telegraph Av.
OaklandCA946090
724-80-9391MacFeatherStearns415 354-7128
44 Upland Hts.
OaklandCA946121
+756-30-7391KarsenLivia415 534-9219
5720 McAuley St.
OaklandCA946091
807-91-6654PanteleySylvia301 946-8853
1956 Arlington Pl.
RockvilleMD208531
846-92-7186HunterSheryl415 836-7128
3410 Blonde St.
Palo AltoCA943011
893-72-1158McBaddenHeather707 448-4982
301 Putnam
VacavilleCA956880
899-46-2035RingerAnne801 826-0752
67 Seventh Av.
Salt Lake CityUT841521
998-72-3567RingerAlbert801 826-0752
67 Seventh Av.
Salt Lake CityUT841521
\ No newline at end of file diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML.sln b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML.sln new file mode 100644 index 0000000..d3e430c --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SQLXML", "SQLXML\SQLXML.vbproj", "{1E1FA241-593E-4C99-A433-7B855BC19605}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1E1FA241-593E-4C99-A433-7B855BC19605}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E1FA241-593E-4C99-A433-7B855BC19605}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E1FA241-593E-4C99-A433-7B855BC19605}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E1FA241-593E-4C99-A433-7B855BC19605}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML.suo b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML.suo new file mode 100644 index 0000000..f1f9aa1 Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML.suo differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/AuthorsXMLNew.xml b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/AuthorsXMLNew.xml new file mode 100644 index 0000000..129ac05 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/AuthorsXMLNew.xml @@ -0,0 +1,3 @@ +172-32-1176WhiteJohnson408 496-7223
10932 Bigge Rd.
Menlo ParkCA940251
213-46-8915GreenMarjorie415 986-7020
309 63rd St. #411
OaklandCA946181
238-95-7766CarsonCheryl415 548-7723
589 Darwin Ln.
BerkeleyCA947051
267-41-2394O'LearyMichael408 286-2428
22 Cleveland Av. #14
San JoseCA951281
274-80-9391StraightDean415 834-2919
5420 College Av.
OaklandCA946091
341-22-1782SmithMeander913 843-0462
10 Mississippi Dr.
LawrenceKS660440
409-56-7008BennetAbraham415 658-9932
6223 Bateman St.
BerkeleyCA947051
427-17-2319DullAnn415 836-7128
3410 Blonde St.
Palo AltoCA943011
472-27-2349GringlesbyBurt707 938-6445
PO + Box 792
CoveloCA954281
486-29-1786LocksleyCharlene415 585-4620
18 Broadway Av.
San FranciscoCA941301
527-72-3246GreeneMorningstar615 297-2723
22 Graybar House Rd.
NashvilleTN372150
648-92-1872Blotchet-HallsReginald503 745-6402
55 Hillsdale Bl.
CorvallisOR973301
672-71-3249YokomotoAkiko415 935-4228
3 Silver Ct.
Walnut CreekCA945951
712-45-1867del CastilloInnes615 996-8275
2286 Cram Pl. #86
Ann ArborMI481051
722-51-5454DeFranceMichel219 547-9982
3 Balding Pl.
GaryIN464031
724-08-9931StringerDirk415 843-2991
5420 Telegraph Av.
OaklandCA946090
724-80-9391MacFeatherStearns415 354-7128
44 Upland Hts.
OaklandCA946121
+756-30-7391KarsenLivia415 534-9219
5720 McAuley St.
OaklandCA946091
807-91-6654PanteleySylvia301 946-8853
1956 Arlington Pl.
RockvilleMD208531
846-92-7186HunterSheryl415 836-7128
3410 Blonde St.
Palo AltoCA943011
893-72-1158McBaddenHeather707 448-4982
301 Putnam
VacavilleCA956880
899-46-2035RingerAnne801 826-0752
67 Seventh Av.
Salt Lake CityUT841521
998-72-3567RingerAlbert801 826-0752
67 Seventh Av.
Salt Lake CityUT841521
\ No newline at end of file diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/AssemblyInfo.vb b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..f88df68 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/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/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/MyApplication.Designer.vb b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/MyApplication.Designer.vb new file mode 100644 index 0000000..6408e9f --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/MyApplication.Designer.vb @@ -0,0 +1,30 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' 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 Class MyApplication + + Public Sub New() + MyBase.New(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.SQLXML.frmMain + End Sub + End Class +End Namespace diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/MyApplication.myapp b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/MyApplication.myapp new file mode 100644 index 0000000..b456038 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/MyApplication.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/MyEvents.vb b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/MyEvents.vb new file mode 100644 index 0000000..d67825f --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/MyEvents.vb @@ -0,0 +1,15 @@ +Namespace My + + 'Use the editor window dropdowns in the Application pane of the Project Designer to handle MyApplication Events + ' + 'Startup: Raised when the application starts, before the startup form is created. + 'Shutdown: Raised after all application forms are closed. This event is not raised if the application is terminating abnormally. + 'UnhandledException: Raised if the application encounters an unhandled exception. + 'StartupNextInstance: Raised when launching a single-instance application and the application is already active. + 'NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. + + Partial Friend Class MyApplication + + End Class + +End Namespace diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Resources.Designer.vb b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Resources.Designer.vb new file mode 100644 index 0000000..29b7415 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' 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 +Imports System.IO +Imports System.Resources + +Namespace My.Resources + + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + 'This class was auto-generated by the Strongly Typed Resource Builder + 'class via a tool like ResGen or Visual Studio.NET. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + _ + Module MyResources + + Private _resMgr As System.Resources.ResourceManager + + Private _resCulture As System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Public ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If (_resMgr Is Nothing) Then + Dim temp As System.Resources.ResourceManager = New System.Resources.ResourceManager("SQLXML.MyResources", GetType(MyResources).Assembly) + System.Threading.Thread.MemoryBarrier + _resMgr = temp + End If + Return _resMgr + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Public Property Culture() As System.Globalization.CultureInfo + Get + Return _resCulture + End Get + Set + _resCulture = value + End Set + End Property + End Module +End Namespace diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Resources.resx b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/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/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Settings.Designer.vb b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Settings.Designer.vb new file mode 100644 index 0000000..3d12c6f --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Settings.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + + +Partial Friend NotInheritable Class MySettings + Inherits System.Configuration.ApplicationSettingsBase + + Private Shared m_Value As MySettings + + Private Shared m_SyncObject As Object = New Object + + _ + Public Shared ReadOnly Property Value() As MySettings + Get + If (MySettings.m_Value Is Nothing) Then + System.Threading.Monitor.Enter(MySettings.m_SyncObject) + If (MySettings.m_Value Is Nothing) Then + Try + MySettings.m_Value = New MySettings + Finally + System.Threading.Monitor.Exit(MySettings.m_SyncObject) + End Try + End If + End If + Return MySettings.m_Value + End Get + End Property +End Class diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Settings.settings b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Settings.settings new file mode 100644 index 0000000..c2dbd5c --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/SQLXML.vbproj b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/SQLXML.vbproj new file mode 100644 index 0000000..819ca2e --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/SQLXML.vbproj @@ -0,0 +1,118 @@ + + + + Debug + AnyCPU + 8.0.50215 + 2.0 + {1E1FA241-593E-4C99-A433-7B855BC19605} + WinExe + SQLXML.My.MyApplication + SQLXML + SQLXML + WindowsForms + + + true + full + true + true + bin\Debug\ + SQLXML.xml + 42016,42017,42018,42019,42032,42036 + + + pdbonly + false + true + true + bin\Release\ + SQLXML.xml + 42016,42017,42018,42019,42032,42036 + + + + + + + + + + + + + + + + + + + + + + Form + + + frmMain.vb + Form + + + + True + MyApplication.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + frmMain.vb + Designer + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + MyApplicationCodeGenerator + MyApplication.Designer.vb + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + {FDCA4B6C-605A-4B76-ADCE-68010C4A2581} + 4 + 0 + 0 + tlbimp + False + + + {00020430-0000-0000-C000-000000000046} + 2 + 0 + 0 + primary + False + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/SQLXML.vbproj.user b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/SQLXML.vbproj.user new file mode 100644 index 0000000..a4461a2 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/SQLXML.vbproj.user @@ -0,0 +1,7 @@ + + + 8.0.50215 + ProjectFiles + 0 + + \ No newline at end of file diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/app.config b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/app.config new file mode 100644 index 0000000..a82640c --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/app.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/Interop.SQLXMLBULKLOADLib.dll b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/Interop.SQLXMLBULKLOADLib.dll new file mode 100644 index 0000000..432ae3a Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/Interop.SQLXMLBULKLOADLib.dll differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.exe b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.exe new file mode 100644 index 0000000..7ed86ff Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.exe differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.exe.config b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.exe.config new file mode 100644 index 0000000..a82640c --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.pdb b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.pdb new file mode 100644 index 0000000..f92914e Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.pdb differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.vshost.exe b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.vshost.exe new file mode 100644 index 0000000..72b0f71 Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.vshost.exe differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.vshost.exe.config b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.vshost.exe.config new file mode 100644 index 0000000..a82640c --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.vshost.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.xml b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.xml new file mode 100644 index 0000000..3da9705 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/bin/Debug/SQLXML.xml @@ -0,0 +1,11 @@ + + + + +SQLXML + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/frmMain.Designer.vb b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/frmMain.Designer.vb new file mode 100644 index 0000000..2caf0c8 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/frmMain.Designer.vb @@ -0,0 +1,274 @@ +Partial Public Class frmMain + Inherits System.Windows.Forms.Form + + _ + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + End Sub + + 'Form overrides dispose to clean up the component list. + _ + Protected Overloads 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.btnBulkLoad = New System.Windows.Forms.Button + Me.txtXMLFile = New System.Windows.Forms.TextBox + Me.lblXML = New System.Windows.Forms.Label + Me.lblXMLSchema = New System.Windows.Forms.Label + Me.txtXMLSchema = New System.Windows.Forms.TextBox + Me.txtSQLQuery = New System.Windows.Forms.TextBox + Me.lblSQLQuery = New System.Windows.Forms.Label + Me.groupQueries = New System.Windows.Forms.GroupBox + Me.radioDataSet = New System.Windows.Forms.RadioButton + Me.radioTemplate = New System.Windows.Forms.RadioButton + Me.radioXPath = New System.Windows.Forms.RadioButton + Me.radioSQLXMLParameter = New System.Windows.Forms.RadioButton + Me.radioXMLTextReader = New System.Windows.Forms.RadioButton + Me.radioStreamReader = New System.Windows.Forms.RadioButton + Me.radioFORXMLClient = New System.Windows.Forms.RadioButton + Me.radioForXML = New System.Windows.Forms.RadioButton + Me.txtResults = New System.Windows.Forms.TextBox + Me.lblResults = New System.Windows.Forms.Label + Me.radioUpdateGram = New System.Windows.Forms.RadioButton + Me.groupQueries.SuspendLayout() + Me.SuspendLayout() + ' + 'btnBulkLoad + ' + Me.btnBulkLoad.Location = New System.Drawing.Point(363, 12) + Me.btnBulkLoad.Name = "btnBulkLoad" + Me.btnBulkLoad.Size = New System.Drawing.Size(147, 36) + Me.btnBulkLoad.TabIndex = 0 + Me.btnBulkLoad.Text = "&Bulkload XML" + ' + 'txtXMLFile + ' + Me.txtXMLFile.Location = New System.Drawing.Point(142, 35) + Me.txtXMLFile.Name = "txtXMLFile" + Me.txtXMLFile.Size = New System.Drawing.Size(215, 20) + Me.txtXMLFile.TabIndex = 1 + ' + 'lblXML + ' + Me.lblXML.AutoSize = True + Me.lblXML.Location = New System.Drawing.Point(58, 41) + Me.lblXML.Name = "lblXML" + Me.lblXML.Size = New System.Drawing.Size(78, 14) + Me.lblXML.TabIndex = 2 + Me.lblXML.Text = "XML File Path:" + ' + 'lblXMLSchema + ' + Me.lblXMLSchema.AutoSize = True + Me.lblXMLSchema.Location = New System.Drawing.Point(39, 15) + Me.lblXMLSchema.Name = "lblXMLSchema" + Me.lblXMLSchema.Size = New System.Drawing.Size(97, 14) + Me.lblXMLSchema.TabIndex = 4 + Me.lblXMLSchema.Text = "XML Schema File:" + ' + 'txtXMLSchema + ' + Me.txtXMLSchema.Location = New System.Drawing.Point(142, 9) + Me.txtXMLSchema.Name = "txtXMLSchema" + Me.txtXMLSchema.Size = New System.Drawing.Size(215, 20) + Me.txtXMLSchema.TabIndex = 3 + ' + 'txtSQLQuery + ' + Me.txtSQLQuery.AutoSize = False + Me.txtSQLQuery.Location = New System.Drawing.Point(142, 180) + Me.txtSQLQuery.Multiline = True + Me.txtSQLQuery.Name = "txtSQLQuery" + Me.txtSQLQuery.ReadOnly = True + Me.txtSQLQuery.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtSQLQuery.Size = New System.Drawing.Size(474, 131) + Me.txtSQLQuery.TabIndex = 6 + ' + 'lblSQLQuery + ' + Me.lblSQLQuery.AutoSize = True + Me.lblSQLQuery.Location = New System.Drawing.Point(58, 180) + Me.lblSQLQuery.Name = "lblSQLQuery" + Me.lblSQLQuery.Size = New System.Drawing.Size(64, 14) + Me.lblSQLQuery.TabIndex = 7 + Me.lblSQLQuery.Text = "SQL Query:" + ' + 'groupQueries + ' + Me.groupQueries.Controls.Add(Me.radioUpdateGram) + Me.groupQueries.Controls.Add(Me.radioDataSet) + Me.groupQueries.Controls.Add(Me.radioTemplate) + Me.groupQueries.Controls.Add(Me.radioXPath) + Me.groupQueries.Controls.Add(Me.radioSQLXMLParameter) + Me.groupQueries.Controls.Add(Me.radioXMLTextReader) + Me.groupQueries.Controls.Add(Me.radioStreamReader) + Me.groupQueries.Controls.Add(Me.radioFORXMLClient) + Me.groupQueries.Controls.Add(Me.radioForXML) + Me.groupQueries.Location = New System.Drawing.Point(12, 83) + Me.groupQueries.Name = "groupQueries" + Me.groupQueries.Size = New System.Drawing.Size(613, 71) + Me.groupQueries.TabIndex = 10 + Me.groupQueries.TabStop = False + Me.groupQueries.Text = "Test Queries" + ' + 'radioDataSet + ' + Me.radioDataSet.AutoSize = True + Me.radioDataSet.Location = New System.Drawing.Point(415, 42) + Me.radioDataSet.Name = "radioDataSet" + Me.radioDataSet.Size = New System.Drawing.Size(80, 17) + Me.radioDataSet.TabIndex = 7 + Me.radioDataSet.Text = "Use Dataset" + ' + 'radioTemplate + ' + Me.radioTemplate.AutoSize = True + Me.radioTemplate.Location = New System.Drawing.Point(415, 19) + Me.radioTemplate.Name = "radioTemplate" + Me.radioTemplate.Size = New System.Drawing.Size(88, 17) + Me.radioTemplate.TabIndex = 6 + Me.radioTemplate.Text = "Run Template" + ' + 'radioXPath + ' + Me.radioXPath.AutoSize = True + Me.radioXPath.Location = New System.Drawing.Point(268, 42) + Me.radioXPath.Name = "radioXPath" + Me.radioXPath.Size = New System.Drawing.Size(104, 17) + Me.radioXPath.TabIndex = 5 + Me.radioXPath.Text = "Run XPath Query" + ' + 'radioSQLXMLParameter + ' + Me.radioSQLXMLParameter.AutoSize = True + Me.radioSQLXMLParameter.Location = New System.Drawing.Point(268, 19) + Me.radioSQLXMLParameter.Name = "radioSQLXMLParameter" + Me.radioSQLXMLParameter.Size = New System.Drawing.Size(134, 17) + Me.radioSQLXMLParameter.TabIndex = 4 + Me.radioSQLXMLParameter.Text = "Use SQLXMLParameter" + ' + 'radioXMLTextReader + ' + Me.radioXMLTextReader.AutoSize = True + Me.radioXMLTextReader.Location = New System.Drawing.Point(135, 42) + Me.radioXMLTextReader.Name = "radioXMLTextReader" + Me.radioXMLTextReader.Size = New System.Drawing.Size(121, 17) + Me.radioXMLTextReader.TabIndex = 3 + Me.radioXMLTextReader.Text = "Use XMLTextReader" + ' + 'radioStreamReader + ' + Me.radioStreamReader.AutoSize = True + Me.radioStreamReader.Location = New System.Drawing.Point(135, 19) + Me.radioStreamReader.Name = "radioStreamReader" + Me.radioStreamReader.Size = New System.Drawing.Size(111, 17) + Me.radioStreamReader.TabIndex = 2 + Me.radioStreamReader.Text = "Use StreamReader" + ' + 'radioFORXMLClient + ' + Me.radioFORXMLClient.AutoSize = True + Me.radioFORXMLClient.Location = New System.Drawing.Point(6, 42) + Me.radioFORXMLClient.Name = "radioFORXMLClient" + Me.radioFORXMLClient.Size = New System.Drawing.Size(116, 17) + Me.radioFORXMLClient.TabIndex = 1 + Me.radioFORXMLClient.Text = "FOR XML Clientside" + ' + 'radioForXML + ' + Me.radioForXML.AutoSize = True + Me.radioForXML.Location = New System.Drawing.Point(6, 19) + Me.radioForXML.Name = "radioForXML" + Me.radioForXML.Size = New System.Drawing.Size(68, 17) + Me.radioForXML.TabIndex = 0 + Me.radioForXML.Text = "FOR XML" + ' + 'txtResults + ' + Me.txtResults.AutoSize = False + Me.txtResults.Location = New System.Drawing.Point(142, 347) + Me.txtResults.Multiline = True + Me.txtResults.Name = "txtResults" + Me.txtResults.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtResults.Size = New System.Drawing.Size(474, 250) + Me.txtResults.TabIndex = 11 + ' + 'lblResults + ' + Me.lblResults.AutoSize = True + Me.lblResults.Location = New System.Drawing.Point(72, 347) + Me.lblResults.Name = "lblResults" + Me.lblResults.Size = New System.Drawing.Size(45, 14) + Me.lblResults.TabIndex = 12 + Me.lblResults.Text = "Results:" + ' + 'radioUpdateGram + ' + Me.radioUpdateGram.AutoSize = True + Me.radioUpdateGram.Location = New System.Drawing.Point(509, 19) + Me.radioUpdateGram.Name = "radioUpdateGram" + Me.radioUpdateGram.Size = New System.Drawing.Size(101, 17) + Me.radioUpdateGram.TabIndex = 8 + Me.radioUpdateGram.Text = "Use Updategram" + ' + 'frmMain + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(628, 609) + Me.Controls.Add(Me.lblResults) + Me.Controls.Add(Me.txtResults) + Me.Controls.Add(Me.groupQueries) + Me.Controls.Add(Me.lblSQLQuery) + Me.Controls.Add(Me.txtSQLQuery) + Me.Controls.Add(Me.lblXMLSchema) + Me.Controls.Add(Me.txtXMLSchema) + Me.Controls.Add(Me.lblXML) + Me.Controls.Add(Me.txtXMLFile) + Me.Controls.Add(Me.btnBulkLoad) + Me.Name = "frmMain" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "SQLXML Sample Application" + Me.groupQueries.ResumeLayout(False) + Me.groupQueries.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents btnBulkLoad As System.Windows.Forms.Button + Friend WithEvents txtXMLFile As System.Windows.Forms.TextBox + Friend WithEvents lblXML As System.Windows.Forms.Label + Friend WithEvents lblXMLSchema As System.Windows.Forms.Label + Friend WithEvents txtXMLSchema As System.Windows.Forms.TextBox + Friend WithEvents txtSQLQuery As System.Windows.Forms.TextBox + Friend WithEvents lblSQLQuery As System.Windows.Forms.Label + Friend WithEvents groupQueries As System.Windows.Forms.GroupBox + Friend WithEvents radioXMLTextReader As System.Windows.Forms.RadioButton + Friend WithEvents radioStreamReader As System.Windows.Forms.RadioButton + Friend WithEvents radioFORXMLClient As System.Windows.Forms.RadioButton + Friend WithEvents radioForXML As System.Windows.Forms.RadioButton + Friend WithEvents radioSQLXMLParameter As System.Windows.Forms.RadioButton + Friend WithEvents txtResults As System.Windows.Forms.TextBox + Friend WithEvents lblResults As System.Windows.Forms.Label + Friend WithEvents radioXPath As System.Windows.Forms.RadioButton + Friend WithEvents radioTemplate As System.Windows.Forms.RadioButton + Friend WithEvents radioDataSet As System.Windows.Forms.RadioButton + Friend WithEvents radioUpdateGram As System.Windows.Forms.RadioButton + +End Class diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/frmMain.resx b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/frmMain.resx new file mode 100644 index 0000000..02bbfa2 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/frmMain.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/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/frmMain.vb b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/frmMain.vb new file mode 100644 index 0000000..7d39922 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/frmMain.vb @@ -0,0 +1,265 @@ +Imports System.Xml +Public Class frmMain + Dim strQuery As String = "" + Dim strConnectionString As String = "Provider=SQLOLEDB;server=localhost;database=pubs;integrated security=SSPI" + Dim strTable As String = "AuthorsXMLNew" + + Private Sub btnBulkLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBulkLoad.Click + Try + + 'Load the XML into SQL Server using SQLXML Bulkload + + Dim oXMLBulkLoad As New SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class() + oXMLBulkLoad.ErrorLogFile = "c:\myerrors.log" + oXMLBulkLoad.SchemaGen = True + oXMLBulkLoad.KeepIdentity = False + oXMLBulkLoad.BulkLoad = True + oXMLBulkLoad.SGDropTables = True + oXMLBulkLoad.XMLFragment = True + oXMLBulkLoad.ConnectionString = strConnectionString + oXMLBulkLoad.Execute(txtXMLSchema.Text, txtXMLFile.Text) + + MsgBox("Bulkload Successful.") + + Catch ex As Exception + MsgBox("Error: " & Err.Number & " Description: " & Err.Description) + End Try + End Sub + + + Private Sub SetQuery(ByVal strQueryText As String) + txtSQLQuery.Text = strQueryText + End Sub + + Private Sub radioForXML_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioForXML.CheckedChanged + 'Set the SQL Query + strQuery = "SELECT au_lname FROM " & strTable & " FOR XML AUTO, ELEMENTS" + SetQuery(strQuery) + + 'Don't use client-side rendering + + ExecuteQuery(strQuery, False, True, False, False, False, False, False) + + End Sub + + + Private Sub radioFORXMLClient_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioFORXMLClient.CheckedChanged + 'Set the SQL Query + strQuery = "SELECT au_lname, au_fname FROM " & strTable & " FOR XML AUTO" + SetQuery(strQuery) + + ExecuteQuery(strQuery, True, False, True, False, False, False, False) + End Sub + + Private Sub radioStreamReader_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioStreamReader.CheckedChanged + 'Set the SQL Query + strQuery = "SELECT phone, address FROM " & strTable & " FOR XML AUTO" + SetQuery(strQuery) + + 'Set to use the streamreader + + ExecuteQuery(strQuery, True, False, False, False, False, False, False) + + + End Sub + + Private Sub radioXMLTextReader_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioXMLTextReader.CheckedChanged + strQuery = "SELECT city FROM " & strTable & " FOR XML AUTO" + SetQuery(strQuery) + + 'Set to use the XMLReader + + ExecuteQuery(strQuery, False, False, False, False, False, False, False) + + End Sub + Private Sub radioXPath_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioXPath.CheckedChanged + 'Load up our query + + strQuery = "/AuthorsXMLNew[city='Oakland']" + SetQuery(strQuery) + + + ExecuteQuery(strQuery, True, False, True, True, False, False, False) + End Sub + + Private Sub radioSQLXMLParameter_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioSQLXMLParameter.CheckedChanged + strQuery = "SELECT * FROM " & strTable & " WHERE city = ? FOR XML AUTO, ELEMENTS" + SetQuery(strQuery) + + 'Set to use the streamreader + + ExecuteQuery(strQuery, True, True, True, False, False, False, False) + + + End Sub + Private Sub radioTemplate_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioTemplate.CheckedChanged + 'Load up our query + + strQuery = "SELECT * FROM " & strTable & " FOR XML AUTO" + SetQuery(strQuery) + + ExecuteQuery(strQuery, True, False, True, False, True, False, False) + + End Sub + Private Sub radioDataSet_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioDataSet.CheckedChanged + strQuery = "SELECT * FROM " & strTable & " WHERE city = 'oakland' FOR XML AUTO, ELEMENTS" + SetQuery(strQuery) + + 'Set to use the Dataset + + ExecuteQuery(strQuery, False, False, True, False, False, True, False) + + End Sub + Private Sub radioUpdateGram_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioUpdateGram.CheckedChanged + + Dim strUpdateGram As New System.Text.StringBuilder() + strUpdateGram.Append("") + strUpdateGram.Append("") + strUpdateGram.Append("") + strUpdateGram.Append("") + strUpdateGram.Append("") + strUpdateGram.Append("") + strUpdateGram.Append("") + strUpdateGram.Append("") + strUpdateGram.Append("") + + strQuery = strUpdateGram.ToString() + + SetQuery(strQuery) + + 'Set to use an UpdateGram + + ExecuteQuery(strQuery, False, False, True, False, False, False, True) + + + End Sub + + Private Sub ExecuteQuery(ByVal strQuery As String, ByVal bUseStreamReader As Boolean, ByVal bUseParameter As Boolean, ByVal bUseClientSide As Boolean, ByVal bUseXPath As Boolean, ByVal bUseTemplate As Boolean, ByVal bUseDataSet As Boolean, ByVal bUseUpdateGram As Boolean) + Err.Clear() + 'Create our SQLXML command + Dim oSQLXMLCommand As New Microsoft.Data.SqlXml.SqlXmlCommand(strConnectionString) + Dim oSQLXMLParameter As Microsoft.Data.SqlXml.SqlXmlParameter + + + oSQLXMLCommand.CommandType = Microsoft.Data.SqlXml.SqlXmlCommandType.Sql + + 'Set our Query + oSQLXMLCommand.CommandText = strQuery + If bUseXPath = True Then + oSQLXMLCommand.CommandType = Microsoft.Data.SqlXml.SqlXmlCommandType.XPath + oSQLXMLCommand.SchemaPath = txtXMLSchema.Text + oSQLXMLCommand.RootTag = "ROOT" + End If + + If bUseUpdateGram = True Then + oSQLXMLCommand.CommandType = Microsoft.Data.SqlXml.SqlXmlCommandType.UpdateGram + End If + + If bUseTemplate = True Then + oSQLXMLCommand.CommandType = Microsoft.Data.SqlXml.SqlXmlCommandType.Template + oSQLXMLCommand.SchemaPath = txtXMLSchema.Text + oSQLXMLCommand.RootTag = "ROOT" + End If + + + Try + + 'See if we need to render client-side + If bUseClientSide = True Then + oSQLXMLCommand.ClientSideXml = True + End If + + 'See if we need to use a parameter + If bUseParameter Then + oSQLXMLParameter = oSQLXMLCommand.CreateParameter() + oSQLXMLParameter.Name = "city" + oSQLXMLParameter.Value = "Oakland" + End If + + 'See if we need to use a streamreader or XMLreader + + If bUseStreamReader = True Then + + Dim oStream As System.IO.Stream + oStream = oSQLXMLCommand.ExecuteStream() + + oStream.Position = 0 + Dim oStreamReader As New System.IO.StreamReader(oStream) + txtResults.Text = oStreamReader.ReadToEnd() + oStreamReader.Close() + + ElseIf bUseStreamReader = False And bUseDataSet = False Then + 'Use XMLTextReader + Dim oXMLTextReader As System.Xml.XmlTextReader + oXMLTextReader = oSQLXMLCommand.ExecuteXmlReader() + Dim strXML As String = "" + + While oXMLTextReader.Read() + 'We're on an element + If oXMLTextReader.NodeType = XmlNodeType.Element Then + strXML += "<" & oXMLTextReader.Name & "" + ElseIf oXMLTextReader.NodeType = XmlNodeType.EndElement Then + strXML += "" + End If + + 'Look for attributes + If oXMLTextReader.HasAttributes() Then + Dim i As Integer = 0 + Do While (oXMLTextReader.MoveToNextAttribute()) + i += 1 + strXML += " " & oXMLTextReader.Name & "=" & oXMLTextReader.Value + If oXMLTextReader.AttributeCount = i Then + 'Last attribute, end the tag + strXML += " />" + End If + Loop + + Else + If (oXMLTextReader.NodeType = XmlNodeType.Text) Then + strXML += oXMLTextReader.Value + ElseIf oXMLTextReader.NodeType <> XmlNodeType.EndElement Then + strXML += ">" + End If + + End If + + End While + + + txtResults.Text = strXML + oXMLTextReader.Close() + + ElseIf bUseDataSet = True Then + Dim oSQLXMLDataAdapter As New Microsoft.Data.SqlXml.SqlXmlAdapter(oSQLXMLCommand) + Dim oDS As New System.Data.DataSet() + oSQLXMLDataAdapter.Fill(oDS) + + 'Display the underlying XML + Dim oMemStream As New System.IO.MemoryStream() + Dim oStreamWriter As New System.IO.StreamWriter(oMemStream) + oDS.WriteXml(oMemStream, System.Data.XmlWriteMode.IgnoreSchema) + oMemStream.Position = 0 + Dim oStreamReader As New System.IO.StreamReader(oMemStream) + txtResults.Text = oStreamReader.ReadToEnd() + oMemStream.Close() + + End If + + Catch + MsgBox("Error Number: " & Err.Number & " Description: " & Err.Description) + Err.Clear() + + + Finally + + + oSQLXMLCommand = Nothing + End Try + + End Sub + + + + +End Class diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/Interop.SQLXMLBULKLOADLib.dll b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/Interop.SQLXMLBULKLOADLib.dll new file mode 100644 index 0000000..432ae3a Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/Interop.SQLXMLBULKLOADLib.dll differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/ResolveAssemblyReference.cache b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..8d9c7b7 Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.Resources.resources b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.Resources.resources differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.exe b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.exe new file mode 100644 index 0000000..7ed86ff Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.exe differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.frmMain.resources b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.frmMain.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.frmMain.resources differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.pdb b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.pdb new file mode 100644 index 0000000..f92914e Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.pdb differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.vbproj.GenerateResource.Cache b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..f6f8806 Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.vbproj.GenerateResource.Cache differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.vbproj.ResolveComReference.cache b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.vbproj.ResolveComReference.cache new file mode 100644 index 0000000..7e14103 Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.vbproj.ResolveComReference.cache differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.xml b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.xml new file mode 100644 index 0000000..3da9705 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/SQLXML.xml @@ -0,0 +1,11 @@ + + + + +SQLXML + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..9ce3212 Binary files /dev/null and b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/SQLXML.vbproj.FileList.txt b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/SQLXML.vbproj.FileList.txt new file mode 100644 index 0000000..a0da8f5 --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/SQLXML/obj/SQLXML.vbproj.FileList.txt @@ -0,0 +1,14 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Interop.SQLXMLBULKLOADLib.dll +obj\Debug\SQLXML.frmMain.resources +obj\Debug\SQLXML.Resources.resources +obj\Debug\SQLXML.vbproj.GenerateResource.Cache +bin\Debug\SQLXML.exe.config +bin\Debug\SQLXML.exe +bin\Debug\SQLXML.pdb +bin\Debug\SQLXML.xml +bin\Debug\Interop.SQLXMLBULKLOADLib.dll +obj\Debug\SQLXML.exe +obj\Debug\SQLXML.xml +obj\Debug\SQLXML.pdb +obj\Debug\SQLXML.vbproj.ResolveComReference.cache diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/mapping schema.xsd b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/mapping schema.xsd new file mode 100644 index 0000000..fceeffd --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/mapping schema.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter07/SQLXML Sample/SQLXML/readme.txt b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/readme.txt new file mode 100644 index 0000000..25ba43f --- /dev/null +++ b/1590594770-1/Chapter07/SQLXML Sample/SQLXML/readme.txt @@ -0,0 +1,19 @@ +The SQLXML samples shows you how to use SQLXML to build applications against SQL Server. + +Please note that you need the Pubs database installed on your server to run this application. + +To run the application, perform the following steps: + +1) Double click the SQLXML.sln file to load the application into Visual Studio 2005. + +2) Find the line "Dim strConnectionString As String = "Provider=SQLOLEDB;server=localhost;database=pubs;integrated security=SSPI"" and replace localhost with the name of your server. + +3) Hit ctrl-F5 to start the application without debugging. + +4) In the XML Schema File textbox, put the full path to the file mapping schema.xsd such as c:\samples\mapping schema.xsd + +5) In the XML File Path textbox, put the full path to the file authorsxmlnew.xml such as c:\samples\authorsxmlnew.xml. + +6) Click the BulkLoadXML button. You should get a success message if the application could bulkload your data. + +7) Once successful, you can click any of the buttons in the main area of the form to see SQLXML in action. Please note that after clicking the Use Updategram button you may get errors. This is expected and should be ignored. \ No newline at end of file diff --git a/1590594770-1/Chapter08/Customer.xsd b/1590594770-1/Chapter08/Customer.xsd new file mode 100644 index 0000000..e6287ac --- /dev/null +++ b/1590594770-1/Chapter08/Customer.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter08/Customer1.xml b/1590594770-1/Chapter08/Customer1.xml new file mode 100644 index 0000000..3c78805 --- /dev/null +++ b/1590594770-1/Chapter08/Customer1.xml @@ -0,0 +1,2 @@ + +TomwidgetsBob Acme \ No newline at end of file diff --git a/1590594770-1/Chapter08/Customer2.xml b/1590594770-1/Chapter08/Customer2.xml new file mode 100644 index 0000000..8bda87e Binary files /dev/null and b/1590594770-1/Chapter08/Customer2.xml differ diff --git a/1590594770-1/Chapter08/Customer3.xml b/1590594770-1/Chapter08/Customer3.xml new file mode 100644 index 0000000..af1c29d --- /dev/null +++ b/1590594770-1/Chapter08/Customer3.xml @@ -0,0 +1,2 @@ + +widgetsBob Acme diff --git a/1590594770-1/Chapter08/Customer4.xml b/1590594770-1/Chapter08/Customer4.xml new file mode 100644 index 0000000..4e135ff --- /dev/null +++ b/1590594770-1/Chapter08/Customer4.xml @@ -0,0 +1,2 @@ + +GabriellewidgetsBob Acme \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App.sln b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App.sln new file mode 100644 index 0000000..cc58ad1 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLWS_App", "SQLWS_App\SQLWS_App.csproj", "{BFE6A6D3-A641-4A0A-A1D8-E6102288B40E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BFE6A6D3-A641-4A0A-A1D8-E6102288B40E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFE6A6D3-A641-4A0A-A1D8-E6102288B40E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFE6A6D3-A641-4A0A-A1D8-E6102288B40E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFE6A6D3-A641-4A0A-A1D8-E6102288B40E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App.suo b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App.suo new file mode 100644 index 0000000..4ff4170 Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App.suo differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Form1.Designer.cs b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Form1.Designer.cs new file mode 100644 index 0000000..785a8d1 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Form1.Designer.cs @@ -0,0 +1,58 @@ +namespace SQLWS_App +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.SuspendLayout(); +// +// button1 +// + this.button1.Location = new System.Drawing.Point(22, 80); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(227, 93); + this.button1.TabIndex = 0; + this.button1.Text = "&Click for SQL Web Service"; + this.button1.Click += new System.EventHandler(this.button1_Click); +// +// Form1 +// + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(292, 273); + this.Controls.Add(this.button1); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button1; + } +} + diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Form1.cs b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Form1.cs new file mode 100644 index 0000000..1217949 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Form1.cs @@ -0,0 +1,73 @@ +#region Using directives + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Windows.Forms; +using System.Net; +using System.Reflection; + + +#endregion + +namespace SQLWS_App +{ + partial class Form1: Form + { + public Form1() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //add a reference to our SQL WS + ws.SQLWS_endpoint SQLWS = new ws.SQLWS_endpoint(); + + //Set our default credentials to our Windows one + SQLWS.Credentials = CredentialCache.DefaultCredentials; + + //Call the sproc through the WS + System.Data.DataSet dsReturnValue = (System.Data.DataSet)SQLWS.SQLWS("Calling stored proc").GetValue(0); + + //Get the reader associated with our Dataset + System.Data.DataTableReader drSQL = dsReturnValue.CreateDataReader(); + + //Get the result + string strResult = ""; + while (drSQL.Read()) + { + strResult = drSQL[0].ToString(); + } + + //Display the results + MessageBox.Show("Return value from SQL call: " + strResult); + + ws.SqlParameter[] sqlparams = new ws.SqlParameter[0]; + + //Send a batch command to SQL + System.Data.DataSet dsReturnValue1 = (System.Data.DataSet)SQLWS.sqlbatch("SELECT * FROM sys.http_endpoints", ref sqlparams).GetValue(0); + + //Get the reader associated with our Dataset + System.Data.DataTableReader drSQL1 = dsReturnValue1.CreateDataReader(); + + //Get the result + string strResult1 = ""; + while (drSQL1.Read()) + { + strResult1 = drSQL1[0].ToString(); + } + + //Display the results + MessageBox.Show("Return value from SQL call: " + strResult1); + + } + + private void button2_Click(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Program.cs b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Program.cs new file mode 100644 index 0000000..e2338d4 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Program.cs @@ -0,0 +1,24 @@ +#region Using directives + +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +#endregion + +namespace SQLWS_App +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + //Application.EnableRTLMirroring(); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/AssemblyInfo.cs b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..498f53f --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +#region Using directives + +using System.Reflection; +using System.Runtime.CompilerServices; + +#endregion + +// 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. +[assembly: AssemblyTitle("SQLWS_App")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SQLWS_App")] +[assembly: AssemblyCopyright("Copyright @ Microsoft 2004")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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 Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Resources.cs b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Resources.cs new file mode 100644 index 0000000..c7a2def --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Resources.cs @@ -0,0 +1,61 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.40426.20 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SQLWS_App.Properties { + using System; + using System.IO; + using System.Resources; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the Strongly Typed Resource Builder + // class via a tool like ResGen or Visual Studio.NET. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + class Resources { + + private static System.Resources.ResourceManager _resMgr; + + private static System.Globalization.CultureInfo _resCulture; + + /*FamANDAssem*/ internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Resources.ResourceManager ResourceManager { + get { + if ((_resMgr == null)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("SQLWS_App.Properties.Resources", typeof(Resources).Assembly); + _resMgr = temp; + } + return _resMgr; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Globalization.CultureInfo Culture { + get { + return _resCulture; + } + set { + _resCulture = value; + } + } + } +} diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Resources.resx b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Resources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Settings.Designer.cs b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Settings.Designer.cs new file mode 100644 index 0000000..7fe734e --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Settings.Designer.cs @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.26 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SQLWS_App.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)] + [global::System.Configuration.DefaultSettingValueAttribute("http://localhost/sql/sample")] + public string SQLWS_App_ws_SQLWS_endpoint { + get { + return ((string)(this["SQLWS_App_ws_SQLWS_endpoint"])); + } + } + } +} diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Settings.settings b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Settings.settings new file mode 100644 index 0000000..a0b113c --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + http://localhost/sql/sample + + + \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/SQLWS_App.csproj b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/SQLWS_App.csproj new file mode 100644 index 0000000..e745eb8 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/SQLWS_App.csproj @@ -0,0 +1,114 @@ + + + Debug + 8.0.50727 + 2.0 + {BFE6A6D3-A641-4A0A-A1D8-E6102288B40E} + WinExe + SQLWS_App + SQLWS_App + 4 + + + true + full + false + .\bin\Debug\ + DEBUG;TRACE + + + false + true + .\bin\Release\ + TRACE + + + + False + + + False + + + False + + + ..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v2.0.40426\System.EnterpriseServices.dll + False + + + ..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v2.0.40426\System.Web.Services.dll + False + + + False + + + False + + + + + Form + + + Form1.cs + + + + + ResXFileCodeGenerator + Resources.cs + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + True + Settings.settings + + + True + True + Reference.map + + + + + + + + + Dynamic + Web References\ws\ + http://localhost/sql/sample%3fwsdl + + + + + Settings + SQLWS_App_ws_SQLWS_endpoint + + + + + + + + MSDiscoCodeGenerator + Reference.cs + + + Reference.map + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/SQLWS_App.csproj.user b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/SQLWS_App.csproj.user new file mode 100644 index 0000000..7a89310 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/SQLWS_App.csproj.user @@ -0,0 +1,7 @@ + + + 8.0.40426 + ProjectFiles + 0 + + \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/Reference.cs b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/Reference.cs new file mode 100644 index 0000000..081020c --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/Reference.cs @@ -0,0 +1,775 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.26 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// +// This source code was auto-generated by Microsoft.VSDesigner, Version 2.0.50727.26. +// +#pragma warning disable 1591 + +namespace SQLWS_App.ws { + using System.Diagnostics; + using System.Web.Services; + using System.ComponentModel; + using System.Web.Services.Protocols; + using System; + using System.Xml.Serialization; + using System.Data; + using System.Data.SqlTypes; + + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.26")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Web.Services.WebServiceBindingAttribute(Name="SQLWS_endpointSoap", Namespace="http://tempuri.org")] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(xml))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(SqlParameter[]))] + public partial class SQLWS_endpoint : System.Web.Services.Protocols.SoapHttpClientProtocol { + + private System.Threading.SendOrPostCallback sqlbatchOperationCompleted; + + private System.Threading.SendOrPostCallback SQLWSOperationCompleted; + + private bool useDefaultCredentialsSetExplicitly; + + /// + public SQLWS_endpoint() { + this.Url = global::SQLWS_App.Properties.Settings.Default.SQLWS_App_ws_SQLWS_endpoint; + if ((this.IsLocalFileSystemWebService(this.Url) == true)) { + this.UseDefaultCredentials = true; + this.useDefaultCredentialsSetExplicitly = false; + } + else { + this.useDefaultCredentialsSetExplicitly = true; + } + } + + public new string Url { + get { + return base.Url; + } + set { + if ((((this.IsLocalFileSystemWebService(base.Url) == true) + && (this.useDefaultCredentialsSetExplicitly == false)) + && (this.IsLocalFileSystemWebService(value) == false))) { + base.UseDefaultCredentials = false; + } + base.Url = value; + } + } + + public new bool UseDefaultCredentials { + get { + return base.UseDefaultCredentials; + } + set { + base.UseDefaultCredentials = value; + this.useDefaultCredentialsSetExplicitly = true; + } + } + + /// + public event sqlbatchCompletedEventHandler sqlbatchCompleted; + + /// + public event SQLWSCompletedEventHandler SQLWSCompleted; + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://schemas.microsoft.com/sqlserver/2004/SOAPsqlbatch", RequestNamespace="http://schemas.microsoft.com/sqlserver/2004/SOAP", ResponseNamespace="http://schemas.microsoft.com/sqlserver/2004/SOAP", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + [return: System.Xml.Serialization.XmlArrayItemAttribute(typeof(SqlMessage), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + [return: System.Xml.Serialization.XmlArrayItemAttribute("SqlResultCode", typeof(int), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + [return: System.Xml.Serialization.XmlArrayItemAttribute(typeof(SqlRowCount), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + [return: System.Xml.Serialization.XmlArrayItemAttribute("SqlRowSet", typeof(System.Data.DataSet), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + [return: System.Xml.Serialization.XmlArrayItemAttribute(typeof(SqlTransaction), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + [return: System.Xml.Serialization.XmlArrayItemAttribute("SqlXml", typeof(System.Xml.XmlNode), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + public object[] sqlbatch(string BatchCommands, [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true)] [System.Xml.Serialization.XmlArrayItemAttribute(Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlParameter", IsNullable=false)] ref SqlParameter[] Parameters) { + object[] results = this.Invoke("sqlbatch", new object[] { + BatchCommands, + Parameters}); + Parameters = ((SqlParameter[])(results[1])); + return ((object[])(results[0])); + } + + /// + public void sqlbatchAsync(string BatchCommands, SqlParameter[] Parameters) { + this.sqlbatchAsync(BatchCommands, Parameters, null); + } + + /// + public void sqlbatchAsync(string BatchCommands, SqlParameter[] Parameters, object userState) { + if ((this.sqlbatchOperationCompleted == null)) { + this.sqlbatchOperationCompleted = new System.Threading.SendOrPostCallback(this.OnsqlbatchOperationCompleted); + } + this.InvokeAsync("sqlbatch", new object[] { + BatchCommands, + Parameters}, this.sqlbatchOperationCompleted, userState); + } + + private void OnsqlbatchOperationCompleted(object arg) { + if ((this.sqlbatchCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.sqlbatchCompleted(this, new sqlbatchCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SQLWS", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + [return: System.Xml.Serialization.XmlArrayItemAttribute(typeof(SqlMessage), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + [return: System.Xml.Serialization.XmlArrayItemAttribute("SqlResultCode", typeof(int), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + [return: System.Xml.Serialization.XmlArrayItemAttribute(typeof(SqlRowCount), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + [return: System.Xml.Serialization.XmlArrayItemAttribute("SqlRowSet", typeof(System.Data.DataSet), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + [return: System.Xml.Serialization.XmlArrayItemAttribute(typeof(SqlTransaction), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + [return: System.Xml.Serialization.XmlArrayItemAttribute("SqlXml", typeof(System.Xml.XmlNode), Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream", IsNullable=false)] + public object[] SQLWS([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] System.Data.SqlTypes.SqlString msg) { + object[] results = this.Invoke("SQLWS", new object[] { + msg}); + return ((object[])(results[0])); + } + + /// + public void SQLWSAsync(System.Data.SqlTypes.SqlString msg) { + this.SQLWSAsync(msg, null); + } + + /// + public void SQLWSAsync(System.Data.SqlTypes.SqlString msg, object userState) { + if ((this.SQLWSOperationCompleted == null)) { + this.SQLWSOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSQLWSOperationCompleted); + } + this.InvokeAsync("SQLWS", new object[] { + msg}, this.SQLWSOperationCompleted, userState); + } + + private void OnSQLWSOperationCompleted(object arg) { + if ((this.SQLWSCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SQLWSCompleted(this, new SQLWSCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + public new void CancelAsync(object userState) { + base.CancelAsync(userState); + } + + private bool IsLocalFileSystemWebService(string url) { + if (((url == null) + || (url == string.Empty))) { + return false; + } + System.Uri wsUri = new System.Uri(url); + if (((wsUri.Port >= 1024) + && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) { + return true; + } + return false; + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.26")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlParameter")] + public partial class SqlParameter { + + private object valueField; + + private string nameField; + + private sqlDbTypeEnum sqlDbTypeField; + + private ParameterDirection directionField; + + private long maxLengthField; + + private byte precisionField; + + private byte scaleField; + + private string clrTypeNameField; + + private sqlCompareOptionsEnum[] sqlCompareOptionsField; + + private int localeIdField; + + private int sqlCollationVersionField; + + private int sqlSortIdField; + + private string xmlSchemaCollectionField; + + public SqlParameter() { + this.sqlDbTypeField = sqlDbTypeEnum.NVarChar; + this.directionField = ParameterDirection.Input; + this.maxLengthField = ((long)(1)); + this.precisionField = ((byte)(18)); + this.scaleField = ((byte)(0)); + this.clrTypeNameField = ""; + this.sqlCompareOptionsField = new sqlCompareOptionsEnum[] { + sqlCompareOptionsEnum.Default}; + this.localeIdField = -1; + this.sqlCollationVersionField = 0; + this.sqlSortIdField = 0; + this.xmlSchemaCollectionField = ""; + } + + /// + [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] + public object Value { + get { + return this.valueField; + } + set { + this.valueField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string name { + get { + return this.nameField; + } + set { + this.nameField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(sqlDbTypeEnum.NVarChar)] + public sqlDbTypeEnum sqlDbType { + get { + return this.sqlDbTypeField; + } + set { + this.sqlDbTypeField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(ParameterDirection.Input)] + public ParameterDirection direction { + get { + return this.directionField; + } + set { + this.directionField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(typeof(long), "1")] + public long maxLength { + get { + return this.maxLengthField; + } + set { + this.maxLengthField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(typeof(byte), "18")] + public byte precision { + get { + return this.precisionField; + } + set { + this.precisionField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(typeof(byte), "0")] + public byte scale { + get { + return this.scaleField; + } + set { + this.scaleField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute("")] + public string clrTypeName { + get { + return this.clrTypeNameField; + } + set { + this.clrTypeNameField = value; + } + } + + /// + // CODEGEN Warning: DefaultValue attribute on members of type sqlCompareOptionsEnum[] is not supported in this version of the .Net Framework. + [System.Xml.Serialization.XmlAttributeAttribute()] + public sqlCompareOptionsEnum[] sqlCompareOptions { + get { + return this.sqlCompareOptionsField; + } + set { + this.sqlCompareOptionsField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(-1)] + public int localeId { + get { + return this.localeIdField; + } + set { + this.localeIdField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(0)] + public int sqlCollationVersion { + get { + return this.sqlCollationVersionField; + } + set { + this.sqlCollationVersionField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(0)] + public int sqlSortId { + get { + return this.sqlSortIdField; + } + set { + this.sqlSortIdField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute("")] + public string xmlSchemaCollection { + get { + return this.xmlSchemaCollectionField; + } + set { + this.xmlSchemaCollectionField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.26")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlTransaction")] + public partial class SqlTransaction { + + private byte[] descriptorField; + + private SqlTransactionType typeField; + + /// + [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] + public byte[] Descriptor { + get { + return this.descriptorField; + } + set { + this.descriptorField = value; + } + } + + /// + public SqlTransactionType Type { + get { + return this.typeField; + } + set { + this.typeField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.26")] + [System.SerializableAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] + public enum SqlTransactionType { + + /// + Begin, + + /// + Commit, + + /// + Rollback, + + /// + EnlistDTC, + + /// + Defect, + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.26")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes")] + public partial class xml { + + private System.Xml.XmlNode[] anyField; + + /// + [System.Xml.Serialization.XmlTextAttribute()] + [System.Xml.Serialization.XmlAnyElementAttribute()] + public System.Xml.XmlNode[] Any { + get { + return this.anyField; + } + set { + this.anyField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.26")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlRowCount")] + public partial class SqlRowCount { + + private long countField; + + /// + public long Count { + get { + return this.countField; + } + set { + this.countField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.26")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlMessage")] + public partial class SqlMessage { + + private int classField; + + private int lineNumberField; + + private string messageField; + + private int numberField; + + private string procedureField; + + private string serverField; + + private string sourceField; + + private int stateField; + + /// + public int Class { + get { + return this.classField; + } + set { + this.classField = value; + } + } + + /// + public int LineNumber { + get { + return this.lineNumberField; + } + set { + this.lineNumberField = value; + } + } + + /// + public string Message { + get { + return this.messageField; + } + set { + this.messageField = value; + } + } + + /// + public int Number { + get { + return this.numberField; + } + set { + this.numberField = value; + } + } + + /// + public string Procedure { + get { + return this.procedureField; + } + set { + this.procedureField = value; + } + } + + /// + public string Server { + get { + return this.serverField; + } + set { + this.serverField = value; + } + } + + /// + public string Source { + get { + return this.sourceField; + } + set { + this.sourceField = value; + } + } + + /// + public int State { + get { + return this.stateField; + } + set { + this.stateField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.26")] + [System.SerializableAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes")] + public enum sqlDbTypeEnum { + + /// + BigInt, + + /// + Binary, + + /// + Bit, + + /// + Char, + + /// + DateTime, + + /// + Decimal, + + /// + Float, + + /// + Image, + + /// + Int, + + /// + Money, + + /// + NChar, + + /// + NText, + + /// + NVarChar, + + /// + Real, + + /// + SmallDateTime, + + /// + SmallInt, + + /// + SmallMoney, + + /// + Text, + + /// + Timestamp, + + /// + TinyInt, + + /// + Udt, + + /// + UniqueIdentifier, + + /// + VarBinary, + + /// + VarChar, + + /// + Variant, + + /// + Xml, + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.26")] + [System.SerializableAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlParameter")] + public enum ParameterDirection { + + /// + Input, + + /// + InputOutput, + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.26")] + [System.SerializableAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes")] + public enum sqlCompareOptionsEnum { + + /// + Default, + + /// + None, + + /// + IgnoreCase, + + /// + IgnoreNonSpace, + + /// + IgnoreKanaType, + + /// + IgnoreWidth, + + /// + BinarySort, + + /// + BinarySort2, + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.26")] + public delegate void sqlbatchCompletedEventHandler(object sender, sqlbatchCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.26")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class sqlbatchCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal sqlbatchCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public object[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((object[])(this.results[0])); + } + } + + /// + public SqlParameter[] Parameters { + get { + this.RaiseExceptionIfNecessary(); + return ((SqlParameter[])(this.results[1])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.26")] + public delegate void SQLWSCompletedEventHandler(object sender, SQLWSCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.26")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class SQLWSCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal SQLWSCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public object[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((object[])(this.results[0])); + } + } + } +} + +#pragma warning restore 1591 \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/Reference.map b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/Reference.map new file mode 100644 index 0000000..37cf0c6 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/Reference.map @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/SqlParameter.datasource b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/SqlParameter.datasource new file mode 100644 index 0000000..7166c4c --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/SqlParameter.datasource @@ -0,0 +1,10 @@ + + + + SQLWS_App.ws.SqlParameter, Web References.ws.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/sample.wsdl b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/sample.wsdl new file mode 100644 index 0000000..2a11ffa --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/Web References/ws/sample.wsdl @@ -0,0 +1,637 @@ + + + + + + +XML Schema describing the base types to which SQL Server types are being mapped. For more information, please consult the documentation. + +(c) Copyright 2004, Microsoft Corporation + +The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema. + +Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis. Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate. + +MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +(c) Copyright 2004, Microsoft Corporation + +The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema. + +Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis. Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate. + +MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES. + + + + + + + + + + + + + + + + + + + + + + + +(c) Copyright 2004, Microsoft Corporation + +The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema. + +Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis. Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate. + +MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES. + + + + + + + + + + + + + + + + + + + + + + +(c) Copyright 2004, Microsoft Corporation + +The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema. + +Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis. Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate. + +MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES. + + + + + + + + + + + +(c) Copyright 2004, Microsoft Corporation + +The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema. + +Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis. Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate. + +MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES. + + + + + + + + + + + + + + + + + + + + + + + + + + + +(c) Copyright 2004, Microsoft Corporation + +The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema. + +Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis. Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate. + +MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES. + + + + + + + + + + + + + + + + +(c) Copyright 2004, Microsoft Corporation + +The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema. + +Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis. Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate. + +MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES. + + + + + Set initial database on login. + + + + + The name of the initial database to attach to. + + + + + Whether the initial database is optional or not. + + + + + The filename of the database to attach to. + + + + + + + Set initial language to set. + + + + + The name of the initial language to set. + + + + + Whether the initial language is optional or not. + + + + + + + Receive environment change notifications. + + + + + Receive notifications of database changes. + + + + + Receive notifications of language changes. + + + + + Receive notifications of transaction boundaries. + + + + + + + Set the application name for the login. + + + + + The application name to set for the login. + + + + + + + Set the host name for the login. + + + + + The host name to set for the login. + + + + + + + Set the client process ID for the login. + + + + + The client process ID to set for the login. + + + + + + + Set the client network ID for the login. + + + + + The client network ID to set for the login. + + + + + + + Set the client interface for the login. + + + + + The client interface to set for the login. + + + + + + + Requests query notifications for the request. + + + + + The notification identifier. + + + + + The delivery service. + + + + + The timeout value. + + + + + + + SQL Server SOAP Session + + + + + Set to 'true' to request to start a new session. + + + + + Set to 'true' to request to terminate an existing session. + + + + + The ID of a session. + + + + + The timeout in seconds before the session expires. + + + + + The descriptor of a transaction to enlist to. + + + + + + + + + +(c) Copyright 2004, Microsoft Corporation + +The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema. + +Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis. Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate. + +MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/app.config b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/app.config new file mode 100644 index 0000000..74f4de7 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/app.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + http://localhost/sql/sample + + + + diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.exe b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.exe new file mode 100644 index 0000000..16df04b Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.exe differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.exe.config b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.exe.config new file mode 100644 index 0000000..74f4de7 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.exe.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + http://localhost/sql/sample + + + + diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.pdb b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.pdb new file mode 100644 index 0000000..e4ddae3 Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.pdb differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.vshost.exe b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.vshost.exe new file mode 100644 index 0000000..72b0f71 Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.vshost.exe differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.vshost.exe.config b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.vshost.exe.config new file mode 100644 index 0000000..74f4de7 --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/bin/Debug/SQLWS_App.vshost.exe.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + http://localhost/sql/sample + + + + diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/ResGen.cache b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/ResGen.cache new file mode 100644 index 0000000..105c521 Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/ResGen.cache differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.Properties.Resources.resources b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.Properties.Resources.resources differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.csproj.GenerateResource.Cache b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.csproj.GenerateResource.Cache new file mode 100644 index 0000000..80ca42b Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.csproj.GenerateResource.Cache differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.exe b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.exe new file mode 100644 index 0000000..16df04b Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.exe differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.pdb b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.pdb new file mode 100644 index 0000000..e4ddae3 Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/SQLWS_App.pdb differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/TempPE/Properties.Resources.cs.dll b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/TempPE/Properties.Resources.cs.dll new file mode 100644 index 0000000..b25bea9 Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/TempPE/Properties.Resources.cs.dll differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/TempPE/Web References.sqlws.Reference.cs.dll b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/TempPE/Web References.sqlws.Reference.cs.dll new file mode 100644 index 0000000..f41ff95 Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/TempPE/Web References.sqlws.Reference.cs.dll differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/TempPE/Web References.ws.Reference.cs.dll b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/TempPE/Web References.ws.Reference.cs.dll new file mode 100644 index 0000000..ec0b395 Binary files /dev/null and b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/Debug/TempPE/Web References.ws.Reference.cs.dll differ diff --git a/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/SQLWS_App.csproj.FileList.txt b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/SQLWS_App.csproj.FileList.txt new file mode 100644 index 0000000..117177c --- /dev/null +++ b/1590594770-1/Chapter08/SQLWS_App/SQLWS_App/obj/SQLWS_App.csproj.FileList.txt @@ -0,0 +1,8 @@ +.\bin\Debug\SQLWS_App.exe.config +obj\Debug\SQLWS_App.exe +obj\Debug\SQLWS_App.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\SQLWS_App.Properties.Resources.resources +obj\Debug\SQLWS_App.csproj.GenerateResource.Cache +.\bin\Debug\SQLWS_App.exe +.\bin\Debug\SQLWS_App.pdb diff --git a/1590594770-1/Chapter08/XMLSample.sql b/1590594770-1/Chapter08/XMLSample.sql new file mode 100644 index 0000000..cb3f662 Binary files /dev/null and b/1590594770-1/Chapter08/XMLSample.sql differ diff --git a/1590594770-1/Chapter08/peopleXML.xml b/1590594770-1/Chapter08/peopleXML.xml new file mode 100644 index 0000000..e39a25d --- /dev/null +++ b/1590594770-1/Chapter08/peopleXML.xml @@ -0,0 +1,27 @@ + + + + + Martin + Smith + + 33 + short + + + + Stacy + Eckstein + + 40 + short + + + + Tom + Rizzo + + 30 + medium + + diff --git a/1590594770-1/Chapter08/readme.txt b/1590594770-1/Chapter08/readme.txt new file mode 100644 index 0000000..6c1753e --- /dev/null +++ b/1590594770-1/Chapter08/readme.txt @@ -0,0 +1,17 @@ +These sample applications show you how to use the new XML datatype, XQuery and Web Services support in SQL Server 2005. + +To use the applications, please follow these steps: + +1) Double-click the XMLSample.sql file to launch Management Studio which will load the file. + +2) Once loaded, follow the instructions in the file. Make sure to change the file paths in the sample to the location where you installed the sample such as c:\samples\ + +3) In order to use the Web Services sample application, you must run the section at the end of the file called ENDPOINT SAMPLE before attempting to use the Windows Forms Web Services sample application. + +4) If you want to try the Windows Forms Web Services Sample Application, double click SQLWS_App.sln in the SQLWS_App directory. Visual Studio should launch. + +5) Hit ctrl-F5 to start the application without debugging. + +6) Click the button Click for SQL Web Service. + +7) If successful, you should get 2 message boxes. The first one shows success in calling a stored procedure as a web service. The second shows sending T-SQL commands to the server. \ No newline at end of file diff --git a/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1.sln b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1.sln new file mode 100644 index 0000000..e3b5f4d --- /dev/null +++ b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1.sln @@ -0,0 +1,17 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{D183A3D8-5FD8-494B-B014-37F57B35E655}") = "Integration Services Project1", "Integration Services Project1\Integration Services Project1.dtproj", "{DE45F28A-957B-4761-B47F-FDD6AA3CD9BA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Development|Default = Development|Default + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DE45F28A-957B-4761-B47F-FDD6AA3CD9BA}.Development|Default.ActiveCfg = Development + {DE45F28A-957B-4761-B47F-FDD6AA3CD9BA}.Development|Default.Build.0 = Development + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1.suo b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1.suo new file mode 100644 index 0000000..aa08533 Binary files /dev/null and b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1.suo differ diff --git a/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Adventure Works.ds b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Adventure Works.ds new file mode 100644 index 0000000..3481477 --- /dev/null +++ b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Adventure Works.ds @@ -0,0 +1,10 @@ + + Adventure Works + Adventure Works + 0001-01-01T00:00:00Z + 0001-01-01T00:00:00Z + Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security=True + Unchanged + System.Data.SqlClient + PT0S + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Adventure Works.dsv b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Adventure Works.dsv new file mode 100644 index 0000000..03a7cd0 --- /dev/null +++ b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Adventure Works.dsv @@ -0,0 +1,328 @@ + + Adventure Works + Adventure Works + 0001-01-01T00:00:00Z + 0001-01-01T00:00:00Z + + + http://schemas.microsoft.com/DataWarehouse/Designer/1.0:ShowFriendlyNames + true + + + http://schemas.microsoft.com/DataWarehouse/Designer/1.0:CurrentLayout + _ALL_TABLES_ + + + http://schemas.microsoft.com/DataWarehouse/Designer/1.0:NameMatchingCriteria + 1 + + + http://schemas.microsoft.com/DataWarehouse/Designer/1.0:Layouts + + + + _ALL_TABLES_ + + False + True + 0 + 0 + 0 + 0 + 100 + + + + + + Adventure Works + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Integration Services Project1.database b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Integration Services Project1.database new file mode 100644 index 0000000..ac7c492 --- /dev/null +++ b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Integration Services Project1.database @@ -0,0 +1,13 @@ + + Integration Services Project1 + Integration Services Project1 + 0001-01-01T00:00:00Z + 0001-01-01T00:00:00Z + 0001-01-01T00:00:00Z + Unprocessed + 0001-01-01T00:00:00Z + + Default + Unchanged + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Integration Services Project1.dtproj b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Integration Services Project1.dtproj new file mode 100644 index 0000000..ee2943a --- /dev/null +++ b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Integration Services Project1.dtproj @@ -0,0 +1,64 @@ + + + + + Package.dtsx + Package.dtsx + + + + 9.0.1187.0 + 9.0.1.0 + $base64$PFNvdXJjZUNvbnRyb2xJbmZvIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOmR3ZD0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9EYXRhV2FyZWhvdXNlL0Rlc2lnbmVyLzEuMCI+DQogIDxFbmFibGVkPmZhbHNlPC9FbmFibGVkPg0KICA8UHJvamVjdE5hbWU+PC9Qcm9qZWN0TmFtZT4NCiAgPEF1eFBhdGg+PC9BdXhQYXRoPg0KICA8TG9jYWxQYXRoPjwvTG9jYWxQYXRoPg0KICA8UHJvdmlkZXI+PC9Qcm92aWRlcj4NCjwvU291cmNlQ29udHJvbEluZm8+ + + Integration Services Project1.database + Integration Services Project1.database + + + + + + Adventure Works.ds + Adventure Works.ds + + + + + Adventure Works.dsv + Adventure Works.dsv + + + + + + + + Development + + bin + true + + + Adventure Works + Adventure Works + Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security=True + + + + + Adventure Works + Adventure Works + System.Data.SqlClient + + + + + Adventure Works + Adventure Works + 0 + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Integration Services Project1.dtproj.user b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Integration Services Project1.dtproj.user new file mode 100644 index 0000000..45d5fb7 --- /dev/null +++ b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Integration Services Project1.dtproj.user @@ -0,0 +1,13 @@ + + + + + Development + + + + false + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Package.dtsx b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Package.dtsx new file mode 100644 index 0000000..7c20152 --- /dev/null +++ b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/Package.dtsx @@ -0,0 +1,165 @@ +2THOMRIZDB2\AdministratorTHOMRIZDB26/8/2005 6:18:03 PM51-10102{1B7D569E-A20E-4AC9-B25B-EDB1AEED7286}0000 +localhost.AdventureWorks{6018E400-6ACD-4500-AACC-2D9BA23AE9DD}ADO.NET:System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security=True; +<TaskHost xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0"><dwd:DtsDataFlowDiagram><dwd:BoundingTop>3889</dwd:BoundingTop><dwd:Layout><dds> + <diagram fontclsid="{0BE35203-8F91-11CE-9DE3-00AA004BB851}" mouseiconclsid="{0BE35204-8F91-11CE-9DE3-00AA004BB851}" defaultlayout="Microsoft.DataWarehouse.Layout.GraphLayout" defaultlineroute="Microsoft.DataWarehouse.Layout.GraphLayout" version="7" nextobject="8" scale="100" pagebreakanchorx="0" pagebreakanchory="0" pagebreaksizex="0" pagebreaksizey="0" scrollleft="0" scrolltop="0" gridx="150" gridy="150" marginx="1000" marginy="1000" zoom="100" x="19050" y="18653" backcolor="15334399" defaultpersistence="2" PrintPageNumbersMode="3" PrintMarginTop="0" PrintMarginBottom="635" PrintMarginLeft="0" PrintMarginRight="0" marqueeselectionmode="1" mousepointer="0" snaptogrid="0" autotypeannotation="1" showscrollbars="0" viewpagebreaks="0" donotforceconnectorsbehindshapes="0" backpictureclsid="{00000000-0000-0000-0000-000000000000}"> + <font> + <ddsxmlobjectstreamwrapper binary="01010000900180380100065461686f6d61" /> + </font> + <mouseicon> + <ddsxmlobjectstreamwrapper binary="6c74000000000000" /> + </mouseicon> + </diagram> + <layoutmanager> + <ddsxmlobj /> + </layoutmanager> + <ddscontrol controlprogid="DdsShapes.DdsObjectManagedBridge.1" tooltip="DataReader Source Adapter" left="5609" top="3889" logicalid="5" controlid="5" masterid="0" hint1="0" hint2="0" width="3598" height="1164" noresize="0" nomove="0" nodefaultattachpoints="0" autodrag="1" usedefaultiddshape="1" selectable="1" showselectionhandles="1" allownudging="1" isannotation="0" dontautolayout="0" groupcollapsed="0" tabstop="1" visible="1" snaptogrid="0"> + <control> + <ddsxmlobjectstreaminitwrapper binary="000800000e0e00008c040000" /> + </control> + <layoutobject> + <ddsxmlobj> + <property name="LogicalObject" value="{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}/components/29" vartype="8" /> + <property name="ShowConnectorSource" value="0" vartype="2" /> + </ddsxmlobj> + </layoutobject> + <shape groupshapeid="0" groupnode="0" /> + </ddscontrol> + <ddscontrol controlprogid="DdsShapes.DdsObjectManagedBridge.1" tooltip="DataReader Destination Adapter" left="7064" top="12965" logicalid="6" controlid="6" masterid="0" hint1="0" hint2="0" width="3598" height="1164" noresize="0" nomove="0" nodefaultattachpoints="0" autodrag="1" usedefaultiddshape="1" selectable="1" showselectionhandles="1" allownudging="1" isannotation="0" dontautolayout="0" groupcollapsed="0" tabstop="1" visible="1" snaptogrid="0"> + <control> + <ddsxmlobjectstreaminitwrapper binary="000800000e0e00008c040000" /> + </control> + <layoutobject> + <ddsxmlobj> + <property name="LogicalObject" value="{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}/components/56" vartype="8" /> + <property name="ShowConnectorSource" value="0" vartype="2" /> + </ddsxmlobj> + </layoutobject> + <shape groupshapeid="0" groupnode="0" /> + </ddscontrol> + <ddscontrol controlprogid="MSDDS.Polyline" left="7009" top="4654" logicalid="7" controlid="7" masterid="0" hint1="0" hint2="0" width="2254" height="8811" noresize="0" nomove="0" nodefaultattachpoints="1" autodrag="0" usedefaultiddshape="0" selectable="1" showselectionhandles="0" allownudging="1" isannotation="0" dontautolayout="0" groupcollapsed="0" tabstop="1" visible="1" snaptogrid="0"> + <control> + <ddsxmlobj> + <polyline endtypedst="3" endtypesrc="1" usercolor="32768" linestyle="0" linerender="1" customendtypedstid="0" customendtypesrcid="0" adornsvisible="1" /> + </ddsxmlobj> + </control> + <layoutobject> + <ddsxmlobj> + <property name="LogicalObject" value="{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}/paths/107" vartype="8" /> + <property name="Virtual" value="0" vartype="11" /> + <property name="VisibleAP" value="0" vartype="3" /> + </ddsxmlobj> + </layoutobject> + <connector lineroutestyle="Microsoft.DataWarehouse.Layout.GraphLayout" sourceid="5" destid="6" sourceattachpoint="7" destattachpoint="6" segmenteditmode="0" bendpointeditmode="0" bendpointvisibility="2" relatedid="0" virtual="0"> + <point x="7408" y="5053" /> + <point x="7408" y="9009" /> + <point x="8863" y="9009" /> + <point x="8863" y="12965" /> + </connector> + </ddscontrol> +</dds></dwd:Layout></dwd:DtsDataFlowDiagram></TaskHost>dts-designer-1.0{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}{10107CA6-32AB-4A38-9FC2-DB4B89AFA53A} +<PipelinePath xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0"><dwd:PathAnnotation>AsNeeded</dwd:PathAnnotation><dwd:DestinationName>DataReader Destination Input</dwd:DestinationName><dwd:SourceName>DataReader Output</dwd:SourceName></PipelinePath>dts-designer-1.0{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}-107{4D99BD22-F58D-4A50-9DCA-78861C28DAC5} +<Package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0"><dwd:DtsControlFlowDiagram><dwd:Layout><dds> + <diagram fontclsid="{0BE35203-8F91-11CE-9DE3-00AA004BB851}" mouseiconclsid="{0BE35204-8F91-11CE-9DE3-00AA004BB851}" defaultlayout="Microsoft.DataWarehouse.Layout.GraphLayout" defaultlineroute="Microsoft.DataWarehouse.Layout.GraphLayout" version="7" nextobject="4" scale="100" pagebreakanchorx="0" pagebreakanchory="0" pagebreaksizex="0" pagebreaksizey="0" scrollleft="0" scrolltop="0" gridx="150" gridy="150" marginx="1000" marginy="1000" zoom="100" x="19050" y="19579" backcolor="15334399" defaultpersistence="2" PrintPageNumbersMode="3" PrintMarginTop="0" PrintMarginBottom="635" PrintMarginLeft="0" PrintMarginRight="0" marqueeselectionmode="1" mousepointer="0" snaptogrid="0" autotypeannotation="1" showscrollbars="0" viewpagebreaks="0" donotforceconnectorsbehindshapes="1" backpictureclsid="{00000000-0000-0000-0000-000000000000}"> + <font> + <ddsxmlobjectstreamwrapper binary="01010000900180380100065461686f6d61" /> + </font> + <mouseicon> + <ddsxmlobjectstreamwrapper binary="6c74000000000000" /> + </mouseicon> + </diagram> + <layoutmanager> + <ddsxmlobj /> + </layoutmanager> + <ddscontrol controlprogid="DdsShapes.DdsObjectManagedBridge.1" tooltip="Data Flow Task" left="0" top="0" logicalid="3" controlid="3" masterid="0" hint1="0" hint2="0" width="3598" height="1164" noresize="0" nomove="0" nodefaultattachpoints="0" autodrag="1" usedefaultiddshape="1" selectable="1" showselectionhandles="1" allownudging="1" isannotation="0" dontautolayout="0" groupcollapsed="0" tabstop="1" visible="1" snaptogrid="0"> + <control> + <ddsxmlobjectstreaminitwrapper binary="000800000e0e00008c040000" /> + </control> + <layoutobject> + <ddsxmlobj> + <property name="LogicalObject" value="{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}" vartype="8" /> + <property name="ShowConnectorSource" value="0" vartype="2" /> + </ddsxmlobj> + </layoutobject> + <shape groupshapeid="0" groupnode="0" /> + </ddscontrol> +</dds></dwd:Layout></dwd:DtsControlFlowDiagram></Package>dts-designer-1.0{E246A403-57B7-4CF1-9B0F-7C48C7619AEA}{1194FB41-A8F6-41D0-9C07-EF8554C76078}00-100011048576103310 +01 +000-100011048576-110 +01Data Flow Task{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}Data Flow Task{C3BF9DC1-4715-4694-936F-D3CFDA9E42C5}0 + + + +EXEC GetProducts +Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter, Microsoft.SqlServer.ADONETSrc, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +30000 + +false +Microsoft.SqlServer.Dts.Pipeline.DataReaderDestinationAdapter, Microsoft.SqlServer.DataReaderDest, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 + + + + + + + + + + + + + + + + + + + + +Package{E246A403-57B7-4CF1-9B0F-7C48C7619AEA}MSDTS.Package.10 \ No newline at end of file diff --git a/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/bin/Package.dtsx b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/bin/Package.dtsx new file mode 100644 index 0000000..7c20152 --- /dev/null +++ b/1590594770-1/Chapter09/Integration Services Project1/Integration Services Project1/bin/Package.dtsx @@ -0,0 +1,165 @@ +2THOMRIZDB2\AdministratorTHOMRIZDB26/8/2005 6:18:03 PM51-10102{1B7D569E-A20E-4AC9-B25B-EDB1AEED7286}0000 +localhost.AdventureWorks{6018E400-6ACD-4500-AACC-2D9BA23AE9DD}ADO.NET:System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security=True; +<TaskHost xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0"><dwd:DtsDataFlowDiagram><dwd:BoundingTop>3889</dwd:BoundingTop><dwd:Layout><dds> + <diagram fontclsid="{0BE35203-8F91-11CE-9DE3-00AA004BB851}" mouseiconclsid="{0BE35204-8F91-11CE-9DE3-00AA004BB851}" defaultlayout="Microsoft.DataWarehouse.Layout.GraphLayout" defaultlineroute="Microsoft.DataWarehouse.Layout.GraphLayout" version="7" nextobject="8" scale="100" pagebreakanchorx="0" pagebreakanchory="0" pagebreaksizex="0" pagebreaksizey="0" scrollleft="0" scrolltop="0" gridx="150" gridy="150" marginx="1000" marginy="1000" zoom="100" x="19050" y="18653" backcolor="15334399" defaultpersistence="2" PrintPageNumbersMode="3" PrintMarginTop="0" PrintMarginBottom="635" PrintMarginLeft="0" PrintMarginRight="0" marqueeselectionmode="1" mousepointer="0" snaptogrid="0" autotypeannotation="1" showscrollbars="0" viewpagebreaks="0" donotforceconnectorsbehindshapes="0" backpictureclsid="{00000000-0000-0000-0000-000000000000}"> + <font> + <ddsxmlobjectstreamwrapper binary="01010000900180380100065461686f6d61" /> + </font> + <mouseicon> + <ddsxmlobjectstreamwrapper binary="6c74000000000000" /> + </mouseicon> + </diagram> + <layoutmanager> + <ddsxmlobj /> + </layoutmanager> + <ddscontrol controlprogid="DdsShapes.DdsObjectManagedBridge.1" tooltip="DataReader Source Adapter" left="5609" top="3889" logicalid="5" controlid="5" masterid="0" hint1="0" hint2="0" width="3598" height="1164" noresize="0" nomove="0" nodefaultattachpoints="0" autodrag="1" usedefaultiddshape="1" selectable="1" showselectionhandles="1" allownudging="1" isannotation="0" dontautolayout="0" groupcollapsed="0" tabstop="1" visible="1" snaptogrid="0"> + <control> + <ddsxmlobjectstreaminitwrapper binary="000800000e0e00008c040000" /> + </control> + <layoutobject> + <ddsxmlobj> + <property name="LogicalObject" value="{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}/components/29" vartype="8" /> + <property name="ShowConnectorSource" value="0" vartype="2" /> + </ddsxmlobj> + </layoutobject> + <shape groupshapeid="0" groupnode="0" /> + </ddscontrol> + <ddscontrol controlprogid="DdsShapes.DdsObjectManagedBridge.1" tooltip="DataReader Destination Adapter" left="7064" top="12965" logicalid="6" controlid="6" masterid="0" hint1="0" hint2="0" width="3598" height="1164" noresize="0" nomove="0" nodefaultattachpoints="0" autodrag="1" usedefaultiddshape="1" selectable="1" showselectionhandles="1" allownudging="1" isannotation="0" dontautolayout="0" groupcollapsed="0" tabstop="1" visible="1" snaptogrid="0"> + <control> + <ddsxmlobjectstreaminitwrapper binary="000800000e0e00008c040000" /> + </control> + <layoutobject> + <ddsxmlobj> + <property name="LogicalObject" value="{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}/components/56" vartype="8" /> + <property name="ShowConnectorSource" value="0" vartype="2" /> + </ddsxmlobj> + </layoutobject> + <shape groupshapeid="0" groupnode="0" /> + </ddscontrol> + <ddscontrol controlprogid="MSDDS.Polyline" left="7009" top="4654" logicalid="7" controlid="7" masterid="0" hint1="0" hint2="0" width="2254" height="8811" noresize="0" nomove="0" nodefaultattachpoints="1" autodrag="0" usedefaultiddshape="0" selectable="1" showselectionhandles="0" allownudging="1" isannotation="0" dontautolayout="0" groupcollapsed="0" tabstop="1" visible="1" snaptogrid="0"> + <control> + <ddsxmlobj> + <polyline endtypedst="3" endtypesrc="1" usercolor="32768" linestyle="0" linerender="1" customendtypedstid="0" customendtypesrcid="0" adornsvisible="1" /> + </ddsxmlobj> + </control> + <layoutobject> + <ddsxmlobj> + <property name="LogicalObject" value="{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}/paths/107" vartype="8" /> + <property name="Virtual" value="0" vartype="11" /> + <property name="VisibleAP" value="0" vartype="3" /> + </ddsxmlobj> + </layoutobject> + <connector lineroutestyle="Microsoft.DataWarehouse.Layout.GraphLayout" sourceid="5" destid="6" sourceattachpoint="7" destattachpoint="6" segmenteditmode="0" bendpointeditmode="0" bendpointvisibility="2" relatedid="0" virtual="0"> + <point x="7408" y="5053" /> + <point x="7408" y="9009" /> + <point x="8863" y="9009" /> + <point x="8863" y="12965" /> + </connector> + </ddscontrol> +</dds></dwd:Layout></dwd:DtsDataFlowDiagram></TaskHost>dts-designer-1.0{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}{10107CA6-32AB-4A38-9FC2-DB4B89AFA53A} +<PipelinePath xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0"><dwd:PathAnnotation>AsNeeded</dwd:PathAnnotation><dwd:DestinationName>DataReader Destination Input</dwd:DestinationName><dwd:SourceName>DataReader Output</dwd:SourceName></PipelinePath>dts-designer-1.0{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}-107{4D99BD22-F58D-4A50-9DCA-78861C28DAC5} +<Package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0"><dwd:DtsControlFlowDiagram><dwd:Layout><dds> + <diagram fontclsid="{0BE35203-8F91-11CE-9DE3-00AA004BB851}" mouseiconclsid="{0BE35204-8F91-11CE-9DE3-00AA004BB851}" defaultlayout="Microsoft.DataWarehouse.Layout.GraphLayout" defaultlineroute="Microsoft.DataWarehouse.Layout.GraphLayout" version="7" nextobject="4" scale="100" pagebreakanchorx="0" pagebreakanchory="0" pagebreaksizex="0" pagebreaksizey="0" scrollleft="0" scrolltop="0" gridx="150" gridy="150" marginx="1000" marginy="1000" zoom="100" x="19050" y="19579" backcolor="15334399" defaultpersistence="2" PrintPageNumbersMode="3" PrintMarginTop="0" PrintMarginBottom="635" PrintMarginLeft="0" PrintMarginRight="0" marqueeselectionmode="1" mousepointer="0" snaptogrid="0" autotypeannotation="1" showscrollbars="0" viewpagebreaks="0" donotforceconnectorsbehindshapes="1" backpictureclsid="{00000000-0000-0000-0000-000000000000}"> + <font> + <ddsxmlobjectstreamwrapper binary="01010000900180380100065461686f6d61" /> + </font> + <mouseicon> + <ddsxmlobjectstreamwrapper binary="6c74000000000000" /> + </mouseicon> + </diagram> + <layoutmanager> + <ddsxmlobj /> + </layoutmanager> + <ddscontrol controlprogid="DdsShapes.DdsObjectManagedBridge.1" tooltip="Data Flow Task" left="0" top="0" logicalid="3" controlid="3" masterid="0" hint1="0" hint2="0" width="3598" height="1164" noresize="0" nomove="0" nodefaultattachpoints="0" autodrag="1" usedefaultiddshape="1" selectable="1" showselectionhandles="1" allownudging="1" isannotation="0" dontautolayout="0" groupcollapsed="0" tabstop="1" visible="1" snaptogrid="0"> + <control> + <ddsxmlobjectstreaminitwrapper binary="000800000e0e00008c040000" /> + </control> + <layoutobject> + <ddsxmlobj> + <property name="LogicalObject" value="{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}" vartype="8" /> + <property name="ShowConnectorSource" value="0" vartype="2" /> + </ddsxmlobj> + </layoutobject> + <shape groupshapeid="0" groupnode="0" /> + </ddscontrol> +</dds></dwd:Layout></dwd:DtsControlFlowDiagram></Package>dts-designer-1.0{E246A403-57B7-4CF1-9B0F-7C48C7619AEA}{1194FB41-A8F6-41D0-9C07-EF8554C76078}00-100011048576103310 +01 +000-100011048576-110 +01Data Flow Task{0EA3D114-04AE-4EE0-BEDD-9A357D942CB0}Data Flow Task{C3BF9DC1-4715-4694-936F-D3CFDA9E42C5}0 + + + +EXEC GetProducts +Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter, Microsoft.SqlServer.ADONETSrc, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +30000 + +false +Microsoft.SqlServer.Dts.Pipeline.DataReaderDestinationAdapter, Microsoft.SqlServer.DataReaderDest, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 + + + + + + + + + + + + + + + + + + + + +Package{E246A403-57B7-4CF1-9B0F-7C48C7619AEA}MSDTS.Package.10 \ No newline at end of file diff --git a/1590594770-1/Chapter09/Integration Services Project1/getproducts.sql b/1590594770-1/Chapter09/Integration Services Project1/getproducts.sql new file mode 100644 index 0000000..a274e1c --- /dev/null +++ b/1590594770-1/Chapter09/Integration Services Project1/getproducts.sql @@ -0,0 +1,31 @@ +use adventureworks +go + +set ANSI_NULLS ON +set QUOTED_IDENTIFIER ON +go + + +-- ============================================= +-- Author: +-- Create date: +-- Description: +-- ============================================= +CREATE PROCEDURE [dbo].[GetProducts] + -- Add the parameters for the function here +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + -- Insert statements for procedure here + SELECT Production.Product.Name, Production.ProductCategory.Name AS CategoryName, Production.ProductSubcategory.Name AS SubCategoryName, + Production.Product.ProductNumber, Production.Product.Color, Production.Product.StandardCost, Production.Product.ListPrice, Production.Product.Size, + Production.Product.Weight, Production.Product.Class, Production.Product.Style, Production.Product.ProductID +FROM Production.Product INNER JOIN + Production.ProductSubcategory ON Production.Product.ProductSubcategoryID = Production.ProductSubcategory.ProductSubcategoryID INNER JOIN + Production.ProductCategory ON Production.ProductSubcategory.ProductCategoryID = Production.ProductCategory.ProductCategoryID ORDER BY CategoryName, SubCategoryName, Production.Product.ListPrice +END + + diff --git a/1590594770-1/Chapter09/Integration Services Project1/readme.txt b/1590594770-1/Chapter09/Integration Services Project1/readme.txt new file mode 100644 index 0000000..a8a6858 --- /dev/null +++ b/1590594770-1/Chapter09/Integration Services Project1/readme.txt @@ -0,0 +1,48 @@ +This sample application shows you how to use Reporting Services and Integration Services together. + +Please note that you must have the AdventureWorks sample installed to use this application. + +To use the applications, please follow these steps: + +1) Double-click the getproducts.sql file to launch Management Studio which will load the file. + +2) Once loaded, press F5 to run the code. The code should create a stored procedure called getproducts in the adventureworks database. + +3) Doublic-click the Integration Services 1.sln file to launch Integration Services. Click F5 to run the package to test it. Click the data flow tab and you should see 295 rows moved between the source and destination. + +4) You must enable the SSIS data processing extension. To do this, open the file rsreportserver.config. You can normally find this file at C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\ + +5) Find the line + + +and remove the comments so that the line reads + + + +6) Save the rsreportserver.config file. + +7) To get the SSIS extension to work in Report Designer, open the file RSReportDesigner.config. You can normally find this file at C:\program files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies + +8) Find the line + + + +and remove the comments so it reads + + + +9) Find the line + +and remove the comments so the line reads + + + +10) Save the file. + +11) Go into the SSIS Project folder. Double-click the SSIS Project.sln to load it into BIDS or Visual Studio depending on what you have installed on your machine. + +12) Double-click the DataSource1.rds and change the path in the connection string to the path where the package.dtsx file is and click ok. + +13) Open Report1.rdl by clicking on it. Make sure that the table is on the report. + +14) Click the Preview tab at the top. The report should load and you should see information from SSIS. diff --git a/1590594770-1/Chapter09/Report Builder Sample/Northwind Report Builder Report.rdl b/1590594770-1/Chapter09/Report Builder Sample/Northwind Report Builder Report.rdl new file mode 100644 index 0000000..61c5552 --- /dev/null +++ b/1590594770-1/Chapter09/Report Builder Sample/Northwind Report Builder Report.rdl @@ -0,0 +1,914 @@ + + + 11in + false + false + 0.25in + + + Order Information + + + 0in + + + 1.0625in + + + 1in + + + 1in + + + 1in + + + 1in + + + 1in + + +
+ + + 0.25in + + + + + true + + + + + Geb928a56-9997-4925-af1b-4b177cdd3170 + + + Detail + + + Drillthrough + + + =Code.DrillthroughContextBuilder.CreateAsString(DataSets!dataSet.RewrittenCommandText, new String() { "CompanyName" }, "<SelectedPath xmlns=""http" & Chr(58) & "//schemas.microsoft.com/sqlserver/2004/10/semanticmodeling"" />", new String() { "Customer", "Order" }, new Object() { Fields!Customer.Value, Fields!Order.Value }, new Boolean() { InScope("table_Customer"), InScope("table_Order") }) + + + /Models/Northwind + + + + table_Customer + =Fields!CompanyName.Value + + + + + + + true + + table_Customer + =Fields!ContactName.Value + + + + + + + true + + table_Customer + =Fields!City.Value + + + + + + + true + + + + + Ga240dd4b-a0b3-4e8a-8b42-eb4ab8d7a328 + + + Detail + + + Drillthrough + + + =Code.DrillthroughContextBuilder.CreateAsString(DataSets!dataSet.RewrittenCommandText, new String() { "OrderDate" }, "<SelectedPath xmlns=""http" & Chr(58) & "//schemas.microsoft.com/sqlserver/2004/10/semanticmodeling"" />", new String() { "Customer", "Order" }, new Object() { Fields!Customer.Value, Fields!Order.Value }, new Boolean() { InScope("table_Customer"), InScope("table_Order") }) + + + /Models/Northwind + + + + =Fields!OrderDate.Value + + + + + + + true + + + + + Ga240dd4b-a0b3-4e8a-8b42-eb4ab8d7a328 + + + Detail + + + Drillthrough + + + =Code.DrillthroughContextBuilder.CreateAsString(DataSets!dataSet.RewrittenCommandText, new String() { "ShippedDate" }, "<SelectedPath xmlns=""http" & Chr(58) & "//schemas.microsoft.com/sqlserver/2004/10/semanticmodeling"" />", new String() { "Customer", "Order" }, new Object() { Fields!Customer.Value, Fields!Order.Value }, new Boolean() { InScope("table_Customer"), InScope("table_Order") }) + + + /Models/Northwind + + + + =Fields!ShippedDate.Value + + + + + + + true + + + + + G4c235f0e-15f0-4ef6-a8c4-71536ba2204a + + + List + + + Drillthrough + + + =Code.DrillthroughContextBuilder.CreateAsString(DataSets!dataSet.RewrittenCommandText, new String() { "AvgUnitPrice_Sum", "AvgUnitPrice_Count" }, "<SelectedPath xmlns=""http" & Chr(58) & "//schemas.microsoft.com/sqlserver/2004/10/semanticmodeling""><RolePathItem><RoleID>G530fd4df-6fda-461a-b4fa-c8b842421e06</RoleID></RolePathItem></SelectedPath>", new String() { "Customer", "Order" }, new Object() { Fields!Customer.Value, Fields!Order.Value }, new Boolean() { InScope("table_Customer"), InScope("table_Order") }) + + + /Models/Northwind + + + + =IIF(Fields!AvgUnitPrice_Count.Value=0,Nothing,Fields!AvgUnitPrice_Sum.Value/Fields!AvgUnitPrice_Count.Value) + + + + + + + + + =Fields!Order.Value + + + + + =IIf(True, Fields!OrderDate.Value, Nothing) + Descending + + + =IIf(True, Fields!expr1.Value, Nothing) + Descending + + + =IIf(True, Fields!ShippedDate.Value, Nothing) + Descending + + + =IIf(True, Fields!expr2.Value, Nothing) + + + =IIf(True, Fields!expr3.Value, Nothing) + Descending + + +
+
+ + + 0.25in + + + 5 + + + true + + Total + + + + + + + true + + + + + G4c235f0e-15f0-4ef6-a8c4-71536ba2204a + + + List + + + Drillthrough + + + =Code.DrillthroughContextBuilder.CreateAsString(DataSets!dataSet.RewrittenCommandText, new String() { "AvgUnitPrice_Sum", "AvgUnitPrice_Count" }, "<SelectedPath xmlns=""http" & Chr(58) & "//schemas.microsoft.com/sqlserver/2004/10/semanticmodeling""><RolePathItem><RoleID>G530fd4df-6fda-461a-b4fa-c8b842421e06</RoleID></RolePathItem></SelectedPath>", new String() { "Customer", "Order" }, new Object() { Fields!Customer.Value, Fields!Order.Value }, new Boolean() { InScope("table_Customer"), InScope("table_Order") }) + + + /Models/Northwind + + + + =IIF(SUM(Fields!AvgUnitPrice_Count.Value)=0,Nothing,SUM(Fields!AvgUnitPrice_Sum.Value)/SUM(Fields!AvgUnitPrice_Count.Value)) + + + + + + +
+ + Company Name + + + + + + + true + + table_Customer + =Fields!ContactName.Value + + + Contact Name + + + + + + + true + + table_Customer + =Fields!City.Value + + + City + + + + + + + true + + table_Order + =Fields!OrderDate.Value + + + Order Date + + + + + + + true + + table_Order + =Fields!ShippedDate.Value + + + Shipped Date + + + + + + + true + + table_Order + =IIF(Fields!AvgUnitPrice_Count.Value=0,Nothing,Fields!AvgUnitPrice_Sum.Value/Fields!AvgUnitPrice_Count.Value) + + + Avg Unit Price + + + + + + + true + true + + + + + + =Fields!Customer.Value + + +
+ + + 0.25in + + + + + true + + + + + + + + + true + + + + + + + + + true + + + + + + + 2 + + + true + + Total + + + + + + + true + + + + + G4c235f0e-15f0-4ef6-a8c4-71536ba2204a + + + List + + + Drillthrough + + + =Code.DrillthroughContextBuilder.CreateAsString(DataSets!dataSet.RewrittenCommandText, new String() { "AvgUnitPrice_Sum", "AvgUnitPrice_Count" }, "<SelectedPath xmlns=""http" & Chr(58) & "//schemas.microsoft.com/sqlserver/2004/10/semanticmodeling""><RolePathItem><RoleID>G530fd4df-6fda-461a-b4fa-c8b842421e06</RoleID></RolePathItem></SelectedPath>", new String() { "Customer", "Order" }, new Object() { Fields!Customer.Value, Fields!Order.Value }, new Boolean() { InScope("table_Customer"), InScope("table_Order") }) + + + /Models/Northwind + + + + =IIF(SUM(Fields!AvgUnitPrice_Count.Value)=0,Nothing,SUM(Fields!AvgUnitPrice_Sum.Value)/SUM(Fields!AvgUnitPrice_Count.Value)) + + + + + + +
+ + + =IIf(True, Fields!CompanyName.Value, Nothing) + + +
+
+ 0in + 0.5in + 1.25in +
+ + 0.5in + 5.25in + true + 7.5in + 0.25in + + + + rb:SpecialContent + TotalRows + + + =String.Format("Total Orders" & Chr(58) & " {0}", COUNTROWS("dataSet")) + + + 0.5in + 5.75in + true + 7.5in + 0.25in + + + + rb:SpecialContent + FilterDescription + + + All Orders + + + + + + Microsoft.ReportingServices.SemanticQueryReportLibrary.DrillthroughContextBuilder + DrillthroughContextBuilder + + + 8.5in + + + 232cbc60-ed7b-4d00-9a25-72aabaf97512 + /Models/Northwind + + + + + + dataSource + <SemanticQuery xmlns="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rb="http://schemas.microsoft.com/sqlserver/2004/11/reportbuilder" xmlns:qd="http://schemas.microsoft.com/sqlserver/2004/11/semanticquerydesign"> + <Hierarchies> + <Hierarchy> + <BaseEntity> + <!--Order--> + <EntityID>Ga240dd4b-a0b3-4e8a-8b42-eb4ab8d7a328</EntityID> + </BaseEntity> + <Groupings> + <Grouping Name="Customer"> + <Expression Name="Customer"> + <Path> + <RolePathItem> + <!--Customer--> + <RoleID>Gf661a2b1-0aeb-4c78-9d51-5c2ad7ce4f44</RoleID> + </RolePathItem> + </Path> + <EntityRef> + <!--Customer--> + <EntityID>Geb928a56-9997-4925-af1b-4b177cdd3170</EntityID> + </EntityRef> + </Expression> + <Details> + <Expression Name="CompanyName"> + <AttributeRef> + <!--Company Name--> + <AttributeID>Gad047f3d-2f5a-49f5-9e6a-ac135307f5f3</AttributeID> + </AttributeRef> + </Expression> + <Expression Name="ContactName"> + <AttributeRef> + <!--Contact Name--> + <AttributeID>G5a940077-dd6b-4c8f-8a63-245283800c39</AttributeID> + </AttributeRef> + </Expression> + <Expression Name="City"> + <AttributeRef> + <!--City--> + <AttributeID>G515e4a41-3290-4a11-8cb0-0ab218f671bd</AttributeID> + </AttributeRef> + </Expression> + </Details> + </Grouping> + <Grouping Name="Order"> + <Expression Name="Order"> + <EntityRef> + <!--Order--> + <EntityID>Ga240dd4b-a0b3-4e8a-8b42-eb4ab8d7a328</EntityID> + </EntityRef> + </Expression> + <Details> + <Expression Name="OrderDate"> + <AttributeRef> + <!--Order Date--> + <AttributeID>G2cf20212-6e20-4819-9643-f4592b136f87</AttributeID> + </AttributeRef> + </Expression> + <Expression Name="ShippedDate"> + <AttributeRef> + <!--Shipped Date--> + <AttributeID>G6ac74e13-07bf-4555-ac91-86f985289d91</AttributeID> + </AttributeRef> + </Expression> + <Expression Name="expr1"> + <AttributeRef> + <!--Required Date--> + <AttributeID>Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a</AttributeID> + </AttributeRef> + </Expression> + <Expression Name="expr2"> + <AttributeRef> + <!--Ship Name--> + <AttributeID>Gc7a83797-6be0-4cff-96b4-ba2faae7afb9</AttributeID> + </AttributeRef> + </Expression> + <Expression Name="expr3"> + <AttributeRef> + <!--Freight--> + <AttributeID>G90c903e1-d921-4039-9deb-809278b1ef46</AttributeID> + </AttributeRef> + </Expression> + </Details> + </Grouping> + </Groupings> + </Hierarchy> + </Hierarchies> + <MeasureGroups> + <MeasureGroup> + <BaseEntity> + <!--Order--> + <EntityID>Ga240dd4b-a0b3-4e8a-8b42-eb4ab8d7a328</EntityID> + </BaseEntity> + <Measures> + <Expression Name="AvgUnitPrice_Sum"> + <Function> + <FunctionName>Sum</FunctionName> + <Arguments> + <Expression> + <Path> + <RolePathItem> + <!--Order Details--> + <RoleID>G530fd4df-6fda-461a-b4fa-c8b842421e06</RoleID> + </RolePathItem> + </Path> + <AttributeRef> + <!--Unit Price--> + <AttributeID>G4254a5f1-c2d3-4092-8fb6-fe9562822080</AttributeID> + </AttributeRef> + </Expression> + </Arguments> + </Function> + <CustomProperties> + <CustomProperty Name="qd:Design"> + <Value xsi:type="xsd:string">AvgUnitPrice</Value> + </CustomProperty> + </CustomProperties> + </Expression> + <Expression Name="AvgUnitPrice_Count"> + <Function> + <FunctionName>Count</FunctionName> + <Arguments> + <Expression> + <Path> + <RolePathItem> + <!--Order Details--> + <RoleID>G530fd4df-6fda-461a-b4fa-c8b842421e06</RoleID> + </RolePathItem> + </Path> + <AttributeRef> + <!--Unit Price--> + <AttributeID>G4254a5f1-c2d3-4092-8fb6-fe9562822080</AttributeID> + </AttributeRef> + </Expression> + </Arguments> + </Function> + <CustomProperties> + <CustomProperty Name="qd:Design"> + <Value xsi:type="xsd:string">AvgUnitPrice</Value> + </CustomProperty> + </CustomProperties> + </Expression> + </Measures> + </MeasureGroup> + </MeasureGroups> + <CalculatedAttributes> + <Expression Name="AvgUnitPrice"> + <Function> + <FunctionName>Aggregate</FunctionName> + <Arguments> + <Expression> + <Path> + <RolePathItem> + <!--Order Details--> + <RoleID>G530fd4df-6fda-461a-b4fa-c8b842421e06</RoleID> + </RolePathItem> + </Path> + <AttributeRef> + <!--Avg Unit Price--> + <AttributeID>Gd12c438c-71a8-4283-b554-b3e283e2a970</AttributeID> + </AttributeRef> + </Expression> + </Arguments> + </Function> + <CustomProperties> + <CustomProperty Name="qd:Design"> + <Value xsi:type="xsd:string"></Value> + </CustomProperty> + </CustomProperties> + </Expression> + </CalculatedAttributes> +</SemanticQuery> + + + + Customer + + + CompanyName + + + ContactName + + + City + + + Order + + + OrderDate + + + ShippedDate + + + expr1 + + + expr2 + + + expr3 + + + AvgUnitPrice_Sum + + + AvgUnitPrice_Count + + + + + 8.5in +
\ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind Report Model Project.smdlproj b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind Report Model Project.smdlproj new file mode 100644 index 0000000..ba0432a --- /dev/null +++ b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind Report Model Project.smdlproj @@ -0,0 +1,61 @@ + + + + Report Model Project1.database + Report Model Project1.database + + $base64$PFNvdXJjZUNvbnRyb2xJbmZvIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOmR3ZD0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9EYXRhV2FyZWhvdXNlL0Rlc2lnbmVyLzEuMCI+DQogIDxFbmFibGVkPmZhbHNlPC9FbmFibGVkPg0KICA8UHJvamVjdE5hbWU+PC9Qcm9qZWN0TmFtZT4NCiAgPEF1eFBhdGg+PC9BdXhQYXRoPg0KICA8TG9jYWxQYXRoPjwvTG9jYWxQYXRoPg0KICA8UHJvdmlkZXI+PC9Qcm92aWRlcj4NCjwvU291cmNlQ29udHJvbEluZm8+ + + + Northwind.ds + Northwind.ds + + + + + Northwind.dsv + Northwind.dsv + + + + + Northwind.smdl + Northwind.smdl + Northwind + + + + + Production + Win32 + + bin + true + + + Northwind + Northwind + Data Source=.;Initial Catalog=Northwind;Integrated Security=True + + + + + Northwind + Northwind + System.Data.SqlClient + + + + + Northwind + Northwind + 0 + + + http://localhost/ReportServer + Models + Data Sources + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind Report Model Project.smdlproj.user b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind Report Model Project.smdlproj.user new file mode 100644 index 0000000..8a67a03 --- /dev/null +++ b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind Report Model Project.smdlproj.user @@ -0,0 +1,13 @@ + + + + + Production + Win32 + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind.ds b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind.ds new file mode 100644 index 0000000..ff91d7b --- /dev/null +++ b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind.ds @@ -0,0 +1,10 @@ + + Northwind + Northwind + 0001-01-01T00:00:00Z + 0001-01-01T00:00:00Z + Data Source=.;Initial Catalog=Northwind;Integrated Security=True + Unchanged + System.Data.SqlClient + PT0S + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind.dsv b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind.dsv new file mode 100644 index 0000000..dcfa795 --- /dev/null +++ b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind.dsv @@ -0,0 +1,1173 @@ + + Northwind + Northwind + 0001-01-01T00:00:00Z + 0001-01-01T00:00:00Z + + + http://schemas.microsoft.com/DataWarehouse/Designer/1.0:ShowFriendlyNames + true + + + http://schemas.microsoft.com/DataWarehouse/Designer/1.0:CurrentLayout + _ALL_TABLES_ + + + http://schemas.microsoft.com/DataWarehouse/Designer/1.0:NameMatchingCriteria + 1 + + + http://schemas.microsoft.com/DataWarehouse/Designer/1.0:Layouts + + + + _ALL_TABLES_ + + False + True + 0 + 0 + 0 + 0 + 100 + + + + + + Northwind + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind.smdl b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind.smdl new file mode 100644 index 0000000..088246e --- /dev/null +++ b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Northwind.smdl @@ -0,0 +1,6293 @@ + + + en-US + + + Alphabetical List Of Product + Alphabetical List Of Products + + + + Gee3b00d8-a71f-41e0-9c03-40c30aef7bfc + + + + + + Gee3b00d8-a71f-41e0-9c03-40c30aef7bfc + + + + Ge5aa4f11-e5ed-4498-ab44-30e33b4582d1 + + + + Gb7fa1941-2912-44b4-b7b7-1fc3f5eb83bd + + + + G017997bd-7247-480d-a9bf-92ab61c5442e + + + + Gb087519d-ee33-49e8-acc6-ec77af482836 + + + + G70fedbb9-c358-403a-8751-09f20ff1d1b5 + + + + G86d12c22-f6df-428e-afb6-037df722b785 + + + + G7400d7f4-67d3-43de-8d9e-2e1292be37da + + + + + + G62ebc456-7b42-4961-ab42-010441e9aa90 + + + Dropdown + + + #Alphabetical List Of Products + Integer + + + Count + + + + + Gb7e7993a-62a5-48c4-b940-e91163ababa7 + + + + + + true + Descending + n0 + true + + + Product ID + Integer + Descending + 2 + g + true + Dropdown + + + + Product Name + String + 30 + true + true + Dropdown + + + + Supplier ID + Integer + true + Descending + 2 + g + Dropdown + + + + Category ID + Integer + true + Descending + 1 + g + Dropdown + + + + Quantity Per Unit + String + true + 20 + true + Dropdown + + + + Unit Price + Decimal + true + Descending + 7 + g + + Gb4d19c98-147c-4922-950b-22d728465359 + Dropdown + + + Sum Unit Price + Decimal + true + + + Sum + + + + + G017997bd-7247-480d-a9bf-92ab61c5442e + + + + + + true + Descending + true + + + Avg Unit Price + Decimal + true + + + Avg + + + + + G017997bd-7247-480d-a9bf-92ab61c5442e + + + + + + true + Descending + true + + + Min Unit Price + Decimal + true + + + Min + + + + + G017997bd-7247-480d-a9bf-92ab61c5442e + + + + + + true + Descending + true + + + Max Unit Price + Decimal + true + + + Max + + + + + G017997bd-7247-480d-a9bf-92ab61c5442e + + + + + + true + Descending + true + + + + + + Units In Stock + Integer + true + Descending + 3 + g + + Gc5d3ce3f-a4ec-400a-9336-bb7106fb1f24 + Dropdown + + + Sum Units In Stock + Integer + true + + + Sum + + + + + Gb087519d-ee33-49e8-acc6-ec77af482836 + + + + + + true + Descending + true + + + Avg Units In Stock + Decimal + true + + + Avg + + + + + Gb087519d-ee33-49e8-acc6-ec77af482836 + + + + + + true + Descending + true + + + Min Units In Stock + Integer + true + + + Min + + + + + Gb087519d-ee33-49e8-acc6-ec77af482836 + + + + + + true + Descending + true + + + Max Units In Stock + Integer + true + + + Max + + + + + Gb087519d-ee33-49e8-acc6-ec77af482836 + + + + + + true + Descending + true + + + + + + Units On Order + Integer + true + Descending + 2 + g + + G755e775d-0e9b-4500-a518-00a5697974dd + Dropdown + + + Sum Units On Order + Integer + true + + + Sum + + + + + G3885dc8c-1d2f-40df-a4a7-7bec73879797 + + + + + + true + Descending + true + + + Avg Units On Order + Decimal + true + + + Avg + + + + + G3885dc8c-1d2f-40df-a4a7-7bec73879797 + + + + + + true + Descending + true + + + Min Units On Order + Integer + true + + + Min + + + + + G3885dc8c-1d2f-40df-a4a7-7bec73879797 + + + + + + true + Descending + true + + + Max Units On Order + Integer + true + + + Max + + + + + G3885dc8c-1d2f-40df-a4a7-7bec73879797 + + + + + + true + Descending + true + + + + + + Reorder Level + Integer + true + Descending + 2 + g + + G32ea0097-b252-448e-ad89-d96d77e3589b + Dropdown + + + Sum Reorder Level + Integer + true + + + Sum + + + + + G43b41e20-0b69-4114-a178-8bf43a7f3c63 + + + + + + true + Descending + true + + + Avg Reorder Level + Decimal + true + + + Avg + + + + + G43b41e20-0b69-4114-a178-8bf43a7f3c63 + + + + + + true + Descending + true + + + Min Reorder Level + Integer + true + + + Min + + + + + G43b41e20-0b69-4114-a178-8bf43a7f3c63 + + + + + + true + Descending + true + + + Max Reorder Level + Integer + true + + + Max + + + + + G43b41e20-0b69-4114-a178-8bf43a7f3c63 + + + + + + true + Descending + true + + + + + + Discontinued + Boolean + Dropdown + + + + Category Name + String + 14 + Dropdown + + + + + + + Customer + Customers + + + + Gad047f3d-2f5a-49f5-9e6a-ac135307f5f3 + + + + + + Gad047f3d-2f5a-49f5-9e6a-ac135307f5f3 + + + + G5a940077-dd6b-4c8f-8a63-245283800c39 + + + + G0beb0500-96f7-4c93-b1bd-9dfcfc89a9d0 + + + + + + Gd3ff1554-3ac2-44b5-83db-5c3168529af0 + + + Dropdown + + + #Customers + Integer + + + Count + + + + + Geb928a56-9997-4925-af1b-4b177cdd3170 + + + + + + true + Descending + n0 + true + + + Customer ID + String + 5 + true + Dropdown + + + + Company Name + String + 29 + true + true + Dropdown + + + + Contact Name + String + true + 19 + true + Dropdown + + + + Contact Title + String + true + 26 + Dropdown + + + + Address + String + true + 31 + true + Dropdown + + + + City + String + true + 13 + Dropdown + + + + Region + String + true + 9 + Dropdown + + + + Postal Code + String + true + 8 + true + Dropdown + + + + Country + String + true + 9 + Dropdown + + + + Phone + String + true + 15 + true + Dropdown + + + + Fax + String + true + 15 + true + Dropdown + + + + + Gf661a2b1-0aeb-4c78-9d51-5c2ad7ce4f44 + OptionalMany + + + + + G4744808e-6a9f-4572-a8e2-ac1d7e927029 + OptionalMany + + + +
+ + + Customer Customer Demo + Customer Customer Demoes + + + + + + G4744808e-6a9f-4572-a8e2-ac1d7e927029 + + + + Gad047f3d-2f5a-49f5-9e6a-ac135307f5f3 + + + + + + G65bda9e0-dbb0-401b-881c-e2d9aced104e + + + + G1f7e69aa-4d3b-4f56-98d0-2323b34749a8 + + + + + + + + G4744808e-6a9f-4572-a8e2-ac1d7e927029 + + + + Gad047f3d-2f5a-49f5-9e6a-ac135307f5f3 + + + + + + G65bda9e0-dbb0-401b-881c-e2d9aced104e + + + + G1f7e69aa-4d3b-4f56-98d0-2323b34749a8 + + + + + + G6c658911-a36c-4ec3-87e6-e2b8178b4145 + + + Dropdown + + + #Customer Customer Demoes + Integer + + + Count + + + + + Gfb29f698-ebab-44f1-aab0-aabb64d1fbc8 + + + + + + true + Descending + n0 + true + + + + G52de0f17-b24f-4b56-b148-025ab3dadb70 + OptionalOne + + + + Customer Type + + G26c2e13f-8616-453f-9bdc-9a5db8b81fac + OptionalOne + + + +
+ + + Employee + Employees + + + + G10ddec60-33b5-47b7-b076-771a24e514f8 + + + + + + G10ddec60-33b5-47b7-b076-771a24e514f8 + + + + Gd9a10a0c-c483-4e07-8600-caa211b6b448 + + + + G027eea82-5fe2-4ae6-9af4-032f0d3169bf + + + + + + Gf769a1c7-7d5f-42ff-8aac-c6a8926942dd + + + Dropdown + + + #Employees + Integer + + + Count + + + + + Gf9162f5e-f8be-47c4-9d52-a893be8671cd + + + + + + true + Descending + n0 + true + + + Employee ID + true + Integer + Descending + 1 + g + true + Dropdown + + + + Last Name + String + 9 + true + true + Dropdown + + + + First Name + String + 8 + true + Dropdown + + + + Title + String + true + 24 + Dropdown + + + + Title Of Courtesy + String + true + 3 + Dropdown + + + + Birth Date + DateTime + true + Descending + d + true + Dropdown + + + Birth Day + Integer + true + + + Day + + + + + Ge54fd705-997e-4dae-bdd2-7fb09942a720 + + + + + + + + Birth Month + Integer + true + + + Month + + + + + Ge54fd705-997e-4dae-bdd2-7fb09942a720 + + + + + + + + Birth Year + Integer + true + + + Year + + + + + Ge54fd705-997e-4dae-bdd2-7fb09942a720 + + + + + + + + Birth Quarter + Integer + true + + + Quarter + + + + + Ge54fd705-997e-4dae-bdd2-7fb09942a720 + + + + + + + + First Birth Date + DateTime + true + + + Min + + + + + Ge54fd705-997e-4dae-bdd2-7fb09942a720 + + + + + + true + Descending + d + true + + + Last Birth Date + DateTime + true + + + Max + + + + + Ge54fd705-997e-4dae-bdd2-7fb09942a720 + + + + + + true + Descending + d + true + + + + + + Hire Date + DateTime + true + Descending + d + true + Dropdown + + + Hire Day + Integer + true + + + Day + + + + + G5cb3f254-c3bf-4327-aa50-9a584ce4bda0 + + + + + + + + Hire Month + Integer + true + + + Month + + + + + G5cb3f254-c3bf-4327-aa50-9a584ce4bda0 + + + + + + + + Hire Year + Integer + true + + + Year + + + + + G5cb3f254-c3bf-4327-aa50-9a584ce4bda0 + + + + + + + + Hire Quarter + Integer + true + + + Quarter + + + + + G5cb3f254-c3bf-4327-aa50-9a584ce4bda0 + + + + + + + + First Hire Date + DateTime + true + + + Min + + + + + G5cb3f254-c3bf-4327-aa50-9a584ce4bda0 + + + + + + true + Descending + d + true + + + Last Hire Date + DateTime + true + + + Max + + + + + G5cb3f254-c3bf-4327-aa50-9a584ce4bda0 + + + + + + true + Descending + d + true + + + + + + Address + String + true + 30 + true + Dropdown + + + + City + String + true + 8 + Dropdown + + + + Region + String + true + 2 + Dropdown + + + + Postal Code + String + true + 7 + true + Dropdown + + + + Country + String + true + 3 + Dropdown + + + + Home Phone + String + true + 14 + true + Dropdown + + + + Extension + String + true + 4 + true + Dropdown + + + + Reports To + Integer + true + Descending + 1 + g + + G0f2fcd63-46ac-46d6-97f2-2a637d412a9e + Dropdown + + + Sum Reports To + Integer + true + + + Sum + + + + + G4a341278-d3cb-4b94-8fa5-d3d3f5001c53 + + + + + + true + Descending + true + + + Avg Reports To + Decimal + true + + + Avg + + + + + G4a341278-d3cb-4b94-8fa5-d3d3f5001c53 + + + + + + true + Descending + true + + + Min Reports To + Integer + true + + + Min + + + + + G4a341278-d3cb-4b94-8fa5-d3d3f5001c53 + + + + + + true + Descending + true + + + Max Reports To + Integer + true + + + Max + + + + + G4a341278-d3cb-4b94-8fa5-d3d3f5001c53 + + + + + + true + Descending + true + + + + + + Photo Path + String + true + 37 + Dropdown + + + + + G515e3ed1-779a-4ba7-bb30-0f14d1e937a4 + OptionalMany + + + + + G3283a345-3148-41ae-9c6f-428c202ed025 + OptionalMany + + + +
+ + + Employee Territory + Employee Territories + + + + + + G6cfdac3f-7184-45aa-bb35-af61ee5dcef3 + + + + Gbc4e69d5-199a-4c87-85d3-1ab8c0efd146 + + + + + + G3283a345-3148-41ae-9c6f-428c202ed025 + + + + G10ddec60-33b5-47b7-b076-771a24e514f8 + + + + + + + + G6cfdac3f-7184-45aa-bb35-af61ee5dcef3 + + + + Gbc4e69d5-199a-4c87-85d3-1ab8c0efd146 + + + + + + G3283a345-3148-41ae-9c6f-428c202ed025 + + + + G10ddec60-33b5-47b7-b076-771a24e514f8 + + + + + + G05403d08-705f-4979-aa04-4c8290e0d45e + + + Dropdown + + + #Employee Territories + Integer + + + Count + + + + + G957da02c-180f-4eb2-8c3d-e29baa6ec139 + + + + + + true + Descending + n0 + true + + + + Gfd139208-735b-4fb3-bd0b-997d1e15b273 + OptionalOne + + + + + Gdbecfc53-ac87-424c-92fe-338265e0c081 + OptionalOne + + + +
+ + + Lookup + + + Customer Demographic + Customer Demographics + + + + G1f7e69aa-4d3b-4f56-98d0-2323b34749a8 + + + + + + G1f7e69aa-4d3b-4f56-98d0-2323b34749a8 + + + + + + Geeee6ea7-7ea4-4ad2-a449-be821ea04d0e + + + Dropdown + true + + + #Customer Demographics + Integer + + + Count + + + + + Gdf523782-53d5-4e61-b7d8-1c693b562093 + + + + + + true + Descending + n0 + true + + + Customer Type ID + String + true + true + + + + Customer Customer Demoes as Customer Type + + Customer Customer Demo as Customer Type + Customer Customer Demoes as Customer Type + + + G65bda9e0-dbb0-401b-881c-e2d9aced104e + OptionalMany + + + +
+ + + Category + Categories + + + + G0043f9f6-1b1a-4f30-80aa-dbe9b8b8d82c + + + + + + G0043f9f6-1b1a-4f30-80aa-dbe9b8b8d82c + + + + + + G097fc1e3-434a-4e97-afba-3ce0f7b11ea0 + + + Dropdown + true + + + #Categories + Integer + + + Count + + + + + G9f52edc8-5934-4a83-a7ac-dbbf2618caf0 + + + + + + true + Descending + n0 + true + + + Category ID + true + Integer + Descending + 1 + g + true + Dropdown + + + + Category Name + String + 14 + true + true + Dropdown + + + + + G0c527fbc-cd91-4a2c-b05c-b445aa40c439 + OptionalMany + + + +
+ + + Current Product List + Current Product Lists + + + + G27a135e2-e985-4589-a8b6-0cb68aa8f136 + + + + + + G27a135e2-e985-4589-a8b6-0cb68aa8f136 + + + + + + G05d5bd47-1c71-4a98-8633-a587591e70a4 + + + Dropdown + true + + + #Current Product Lists + Integer + + + Count + + + + + G12e0069a-f4e9-4b69-8170-28c33a30ec91 + + + + + + true + Descending + n0 + true + + + Product ID + true + Integer + Descending + 2 + g + true + Dropdown + + + + Product Name + String + 30 + true + true + Dropdown + + + +
+ + + + + Order + Orders + + + + G2cf20212-6e20-4819-9643-f4592b136f87 + + + + Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a + + + + G6ac74e13-07bf-4555-ac91-86f985289d91 + + + + Gc7a83797-6be0-4cff-96b4-ba2faae7afb9 + + + + G90c903e1-d921-4039-9deb-809278b1ef46 + + + + + + G90c903e1-d921-4039-9deb-809278b1ef46 + + + + G2cf20212-6e20-4819-9643-f4592b136f87 + + + + Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a + + + + G6ac74e13-07bf-4555-ac91-86f985289d91 + + + + Gc7a83797-6be0-4cff-96b4-ba2faae7afb9 + + + + G5bd87278-a97c-4e37-8aa6-69327665df2c + + + + + + G7eda4165-27c4-42ad-b0fd-3e17e07acf31 + + + FilteredList + + + #Orders + Integer + + + Count + + + + + Ga240dd4b-a0b3-4e8a-8b42-eb4ab8d7a328 + + + + + + true + Descending + n0 + true + + + Order ID + true + Integer + Descending + 5 + g + true + + + + + Gba5aae21-a232-4610-8c21-e10796997944 + OptionalOne + + + + + G20f713ab-074e-42fd-b592-7ced39948f5b + OptionalOne + + + + Order Date + DateTime + true + Descending + d + true + + + Order Day + Integer + true + + + Day + + + + + G2cf20212-6e20-4819-9643-f4592b136f87 + + + + + + + + Order Month + Integer + true + + + Month + + + + + G2cf20212-6e20-4819-9643-f4592b136f87 + + + + + + + + Order Year + Integer + true + + + Year + + + + + G2cf20212-6e20-4819-9643-f4592b136f87 + + + + + + + + Order Quarter + Integer + true + + + Quarter + + + + + G2cf20212-6e20-4819-9643-f4592b136f87 + + + + + + + + First Order Date + DateTime + true + + + Min + + + + + G2cf20212-6e20-4819-9643-f4592b136f87 + + + + + + true + Descending + d + true + + + Last Order Date + DateTime + true + + + Max + + + + + G2cf20212-6e20-4819-9643-f4592b136f87 + + + + + + true + Descending + d + true + + + + + + Required Date + DateTime + true + Descending + d + true + + + Required Day + Integer + true + + + Day + + + + + Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a + + + + + + + + Required Month + Integer + true + + + Month + + + + + Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a + + + + + + + + Required Year + Integer + true + + + Year + + + + + Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a + + + + + + + + Required Quarter + Integer + true + + + Quarter + + + + + Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a + + + + + + + + First Required Date + DateTime + true + + + Min + + + + + Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a + + + + + + true + Descending + d + true + + + Last Required Date + DateTime + true + + + Max + + + + + Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a + + + + + + true + Descending + d + true + + + + + + Shipped Date + DateTime + true + Descending + d + true + + + Shipped Day + Integer + true + + + Day + + + + + G6ac74e13-07bf-4555-ac91-86f985289d91 + + + + + + + + Shipped Month + Integer + true + + + Month + + + + + G6ac74e13-07bf-4555-ac91-86f985289d91 + + + + + + + + Shipped Year + Integer + true + + + Year + + + + + G6ac74e13-07bf-4555-ac91-86f985289d91 + + + + + + + + Shipped Quarter + Integer + true + + + Quarter + + + + + G6ac74e13-07bf-4555-ac91-86f985289d91 + + + + + + + + First Shipped Date + DateTime + true + + + Min + + + + + G6ac74e13-07bf-4555-ac91-86f985289d91 + + + + + + true + Descending + d + true + + + Last Shipped Date + DateTime + true + + + Max + + + + + G6ac74e13-07bf-4555-ac91-86f985289d91 + + + + + + true + Descending + d + true + + + + + + Ship Via + Integer + true + Descending + 1 + g + + G6244bfac-ea98-47cc-8b52-6d2e3a4d010f + Dropdown + + + Sum Ship Via + Integer + true + + + Sum + + + + + G880f395d-a41e-4831-bfa2-10e9041077bf + + + + + + true + Descending + true + + + Avg Ship Via + Decimal + true + + + Avg + + + + + G880f395d-a41e-4831-bfa2-10e9041077bf + + + + + + true + Descending + true + + + Min Ship Via + Integer + true + + + Min + + + + + G880f395d-a41e-4831-bfa2-10e9041077bf + + + + + + true + Descending + true + + + Max Ship Via + Integer + true + + + Max + + + + + G880f395d-a41e-4831-bfa2-10e9041077bf + + + + + + true + Descending + true + + + + + + Freight + Decimal + true + Descending + 8 + g + true + true + + G94b735bc-7688-464c-ace7-17e48fe248aa + + + Sum Freight + Decimal + true + + + Sum + + + + + G90c903e1-d921-4039-9deb-809278b1ef46 + + + + + + true + Descending + true + + + Avg Freight + Decimal + true + + + Avg + + + + + G90c903e1-d921-4039-9deb-809278b1ef46 + + + + + + true + Descending + true + + + Min Freight + Decimal + true + + + Min + + + + + G90c903e1-d921-4039-9deb-809278b1ef46 + + + + + + true + Descending + true + + + Max Freight + Decimal + true + + + Max + + + + + G90c903e1-d921-4039-9deb-809278b1ef46 + + + + + + true + Descending + true + + + + + + Ship Name + String + true + 27 + true + Dropdown + + + + Ship Address + String + true + 32 + Dropdown + + + + Ship City + String + true + 14 + Dropdown + + + + Ship Region + String + true + 10 + Dropdown + + + + Ship Postal Code + String + true + 8 + Dropdown + + + + Ship Country + String + true + 9 + Dropdown + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + OptionalMany + + + +
+ + + Order Detail + Order Details + + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + + + + G2cf20212-6e20-4819-9643-f4592b136f87 + + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + + + + Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a + + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + + + + G6ac74e13-07bf-4555-ac91-86f985289d91 + + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + + + + Gc7a83797-6be0-4cff-96b4-ba2faae7afb9 + + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + + + + G90c903e1-d921-4039-9deb-809278b1ef46 + + + + + + Gd285fddd-c919-4f1f-87db-3e55e8c23b38 + + + + G0ab022c7-1254-4c19-a724-f8bcd833f314 + + + + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + + + + G2cf20212-6e20-4819-9643-f4592b136f87 + + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + + + + Gfca0e2f7-ed37-4ff9-9d29-e6306c7a207a + + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + + + + G6ac74e13-07bf-4555-ac91-86f985289d91 + + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + + + + Gc7a83797-6be0-4cff-96b4-ba2faae7afb9 + + + + + + Gebb72807-e55c-40d6-9688-877ad237cc71 + + + + G90c903e1-d921-4039-9deb-809278b1ef46 + + + + + + Gd285fddd-c919-4f1f-87db-3e55e8c23b38 + + + + G0ab022c7-1254-4c19-a724-f8bcd833f314 + + + + + + G672967fb-db1a-485a-bb8d-dd9b0ddc82d6 + + + FilteredList + + + #Order Details + Integer + + + Count + + + + + G4c235f0e-15f0-4ef6-a8c4-71536ba2204a + + + + + + true + Descending + n0 + true + + + + G530fd4df-6fda-461a-b4fa-c8b842421e06 + OptionalOne + + + + + G6fedb38a-fe49-478b-a7ba-5d7ef847e2e9 + OptionalOne + + + + Unit Price + Decimal + Descending + 7 + g + + G943da10c-7149-48a1-ab8e-75525d661f36 + Dropdown + + + Sum Unit Price + Decimal + true + + + Sum + + + + + G4254a5f1-c2d3-4092-8fb6-fe9562822080 + + + + + + true + Descending + true + + + Avg Unit Price + Decimal + true + + + Avg + + + + + G4254a5f1-c2d3-4092-8fb6-fe9562822080 + + + + + + true + Descending + true + + + Min Unit Price + Decimal + true + + + Min + + + + + G4254a5f1-c2d3-4092-8fb6-fe9562822080 + + + + + + true + Descending + true + + + Max Unit Price + Decimal + true + + + Max + + + + + G4254a5f1-c2d3-4092-8fb6-fe9562822080 + + + + + + true + Descending + true + + + + + + Quantity + Integer + Descending + 2 + g + + G18b07b3c-6a94-494b-8714-3e14b4e1b0b2 + Dropdown + + + Sum Quantity + Integer + true + + + Sum + + + + + Gb62c7a95-803a-42f0-8ad4-8d3b890c4118 + + + + + + true + Descending + true + + + Avg Quantity + Decimal + true + + + Avg + + + + + Gb62c7a95-803a-42f0-8ad4-8d3b890c4118 + + + + + + true + Descending + true + + + Min Quantity + Integer + true + + + Min + + + + + Gb62c7a95-803a-42f0-8ad4-8d3b890c4118 + + + + + + true + Descending + true + + + Max Quantity + Integer + true + + + Max + + + + + Gb62c7a95-803a-42f0-8ad4-8d3b890c4118 + + + + + + true + Descending + true + + + + + + Discount + Float + Descending + 2 + f2 + + G3c6ee1b3-d16c-4f15-81c3-88a0bd843ff2 + Dropdown + + + Sum Discount + Float + true + + + Sum + + + + + Gd9892c8c-24aa-48cb-b47e-ea485ee3833c + + + + + + true + Descending + true + + + Avg Discount + Float + true + + + Avg + + + + + Gd9892c8c-24aa-48cb-b47e-ea485ee3833c + + + + + + true + Descending + true + + + Min Discount + Float + true + + + Min + + + + + Gd9892c8c-24aa-48cb-b47e-ea485ee3833c + + + + + + true + Descending + true + + + Max Discount + Float + true + + + Max + + + + + Gd9892c8c-24aa-48cb-b47e-ea485ee3833c + + + + + + true + Descending + true + + + + + +
+ + + Order Details Extended + Order Details Extendeds + + + + Gc56f2541-e91b-4d96-bed6-d369ff668d32 + + + + G60bb9f15-86ad-46c7-aa46-71cf9c777581 + + + + G3baa3046-35ca-47e4-a9aa-23d130db0b1a + + + + G881a398c-8abb-4c5e-b25b-f214a1156b2c + + + + Geb3e8860-b9b8-4579-9251-257dec0d8a8a + + + + Gd6f6fd2f-ca5c-43a4-9473-20c43ca75c93 + + + + + + Geb3e8860-b9b8-4579-9251-257dec0d8a8a + + + + Gc56f2541-e91b-4d96-bed6-d369ff668d32 + + + + G60bb9f15-86ad-46c7-aa46-71cf9c777581 + + + + G3baa3046-35ca-47e4-a9aa-23d130db0b1a + + + + G881a398c-8abb-4c5e-b25b-f214a1156b2c + + + + Gd6f6fd2f-ca5c-43a4-9473-20c43ca75c93 + + + + G3543f6b0-f0fc-4416-8d80-a73328f69d14 + + + + + + G5ec40932-4758-4be6-a20c-6b7214e984e3 + + + FilteredList + + + #Order Details Extendeds + Integer + + + Count + + + + + Gbd2bd469-1d53-4e10-bfc2-5f5699df5aa3 + + + + + + true + Descending + n0 + true + + + Order ID + Integer + Descending + 5 + g + true + + + + Product ID + Integer + Descending + 2 + g + true + Dropdown + + + + Product Name + String + 30 + true + Dropdown + + + + Unit Price + Decimal + Descending + 7 + g + true + + Gf93a0826-0e66-4bbd-ada8-dd89134f60a5 + Dropdown + + + Sum Unit Price + Decimal + true + + + Sum + + + + + Gd6f6fd2f-ca5c-43a4-9473-20c43ca75c93 + + + + + + true + Descending + true + + + Avg Unit Price + Decimal + true + + + Avg + + + + + Gd6f6fd2f-ca5c-43a4-9473-20c43ca75c93 + + + + + + true + Descending + true + + + Min Unit Price + Decimal + true + + + Min + + + + + Gd6f6fd2f-ca5c-43a4-9473-20c43ca75c93 + + + + + + true + Descending + true + + + Max Unit Price + Decimal + true + + + Max + + + + + Gd6f6fd2f-ca5c-43a4-9473-20c43ca75c93 + + + + + + true + Descending + true + + + + + + Quantity + Integer + Descending + 2 + g + true + + Gc525dcfd-0f56-4339-82cb-0d9f38e23cc8 + Dropdown + + + Sum Quantity + Integer + true + + + Sum + + + + + G881a398c-8abb-4c5e-b25b-f214a1156b2c + + + + + + true + Descending + true + + + Avg Quantity + Decimal + true + + + Avg + + + + + G881a398c-8abb-4c5e-b25b-f214a1156b2c + + + + + + true + Descending + true + + + Min Quantity + Integer + true + + + Min + + + + + G881a398c-8abb-4c5e-b25b-f214a1156b2c + + + + + + true + Descending + true + + + Max Quantity + Integer + true + + + Max + + + + + G881a398c-8abb-4c5e-b25b-f214a1156b2c + + + + + + true + Descending + true + + + + + + Discount + Float + Descending + 2 + f2 + + G5b100315-efd3-49ed-8586-d69f7fc36ba4 + Dropdown + + + Sum Discount + Float + true + + + Sum + + + + + G3543f6b0-f0fc-4416-8d80-a73328f69d14 + + + + + + true + Descending + true + + + Avg Discount + Float + true + + + Avg + + + + + G3543f6b0-f0fc-4416-8d80-a73328f69d14 + + + + + + true + Descending + true + + + Min Discount + Float + true + + + Min + + + + + G3543f6b0-f0fc-4416-8d80-a73328f69d14 + + + + + + true + Descending + true + + + Max Discount + Float + true + + + Max + + + + + G3543f6b0-f0fc-4416-8d80-a73328f69d14 + + + + + + true + Descending + true + + + + + + Extended Price + Decimal + true + Descending + 8 + g + true + + Gd741302f-c123-40d0-891f-6d2fbc2048b1 + + + Sum Extended Price + Decimal + true + + + Sum + + + + + Geb3e8860-b9b8-4579-9251-257dec0d8a8a + + + + + + true + Descending + true + + + Avg Extended Price + Decimal + true + + + Avg + + + + + Geb3e8860-b9b8-4579-9251-257dec0d8a8a + + + + + + true + Descending + true + + + Min Extended Price + Decimal + true + + + Min + + + + + Geb3e8860-b9b8-4579-9251-257dec0d8a8a + + + + + + true + Descending + true + + + Max Extended Price + Decimal + true + + + Max + + + + + Geb3e8860-b9b8-4579-9251-257dec0d8a8a + + + + + + true + Descending + true + + + + + +
+ + + Order Subtotal + Order Subtotals + + + + G7d35502a-9581-413c-9179-e086e1aa51c5 + + + + G50e6ff84-db9d-4dbf-8c46-4eede90686d5 + + + + + + G7d35502a-9581-413c-9179-e086e1aa51c5 + + + + G50e6ff84-db9d-4dbf-8c46-4eede90686d5 + + + + + + G82863f81-8a55-4ef7-bbfa-4ec4739602dd + + + FilteredList + + + #Order Subtotals + Integer + + + Count + + + + + Gfb96a327-6626-4e47-a032-07b51f8d3c9d + + + + + + true + Descending + n0 + true + + + Order ID + Integer + Descending + 5 + g + true + true + + + + Subtotal + Decimal + true + Descending + 9 + g + true + true + + Gccbc6790-095c-45ef-b522-5e3c1f4623f1 + + + Sum Subtotal + Decimal + true + + + Sum + + + + + G50e6ff84-db9d-4dbf-8c46-4eede90686d5 + + + + + + true + Descending + true + + + Avg Subtotal + Decimal + true + + + Avg + + + + + G50e6ff84-db9d-4dbf-8c46-4eede90686d5 + + + + + + true + Descending + true + + + Min Subtotal + Decimal + true + + + Min + + + + + G50e6ff84-db9d-4dbf-8c46-4eede90686d5 + + + + + + true + Descending + true + + + Max Subtotal + Decimal + true + + + Max + + + + + G50e6ff84-db9d-4dbf-8c46-4eede90686d5 + + + + + + true + Descending + true + + + + + +
+ + + Orders Qry + Orders Qries + + + + Gdbec4d48-76f5-4e7e-a799-dbf2ee0b6c3e + + + + Gc8074ec9-6a6f-4d44-9875-98109f9479dd + + + + G4472b76e-0632-4b70-9b90-409e1ddba55c + + + + G48ec2d5c-9787-42d7-a36c-c31a431892fb + + + + + + Gdbec4d48-76f5-4e7e-a799-dbf2ee0b6c3e + + + + G361de97d-a0d4-4f1d-87a4-93f1e8df7750 + + + + Gc8074ec9-6a6f-4d44-9875-98109f9479dd + + + + G4472b76e-0632-4b70-9b90-409e1ddba55c + + + + G48ec2d5c-9787-42d7-a36c-c31a431892fb + + + + + + Gca3bc3d4-7203-4b38-b767-79e15cfeeb6e + + + FilteredList + + + #Orders Qries + Integer + + + Count + + + + + G94559dcf-4855-4185-be25-b279af1dfb44 + + + + + + true + Descending + n0 + true + + + Order ID + Integer + Descending + 5 + g + true + true + + + + Customer ID + String + true + 5 + Dropdown + + + + Employee ID + Integer + true + Descending + 1 + g + Dropdown + + + + Order Date + DateTime + true + Descending + d + true + + + Order Day + Integer + true + + + Day + + + + + Gc8074ec9-6a6f-4d44-9875-98109f9479dd + + + + + + + + Order Month + Integer + true + + + Month + + + + + Gc8074ec9-6a6f-4d44-9875-98109f9479dd + + + + + + + + Order Year + Integer + true + + + Year + + + + + Gc8074ec9-6a6f-4d44-9875-98109f9479dd + + + + + + + + Order Quarter + Integer + true + + + Quarter + + + + + Gc8074ec9-6a6f-4d44-9875-98109f9479dd + + + + + + + + First Order Date + DateTime + true + + + Min + + + + + Gc8074ec9-6a6f-4d44-9875-98109f9479dd + + + + + + true + Descending + d + true + + + Last Order Date + DateTime + true + + + Max + + + + + Gc8074ec9-6a6f-4d44-9875-98109f9479dd + + + + + + true + Descending + d + true + + + + + + Required Date + DateTime + true + Descending + d + true + + + Required Day + Integer + true + + + Day + + + + + G4472b76e-0632-4b70-9b90-409e1ddba55c + + + + + + + + Required Month + Integer + true + + + Month + + + + + G4472b76e-0632-4b70-9b90-409e1ddba55c + + + + + + + + Required Year + Integer + true + + + Year + + + + + G4472b76e-0632-4b70-9b90-409e1ddba55c + + + + + + + + Required Quarter + Integer + true + + + Quarter + + + + + G4472b76e-0632-4b70-9b90-409e1ddba55c + + + + + + + + First Required Date + DateTime + true + + + Min + + + + + G4472b76e-0632-4b70-9b90-409e1ddba55c + + + + + + true + Descending + d + true + + + Last Required Date + DateTime + true + + + Max + + + + + G4472b76e-0632-4b70-9b90-409e1ddba55c + + + + + + true + Descending + d + true + + + + + + Shipped Date + DateTime + true + Descending + d + true + + + Shipped Day + Integer + true + + + Day + + + + + G48ec2d5c-9787-42d7-a36c-c31a431892fb + + + + + + + + Shipped Month + Integer + true + + + Month + + + + + G48ec2d5c-9787-42d7-a36c-c31a431892fb + + + + + + + + Shipped Year + Integer + true + + + Year + + + + + G48ec2d5c-9787-42d7-a36c-c31a431892fb + + + + + + + + Shipped Quarter + Integer + true + + + Quarter + + + + + G48ec2d5c-9787-42d7-a36c-c31a431892fb + + + + + + + + First Shipped Date + DateTime + true + + + Min + + + + + G48ec2d5c-9787-42d7-a36c-c31a431892fb + + + + + + true + Descending + d + true + + + Last Shipped Date + DateTime + true + + + Max + + + + + G48ec2d5c-9787-42d7-a36c-c31a431892fb + + + + + + true + Descending + d + true + + + + + + Ship Via + Integer + true + Descending + 1 + g + + G12fe3c16-a8e7-4f73-8472-6e892a40ae63 + Dropdown + + + Sum Ship Via + Integer + true + + + Sum + + + + + G2c44c3df-5dec-4bce-b9b5-a3580a9363d2 + + + + + + true + Descending + true + + + Avg Ship Via + Decimal + true + + + Avg + + + + + G2c44c3df-5dec-4bce-b9b5-a3580a9363d2 + + + + + + true + Descending + true + + + Min Ship Via + Integer + true + + + Min + + + + + G2c44c3df-5dec-4bce-b9b5-a3580a9363d2 + + + + + + true + Descending + true + + + Max Ship Via + Integer + true + + + Max + + + + + G2c44c3df-5dec-4bce-b9b5-a3580a9363d2 + + + + + + true + Descending + true + + + + + + Freight + Decimal + true + Descending + 8 + g + true + + G1d2aa994-b35e-4d35-9933-e76d0a85d761 + + + Sum Freight + Decimal + true + + + Sum + + + + + G361de97d-a0d4-4f1d-87a4-93f1e8df7750 + + + + + + true + Descending + true + + + Avg Freight + Decimal + true + + + Avg + + + + + G361de97d-a0d4-4f1d-87a4-93f1e8df7750 + + + + + + true + Descending + true + + + Min Freight + Decimal + true + + + Min + + + + + G361de97d-a0d4-4f1d-87a4-93f1e8df7750 + + + + + + true + Descending + true + + + Max Freight + Decimal + true + + + Max + + + + + G361de97d-a0d4-4f1d-87a4-93f1e8df7750 + + + + + + true + Descending + true + + + + + + Ship Name + String + true + 27 + Dropdown + + + + Ship Address + String + true + 32 + Dropdown + + + + Ship City + String + true + 14 + Dropdown + + + + Ship Region + String + true + 10 + Dropdown + + + + Ship Postal Code + String + true + 8 + Dropdown + + + + Ship Country + String + true + 9 + Dropdown + + + + Company Name + String + 27 + Dropdown + + + + Address + String + true + 31 + Dropdown + + + + City + String + true + 13 + Dropdown + + + + Region + String + true + 10 + Dropdown + + + + Postal Code + String + true + 8 + Dropdown + + + + Country + String + true + 9 + Dropdown + + + +
+ + + Product + Products + + + + G0ab022c7-1254-4c19-a724-f8bcd833f314 + + + + + + G0ab022c7-1254-4c19-a724-f8bcd833f314 + + + + G077c733a-2a1d-4ca9-a42b-c6e73d3c663f + + + + G20cdd04a-75fa-413e-9bb1-2481a2040a15 + + + + G63ad2216-6a0b-449a-ba89-eb6c1d9d83e5 + + + + + + Ga6e20a1a-f939-476c-ad11-3ee1c1dcb276 + + + + Ge0bb8030-a85d-4df4-a409-a1bbe0f16e3d + + + + + + G0c527fbc-cd91-4a2c-b05c-b445aa40c439 + + + + G0043f9f6-1b1a-4f30-80aa-dbe9b8b8d82c + + + + + + Gd46cf663-5dcb-43b1-b516-0f337f1db1d2 + + + Dropdown + + + #Products + Integer + + + Count + + + + + G076a0d71-0e2e-472c-817b-390182ddab8d + + + + + + true + Descending + n0 + true + + + Product ID + true + Integer + Descending + 2 + g + true + Dropdown + + + + Product Name + String + 30 + true + true + Dropdown + + + + + G467d061b-359d-4ac1-9e24-5f6aa0126d47 + OptionalOne + + + + + Gadbb1d12-d90c-4ef8-9a69-710e1a0e08ba + OptionalOne + + + + Quantity Per Unit + String + true + 20 + true + Dropdown + + + + Unit Price + Decimal + true + Descending + 7 + g + + G18f861c4-d08c-42db-bbe4-c0e4ea494d88 + Dropdown + + + Sum Unit Price + Decimal + true + + + Sum + + + + + G20cdd04a-75fa-413e-9bb1-2481a2040a15 + + + + + + true + Descending + true + + + Avg Unit Price + Decimal + true + + + Avg + + + + + G20cdd04a-75fa-413e-9bb1-2481a2040a15 + + + + + + true + Descending + true + + + Min Unit Price + Decimal + true + + + Min + + + + + G20cdd04a-75fa-413e-9bb1-2481a2040a15 + + + + + + true + Descending + true + + + Max Unit Price + Decimal + true + + + Max + + + + + G20cdd04a-75fa-413e-9bb1-2481a2040a15 + + + + + + true + Descending + true + + + + + + Units In Stock + Integer + true + Descending + 3 + g + + Gf09c9c57-c922-4e34-a368-e70a14275575 + Dropdown + + + Sum Units In Stock + Integer + true + + + Sum + + + + + G63ad2216-6a0b-449a-ba89-eb6c1d9d83e5 + + + + + + true + Descending + true + + + Avg Units In Stock + Decimal + true + + + Avg + + + + + G63ad2216-6a0b-449a-ba89-eb6c1d9d83e5 + + + + + + true + Descending + true + + + Min Units In Stock + Integer + true + + + Min + + + + + G63ad2216-6a0b-449a-ba89-eb6c1d9d83e5 + + + + + + true + Descending + true + + + Max Units In Stock + Integer + true + + + Max + + + + + G63ad2216-6a0b-449a-ba89-eb6c1d9d83e5 + + + + + + true + Descending + true + + + + + + Units On Order + Integer + true + Descending + 2 + g + + Gac8c0988-6a08-46a1-9860-724d5df979bf + Dropdown + + + Sum Units On Order + Integer + true + + + Sum + + + + + G766a7c62-b008-4dec-b3c6-6063d4f3f5e2 + + + + + + true + Descending + true + + + Avg Units On Order + Decimal + true + + + Avg + + + + + G766a7c62-b008-4dec-b3c6-6063d4f3f5e2 + + + + + + true + Descending + true + + + Min Units On Order + Integer + true + + + Min + + + + + G766a7c62-b008-4dec-b3c6-6063d4f3f5e2 + + + + + + true + Descending + true + + + Max Units On Order + Integer + true + + + Max + + + + + G766a7c62-b008-4dec-b3c6-6063d4f3f5e2 + + + + + + true + Descending + true + + + + + + Reorder Level + Integer + true + Descending + 2 + g + + G1e7f46f6-1bcc-4b8a-99ef-f769e40fc71d + Dropdown + + + Sum Reorder Level + Integer + true + + + Sum + + + + + G05ebbbb2-99fd-4332-84e4-c41c1fc3c8c7 + + + + + + true + Descending + true + + + Avg Reorder Level + Decimal + true + + + Avg + + + + + G05ebbbb2-99fd-4332-84e4-c41c1fc3c8c7 + + + + + + true + Descending + true + + + Min Reorder Level + Integer + true + + + Min + + + + + G05ebbbb2-99fd-4332-84e4-c41c1fc3c8c7 + + + + + + true + Descending + true + + + Max Reorder Level + Integer + true + + + Max + + + + + G05ebbbb2-99fd-4332-84e4-c41c1fc3c8c7 + + + + + + true + Descending + true + + + + + + Discontinued + Boolean + Dropdown + + + + + Gd285fddd-c919-4f1f-87db-3e55e8c23b38 + OptionalMany + + + +
+ + + Region + Regions + + + + G567be66f-36cb-4ff5-86c8-6042f5b03290 + + + + + + G567be66f-36cb-4ff5-86c8-6042f5b03290 + + + + G8e6e9623-d028-4302-9d11-cff97c77c4f3 + + + + + + G8773807e-8649-48b0-9049-10e6dfde7a6b + + + Dropdown + + + #Regions + Integer + + + Count + + + + + Gc51a8a8d-c532-4224-aa60-2e1f377c2da9 + + + + + + true + Descending + n0 + true + + + Region ID + Integer + Descending + 1 + g + true + Dropdown + + + + Region Description + String + 8 + true + true + Dropdown + + + + + Gd4617712-fada-4440-b2ff-8ea1ed23d767 + OptionalMany + + + +
+ + + Sales By Category + Sales By Categories + + + + Gd39c3ee1-b51e-4d61-8398-416d41f9f3af + + + + + + Gd39c3ee1-b51e-4d61-8398-416d41f9f3af + + + + Gbbe6d046-1de4-4e89-8743-c93ba5db4505 + + + + G62e31650-6d7a-459e-afb0-7bd4294a06dd + + + + G31875163-820b-4c02-b052-6913d727fda6 + + + + + + Gef0cb543-09f6-4c04-b967-d0738649a7b1 + + + Dropdown + + + #Sales By Categories + Integer + + + Count + + + + + G840d0cdf-2ddd-431d-a835-0e712ed107de + + + + + + true + Descending + n0 + true + + + Category ID + Integer + Descending + 1 + g + true + Dropdown + + + + Category Name + String + 14 + Dropdown + + + + Product Name + String + 30 + true + true + Dropdown + + + + Product Sales + Decimal + true + Descending + 10 + g + true + + G435f7a59-608a-4539-9b1c-a28251fcec12 + Dropdown + + + Sum Product Sales + Decimal + true + + + Sum + + + + + G62e31650-6d7a-459e-afb0-7bd4294a06dd + + + + + + true + Descending + true + + + Avg Product Sales + Decimal + true + + + Avg + + + + + G62e31650-6d7a-459e-afb0-7bd4294a06dd + + + + + + true + Descending + true + + + Min Product Sales + Decimal + true + + + Min + + + + + G62e31650-6d7a-459e-afb0-7bd4294a06dd + + + + + + true + Descending + true + + + Max Product Sales + Decimal + true + + + Max + + + + + G62e31650-6d7a-459e-afb0-7bd4294a06dd + + + + + + true + Descending + true + + + + + +
+ + + Sales Totals By Amount + Sales Totals By Amounts + + + + Gf854ce01-d91e-4501-a3b5-4e9e6d0bb069 + + + + Ge23fef10-8a92-442f-b5cc-8eddbebd9655 + + + + + + Gf854ce01-d91e-4501-a3b5-4e9e6d0bb069 + + + + Ge23fef10-8a92-442f-b5cc-8eddbebd9655 + + + + G5dba4fd7-0995-42d9-a03f-e6d01ae3b457 + + + + G87a73455-e05f-4374-94e7-7ad31ed775db + + + + + + G9dd33565-11bc-4e83-bc2b-0e453b662033 + + + Dropdown + + + #Sales Totals By Amounts + Integer + + + Count + + + + + G2a0d86a6-1d4d-48a5-871f-41541bd3856a + + + + + + true + Descending + n0 + true + + + Sale Amount + Decimal + true + Descending + 9 + g + true + + Gf0701d34-13bb-462d-83fb-6dc8a0cdd132 + Dropdown + + + Sum Sale Amount + Decimal + true + + + Sum + + + + + G5dba4fd7-0995-42d9-a03f-e6d01ae3b457 + + + + + + true + Descending + true + + + Avg Sale Amount + Decimal + true + + + Avg + + + + + G5dba4fd7-0995-42d9-a03f-e6d01ae3b457 + + + + + + true + Descending + true + + + Min Sale Amount + Decimal + true + + + Min + + + + + G5dba4fd7-0995-42d9-a03f-e6d01ae3b457 + + + + + + true + Descending + true + + + Max Sale Amount + Decimal + true + + + Max + + + + + G5dba4fd7-0995-42d9-a03f-e6d01ae3b457 + + + + + + true + Descending + true + + + + + + Order ID + Integer + Descending + 5 + g + true + true + Dropdown + + + + Company Name + String + 25 + Dropdown + + + + Shipped Date + DateTime + true + Descending + d + true + true + Dropdown + + + Shipped Day + Integer + true + + + Day + + + + + Ge23fef10-8a92-442f-b5cc-8eddbebd9655 + + + + + + + + Shipped Month + Integer + true + + + Month + + + + + Ge23fef10-8a92-442f-b5cc-8eddbebd9655 + + + + + + + + Shipped Year + Integer + true + + + Year + + + + + Ge23fef10-8a92-442f-b5cc-8eddbebd9655 + + + + + + + + Shipped Quarter + Integer + true + + + Quarter + + + + + Ge23fef10-8a92-442f-b5cc-8eddbebd9655 + + + + + + + + First Shipped Date + DateTime + true + + + Min + + + + + Ge23fef10-8a92-442f-b5cc-8eddbebd9655 + + + + + + true + Descending + d + true + + + Last Shipped Date + DateTime + true + + + Max + + + + + Ge23fef10-8a92-442f-b5cc-8eddbebd9655 + + + + + + true + Descending + d + true + + + + + +
+ + + Shipper + Shippers + + + + G95733084-1d34-4843-81a6-381192baa4dd + + + + + + G95733084-1d34-4843-81a6-381192baa4dd + + + + G55d02df8-ef01-4027-a6cc-d24942fcbe2c + + + + + + Gff38747b-5715-495c-82e9-817df6d66da9 + + + Dropdown + + + #Shippers + Integer + + + Count + + + + + Gb610ae81-244f-4155-bb9a-fc95b56a42d3 + + + + + + true + Descending + n0 + true + + + Shipper ID + true + Integer + Descending + 1 + g + true + Dropdown + + + + Company Name + String + 16 + true + true + Dropdown + + + + Phone + String + true + 14 + true + Dropdown + + + +
+ + + Summary Of Sales By Quarter + Summary Of Sales By Quarters + + + + G1aa265a0-5dcb-46ee-a129-77d0b7fb2e7a + + + + G962cdb84-3399-4473-9006-f8ff8cf129b7 + + + + G5d7679ad-5c58-43bf-a894-c75448f86ffe + + + + + + G1aa265a0-5dcb-46ee-a129-77d0b7fb2e7a + + + + G5d7679ad-5c58-43bf-a894-c75448f86ffe + + + + G962cdb84-3399-4473-9006-f8ff8cf129b7 + + + + + + G01efea84-0b6d-4e62-b7ba-646b16f93546 + + + FilteredList + + + #Summary Of Sales By Quarters + Integer + + + Count + + + + + G80a4f203-1651-41aa-8017-d19314d3f009 + + + + + + true + Descending + n0 + true + + + Shipped Date + DateTime + true + Descending + d + true + + + Shipped Day + Integer + true + + + Day + + + + + G962cdb84-3399-4473-9006-f8ff8cf129b7 + + + + + + + + Shipped Month + Integer + true + + + Month + + + + + G962cdb84-3399-4473-9006-f8ff8cf129b7 + + + + + + + + Shipped Year + Integer + true + + + Year + + + + + G962cdb84-3399-4473-9006-f8ff8cf129b7 + + + + + + + + Shipped Quarter + Integer + true + + + Quarter + + + + + G962cdb84-3399-4473-9006-f8ff8cf129b7 + + + + + + + + First Shipped Date + DateTime + true + + + Min + + + + + G962cdb84-3399-4473-9006-f8ff8cf129b7 + + + + + + true + Descending + d + true + + + Last Shipped Date + DateTime + true + + + Max + + + + + G962cdb84-3399-4473-9006-f8ff8cf129b7 + + + + + + true + Descending + d + true + + + + + + Order ID + Integer + Descending + 5 + g + true + true + + + + Subtotal + Decimal + true + Descending + 9 + g + true + true + + G632c92e3-a18d-41cb-8966-1ae72482b4a2 + + + Sum Subtotal + Decimal + true + + + Sum + + + + + G5d7679ad-5c58-43bf-a894-c75448f86ffe + + + + + + true + Descending + true + + + Avg Subtotal + Decimal + true + + + Avg + + + + + G5d7679ad-5c58-43bf-a894-c75448f86ffe + + + + + + true + Descending + true + + + Min Subtotal + Decimal + true + + + Min + + + + + G5d7679ad-5c58-43bf-a894-c75448f86ffe + + + + + + true + Descending + true + + + Max Subtotal + Decimal + true + + + Max + + + + + G5d7679ad-5c58-43bf-a894-c75448f86ffe + + + + + + true + Descending + true + + + + + +
+ + + Summary Of Sales By Year + Summary Of Sales By Years + + + + G3a93726c-ce6b-494d-97e1-e4af307bd504 + + + + Gc7c8bee7-77dc-48b1-bb99-7d8dc5a069a6 + + + + Ge5cc85ce-fe4c-418a-b5d9-236a1a078b4f + + + + + + G3a93726c-ce6b-494d-97e1-e4af307bd504 + + + + Ge5cc85ce-fe4c-418a-b5d9-236a1a078b4f + + + + Gc7c8bee7-77dc-48b1-bb99-7d8dc5a069a6 + + + + + + G5bb1520c-e2a4-43fc-9ac8-0c57892fc10e + + + FilteredList + + + #Summary Of Sales By Years + Integer + + + Count + + + + + G2a096595-7446-4365-9fc7-2a1a2a497682 + + + + + + true + Descending + n0 + true + + + Shipped Date + DateTime + true + Descending + d + true + + + Shipped Day + Integer + true + + + Day + + + + + Gc7c8bee7-77dc-48b1-bb99-7d8dc5a069a6 + + + + + + + + Shipped Month + Integer + true + + + Month + + + + + Gc7c8bee7-77dc-48b1-bb99-7d8dc5a069a6 + + + + + + + + Shipped Year + Integer + true + + + Year + + + + + Gc7c8bee7-77dc-48b1-bb99-7d8dc5a069a6 + + + + + + + + Shipped Quarter + Integer + true + + + Quarter + + + + + Gc7c8bee7-77dc-48b1-bb99-7d8dc5a069a6 + + + + + + + + First Shipped Date + DateTime + true + + + Min + + + + + Gc7c8bee7-77dc-48b1-bb99-7d8dc5a069a6 + + + + + + true + Descending + d + true + + + Last Shipped Date + DateTime + true + + + Max + + + + + Gc7c8bee7-77dc-48b1-bb99-7d8dc5a069a6 + + + + + + true + Descending + d + true + + + + + + Order ID + Integer + Descending + 5 + g + true + true + + + + Subtotal + Decimal + true + Descending + 9 + g + true + true + + G270833f4-bcd1-4ee8-b2d9-6d541d72094f + + + Sum Subtotal + Decimal + true + + + Sum + + + + + Ge5cc85ce-fe4c-418a-b5d9-236a1a078b4f + + + + + + true + Descending + true + + + Avg Subtotal + Decimal + true + + + Avg + + + + + Ge5cc85ce-fe4c-418a-b5d9-236a1a078b4f + + + + + + true + Descending + true + + + Min Subtotal + Decimal + true + + + Min + + + + + Ge5cc85ce-fe4c-418a-b5d9-236a1a078b4f + + + + + + true + Descending + true + + + Max Subtotal + Decimal + true + + + Max + + + + + Ge5cc85ce-fe4c-418a-b5d9-236a1a078b4f + + + + + + true + Descending + true + + + + + +
+ + + Supplier + Suppliers + + + + Ge0bb8030-a85d-4df4-a409-a1bbe0f16e3d + + + + + + Ge0bb8030-a85d-4df4-a409-a1bbe0f16e3d + + + + Gd4c876f9-22a0-47ad-b7bb-5d2a30c7cd3b + + + + G29b58d78-b260-47b8-bf62-e709c33d0163 + + + + + + G3c69d28f-2e27-43e9-a35b-5ff6c8bbe651 + + + Dropdown + + + #Suppliers + Integer + + + Count + + + + + G9e7962cf-4d22-4a00-93b2-870521c7633c + + + + + + true + Descending + n0 + true + + + Supplier ID + true + Integer + Descending + 2 + g + true + Dropdown + + + + Company Name + String + 35 + true + true + Dropdown + + + + Contact Name + String + true + 19 + true + Dropdown + + + + Contact Title + String + true + 27 + Dropdown + + + + Address + String + true + 36 + true + Dropdown + + + + City + String + true + 11 + true + Dropdown + + + + Region + String + true + 8 + true + Dropdown + + + + Postal Code + String + true + 7 + true + Dropdown + + + + Country + String + true + 10 + Dropdown + + + + Phone + String + true + 15 + true + Dropdown + + + + Fax + String + true + 15 + true + Dropdown + + + + + Ga6e20a1a-f939-476c-ad11-3ee1c1dcb276 + OptionalMany + + + +
+ + + Territory + Territories + + + + Gbc4e69d5-199a-4c87-85d3-1ab8c0efd146 + + + + + + Gbc4e69d5-199a-4c87-85d3-1ab8c0efd146 + + + + G6b34ef9e-9924-4742-b04a-5400ba6ae2ce + + + + + + Gd4617712-fada-4440-b2ff-8ea1ed23d767 + + + + G567be66f-36cb-4ff5-86c8-6042f5b03290 + + + + + + G5eb719b0-0b85-4852-a487-de2e104cc4cf + + + Dropdown + + + #Territories + Integer + + + Count + + + + + Gb76e46ab-4d49-4bda-a2df-24b7d319c3e8 + + + + + + true + Descending + n0 + true + + + Territory ID + String + 5 + true + Dropdown + + + + Territory Description + String + 13 + true + true + Dropdown + + + + + Gb719acb6-dae9-4b7d-af2a-2dfea304a245 + OptionalOne + + + + + G6cfdac3f-7184-45aa-bb35-af61ee5dcef3 + OptionalMany + + + +
+ + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.database b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.database new file mode 100644 index 0000000..1ba6e94 --- /dev/null +++ b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.database @@ -0,0 +1,15 @@ + + Report Model Project1 + Report Model Project1 + 0001-01-01T08:00:00Z + 0001-01-01T08:00:00Z + 0001-01-01T08:00:00Z + Unprocessed + 0001-01-01T08:00:00Z + + Default + Unchanged + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.sln b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.sln new file mode 100644 index 0000000..3cd3ccb --- /dev/null +++ b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.sln @@ -0,0 +1,18 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{999D2CB9-9277-4465-A902-1604ED3686A3}") = "Northwind Report Model Project", "Northwind Report Model Project.smdlproj", "{8C1AE98C-50C7-4985-831F-EA2035C923E3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Production|Default = Production|Default + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8C1AE98C-50C7-4985-831F-EA2035C923E3}.Production|Default.ActiveCfg = Production + {8C1AE98C-50C7-4985-831F-EA2035C923E3}.Production|Default.Build.0 = Production + {8C1AE98C-50C7-4985-831F-EA2035C923E3}.Production|Default.Deploy.0 = Production + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.smdlproj.user b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.smdlproj.user new file mode 100644 index 0000000..8a67a03 --- /dev/null +++ b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.smdlproj.user @@ -0,0 +1,13 @@ + + + + + Production + Win32 + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.suo b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.suo new file mode 100644 index 0000000..8b82e9b Binary files /dev/null and b/1590594770-1/Chapter09/Report Builder Sample/Report Model Project1/Report Model Project1.suo differ diff --git a/1590594770-1/Chapter09/Report Builder Sample/readme.txt b/1590594770-1/Chapter09/Report Builder Sample/readme.txt new file mode 100644 index 0000000..8a7e174 --- /dev/null +++ b/1590594770-1/Chapter09/Report Builder Sample/readme.txt @@ -0,0 +1,20 @@ +This sample application shows you how to use Report Builder in Reporting Services 2005. + +Please note that you must have the Northwind sample installed to use this application. + +To use the applications, please follow these steps: + +1) Double-click the Report Model Project1.sln file in the Report Model Project1 folder to launch Visual Studio which will load the file. + +2) Right-click Northwind.smdl and click deploy. + +3) Launch Report Manager by launching Internet Explorer and going to http://localhost/reports. + +4) Click on the Report Builder icon on the toolbar. + +5) Click the Open from File in the lower right hand corner and select Northwind Report Builder Report.rdl from where you installed the samples with the book. + +6) You may get an error when you open the file about an unknown entity. Ignore the error and hit ok. + +7) To try the report, click the Run Report button on the toolbar. + diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample.sln b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample.sln new file mode 100644 index 0000000..44b0a15 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Report Control Sample", "Report Control Sample\Report Control Sample.vbproj", "{D5DAE4D1-27A6-4AE6-AF50-82B39B99BDCE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D5DAE4D1-27A6-4AE6-AF50-82B39B99BDCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D5DAE4D1-27A6-4AE6-AF50-82B39B99BDCE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D5DAE4D1-27A6-4AE6-AF50-82B39B99BDCE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D5DAE4D1-27A6-4AE6-AF50-82B39B99BDCE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample.suo b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample.suo new file mode 100644 index 0000000..8f787b7 Binary files /dev/null and b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample.suo differ diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.Designer.vb b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.Designer.vb new file mode 100644 index 0000000..a2c093f --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.Designer.vb @@ -0,0 +1,882 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50215.312 +' +' 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 AdventureWorksDataSet + Inherits System.Data.DataSet + + Private tableGetProducts As GetProductsDataTable + + 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) + 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("GetProducts")) Is Nothing) Then + MyBase.Tables.Add(New GetProductsDataTable(ds.Tables("GetProducts"))) + 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 GetProducts() As GetProductsDataTable + Get + Return Me.tableGetProducts + 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 + + _ + Public Shadows Property EnforceConstraints() As Boolean + Get + Return MyBase.EnforceConstraints + End Get + Set + MyBase.EnforceConstraints = value + End Set + 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 AdventureWorksDataSet = CType(MyBase.Clone,AdventureWorksDataSet) + cln.InitVars + 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("GetProducts")) Is Nothing) Then + MyBase.Tables.Add(New GetProductsDataTable(ds.Tables("GetProducts"))) + 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.tableGetProducts = CType(MyBase.Tables("GetProducts"),GetProductsDataTable) + If (initTable = true) Then + If (Not (Me.tableGetProducts) Is Nothing) Then + Me.tableGetProducts.InitVars + End If + End If + End Sub + + Private Sub InitClass() + Me.DataSetName = "AdventureWorksDataSet" + Me.Prefix = "" + Me.Namespace = "http://tempuri.org/AdventureWorksDataSet.xsd" + Me.EnforceConstraints = true + Me.tableGetProducts = New GetProductsDataTable + MyBase.Tables.Add(Me.tableGetProducts) + End Sub + + Private Function ShouldSerializeGetProducts() 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 AdventureWorksDataSet = New AdventureWorksDataSet + 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 GetProductsRowChangeEventHandler(ByVal sender As Object, ByVal e As GetProductsRowChangeEvent) + + _ + Partial Public Class GetProductsDataTable + Inherits System.Data.DataTable + Implements System.Collections.IEnumerable + + Private columnName As System.Data.DataColumn + + Private columnCategoryName As System.Data.DataColumn + + Private columnSubCategoryName As System.Data.DataColumn + + Private columnProductNumber As System.Data.DataColumn + + Private columnColor As System.Data.DataColumn + + Private columnStandardCost As System.Data.DataColumn + + Private columnListPrice As System.Data.DataColumn + + Private columnSize As System.Data.DataColumn + + Private columnWeight As System.Data.DataColumn + + Private columnClass As System.Data.DataColumn + + Private columnStyle As System.Data.DataColumn + + Private columnProductID As System.Data.DataColumn + + Public Sub New() + MyBase.New + Me.TableName = "GetProducts" + 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 NameColumn() As System.Data.DataColumn + Get + Return Me.columnName + End Get + End Property + + Public ReadOnly Property CategoryNameColumn() As System.Data.DataColumn + Get + Return Me.columnCategoryName + End Get + End Property + + Public ReadOnly Property SubCategoryNameColumn() As System.Data.DataColumn + Get + Return Me.columnSubCategoryName + End Get + End Property + + Public ReadOnly Property ProductNumberColumn() As System.Data.DataColumn + Get + Return Me.columnProductNumber + End Get + End Property + + Public ReadOnly Property ColorColumn() As System.Data.DataColumn + Get + Return Me.columnColor + End Get + End Property + + Public ReadOnly Property StandardCostColumn() As System.Data.DataColumn + Get + Return Me.columnStandardCost + End Get + End Property + + Public ReadOnly Property ListPriceColumn() As System.Data.DataColumn + Get + Return Me.columnListPrice + End Get + End Property + + Public ReadOnly Property SizeColumn() As System.Data.DataColumn + Get + Return Me.columnSize + End Get + End Property + + Public ReadOnly Property WeightColumn() As System.Data.DataColumn + Get + Return Me.columnWeight + End Get + End Property + + Public ReadOnly Property ClassColumn() As System.Data.DataColumn + Get + Return Me.columnClass + End Get + End Property + + Public ReadOnly Property StyleColumn() As System.Data.DataColumn + Get + Return Me.columnStyle + End Get + End Property + + Public ReadOnly Property ProductIDColumn() As System.Data.DataColumn + Get + Return Me.columnProductID + 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 GetProductsRow + Get + Return CType(Me.Rows(index),GetProductsRow) + End Get + End Property + + Public Event GetProductsRowChanged As GetProductsRowChangeEventHandler + + Public Event GetProductsRowChanging As GetProductsRowChangeEventHandler + + Public Event GetProductsRowDeleted As GetProductsRowChangeEventHandler + + Public Event GetProductsRowDeleting As GetProductsRowChangeEventHandler + + Public Overloads Sub AddGetProductsRow(ByVal row As GetProductsRow) + Me.Rows.Add(row) + End Sub + + Public Overloads Function AddGetProductsRow(ByVal Name As String, ByVal CategoryName As String, ByVal SubCategoryName As String, ByVal ProductNumber As String, ByVal Color As String, ByVal StandardCost As Decimal, ByVal ListPrice As Decimal, ByVal Size As String, ByVal Weight As Decimal, ByVal _Class As String, ByVal Style As String) As GetProductsRow + Dim rowGetProductsRow As GetProductsRow = CType(Me.NewRow,GetProductsRow) + rowGetProductsRow.ItemArray = New Object() {Name, CategoryName, SubCategoryName, ProductNumber, Color, StandardCost, ListPrice, Size, Weight, _Class, Style, Nothing} + Me.Rows.Add(rowGetProductsRow) + Return rowGetProductsRow + End Function + + Public Function FindByProductID(ByVal ProductID As Integer) As GetProductsRow + Return CType(Me.Rows.Find(New Object() {ProductID}),GetProductsRow) + 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 GetProductsDataTable = CType(MyBase.Clone,GetProductsDataTable) + cln.InitVars + Return cln + End Function + + Protected Overrides Function CreateInstance() As System.Data.DataTable + Return New GetProductsDataTable + End Function + + Friend Sub InitVars() + Me.columnName = MyBase.Columns("Name") + Me.columnCategoryName = MyBase.Columns("CategoryName") + Me.columnSubCategoryName = MyBase.Columns("SubCategoryName") + Me.columnProductNumber = MyBase.Columns("ProductNumber") + Me.columnColor = MyBase.Columns("Color") + Me.columnStandardCost = MyBase.Columns("StandardCost") + Me.columnListPrice = MyBase.Columns("ListPrice") + Me.columnSize = MyBase.Columns("Size") + Me.columnWeight = MyBase.Columns("Weight") + Me.columnClass = MyBase.Columns("Class") + Me.columnStyle = MyBase.Columns("Style") + Me.columnProductID = MyBase.Columns("ProductID") + End Sub + + Private Sub InitClass() + Me.columnName = New System.Data.DataColumn("Name", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnName) + Me.columnCategoryName = New System.Data.DataColumn("CategoryName", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnCategoryName) + Me.columnSubCategoryName = New System.Data.DataColumn("SubCategoryName", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnSubCategoryName) + Me.columnProductNumber = New System.Data.DataColumn("ProductNumber", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnProductNumber) + Me.columnColor = New System.Data.DataColumn("Color", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnColor) + Me.columnStandardCost = New System.Data.DataColumn("StandardCost", GetType(Decimal), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnStandardCost) + Me.columnListPrice = New System.Data.DataColumn("ListPrice", GetType(Decimal), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnListPrice) + Me.columnSize = New System.Data.DataColumn("Size", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnSize) + Me.columnWeight = New System.Data.DataColumn("Weight", GetType(Decimal), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnWeight) + Me.columnClass = New System.Data.DataColumn("Class", GetType(String), Nothing, System.Data.MappingType.Element) + Me.columnClass.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "_Class") + Me.columnClass.ExtendedProperties.Add("Generator_UserColumnName", "Class") + MyBase.Columns.Add(Me.columnClass) + Me.columnStyle = New System.Data.DataColumn("Style", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnStyle) + Me.columnProductID = New System.Data.DataColumn("ProductID", GetType(Integer), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnProductID) + Me.Constraints.Add(New System.Data.UniqueConstraint("Constraint1", New System.Data.DataColumn() {Me.columnProductID}, true)) + Me.columnName.AllowDBNull = false + Me.columnName.MaxLength = 50 + Me.columnCategoryName.AllowDBNull = false + Me.columnCategoryName.MaxLength = 50 + Me.columnSubCategoryName.AllowDBNull = false + Me.columnSubCategoryName.MaxLength = 50 + Me.columnProductNumber.AllowDBNull = false + Me.columnProductNumber.MaxLength = 25 + Me.columnColor.MaxLength = 15 + Me.columnStandardCost.AllowDBNull = false + Me.columnListPrice.AllowDBNull = false + Me.columnSize.MaxLength = 5 + Me.columnClass.MaxLength = 2 + Me.columnStyle.MaxLength = 2 + Me.columnProductID.AutoIncrement = true + Me.columnProductID.AllowDBNull = false + Me.columnProductID.ReadOnly = true + Me.columnProductID.Unique = true + End Sub + + Public Function NewGetProductsRow() As GetProductsRow + Return CType(Me.NewRow,GetProductsRow) + End Function + + Protected Overrides Function NewRowFromBuilder(ByVal builder As System.Data.DataRowBuilder) As System.Data.DataRow + Return New GetProductsRow(builder) + End Function + + Protected Overrides Function GetRowType() As System.Type + Return GetType(GetProductsRow) + End Function + + Protected Overrides Sub OnRowChanged(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanged(e) + If (Not (Me.GetProductsRowChangedEvent) Is Nothing) Then + RaiseEvent GetProductsRowChanged(Me, New GetProductsRowChangeEvent(CType(e.Row,GetProductsRow), e.Action)) + End If + End Sub + + Protected Overrides Sub OnRowChanging(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanging(e) + If (Not (Me.GetProductsRowChangingEvent) Is Nothing) Then + RaiseEvent GetProductsRowChanging(Me, New GetProductsRowChangeEvent(CType(e.Row,GetProductsRow), e.Action)) + End If + End Sub + + Protected Overrides Sub OnRowDeleted(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleted(e) + If (Not (Me.GetProductsRowDeletedEvent) Is Nothing) Then + RaiseEvent GetProductsRowDeleted(Me, New GetProductsRowChangeEvent(CType(e.Row,GetProductsRow), e.Action)) + End If + End Sub + + Protected Overrides Sub OnRowDeleting(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleting(e) + If (Not (Me.GetProductsRowDeletingEvent) Is Nothing) Then + RaiseEvent GetProductsRowDeleting(Me, New GetProductsRowChangeEvent(CType(e.Row,GetProductsRow), e.Action)) + End If + End Sub + + Public Sub RemoveGetProductsRow(ByVal row As GetProductsRow) + 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 AdventureWorksDataSet = New AdventureWorksDataSet + 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 = "GetProductsDataTable" + type.Attributes.Add(attribute2) + type.Particle = sequence + Return type + End Function + End Class + + Partial Public Class GetProductsRow + Inherits System.Data.DataRow + + Private tableGetProducts As GetProductsDataTable + + Friend Sub New(ByVal rb As System.Data.DataRowBuilder) + MyBase.New(rb) + Me.tableGetProducts = CType(Me.Table,GetProductsDataTable) + End Sub + + Public Property Name() As String + Get + Return CType(Me(Me.tableGetProducts.NameColumn),String) + End Get + Set + Me(Me.tableGetProducts.NameColumn) = value + End Set + End Property + + Public Property CategoryName() As String + Get + Return CType(Me(Me.tableGetProducts.CategoryNameColumn),String) + End Get + Set + Me(Me.tableGetProducts.CategoryNameColumn) = value + End Set + End Property + + Public Property SubCategoryName() As String + Get + Return CType(Me(Me.tableGetProducts.SubCategoryNameColumn),String) + End Get + Set + Me(Me.tableGetProducts.SubCategoryNameColumn) = value + End Set + End Property + + Public Property ProductNumber() As String + Get + Return CType(Me(Me.tableGetProducts.ProductNumberColumn),String) + End Get + Set + Me(Me.tableGetProducts.ProductNumberColumn) = value + End Set + End Property + + Public Property Color() As String + Get + Try + Return CType(Me(Me.tableGetProducts.ColorColumn),String) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'Color' in table 'GetProducts' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableGetProducts.ColorColumn) = value + End Set + End Property + + Public Property StandardCost() As Decimal + Get + Return CType(Me(Me.tableGetProducts.StandardCostColumn),Decimal) + End Get + Set + Me(Me.tableGetProducts.StandardCostColumn) = value + End Set + End Property + + Public Property ListPrice() As Decimal + Get + Return CType(Me(Me.tableGetProducts.ListPriceColumn),Decimal) + End Get + Set + Me(Me.tableGetProducts.ListPriceColumn) = value + End Set + End Property + + Public Property Size() As String + Get + Try + Return CType(Me(Me.tableGetProducts.SizeColumn),String) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'Size' in table 'GetProducts' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableGetProducts.SizeColumn) = value + End Set + End Property + + Public Property Weight() As Decimal + Get + Try + Return CType(Me(Me.tableGetProducts.WeightColumn),Decimal) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'Weight' in table 'GetProducts' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableGetProducts.WeightColumn) = value + End Set + End Property + + Public Property _Class() As String + Get + Try + Return CType(Me(Me.tableGetProducts.ClassColumn),String) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'Class' in table 'GetProducts' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableGetProducts.ClassColumn) = value + End Set + End Property + + Public Property Style() As String + Get + Try + Return CType(Me(Me.tableGetProducts.StyleColumn),String) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'Style' in table 'GetProducts' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableGetProducts.StyleColumn) = value + End Set + End Property + + Public Property ProductID() As Integer + Get + Return CType(Me(Me.tableGetProducts.ProductIDColumn),Integer) + End Get + Set + Me(Me.tableGetProducts.ProductIDColumn) = value + End Set + End Property + + Public Function IsColorNull() As Boolean + Return Me.IsNull(Me.tableGetProducts.ColorColumn) + End Function + + Public Sub SetColorNull() + Me(Me.tableGetProducts.ColorColumn) = System.Convert.DBNull + End Sub + + Public Function IsSizeNull() As Boolean + Return Me.IsNull(Me.tableGetProducts.SizeColumn) + End Function + + Public Sub SetSizeNull() + Me(Me.tableGetProducts.SizeColumn) = System.Convert.DBNull + End Sub + + Public Function IsWeightNull() As Boolean + Return Me.IsNull(Me.tableGetProducts.WeightColumn) + End Function + + Public Sub SetWeightNull() + Me(Me.tableGetProducts.WeightColumn) = System.Convert.DBNull + End Sub + + Public Function Is_ClassNull() As Boolean + Return Me.IsNull(Me.tableGetProducts.ClassColumn) + End Function + + Public Sub Set_ClassNull() + Me(Me.tableGetProducts.ClassColumn) = System.Convert.DBNull + End Sub + + Public Function IsStyleNull() As Boolean + Return Me.IsNull(Me.tableGetProducts.StyleColumn) + End Function + + Public Sub SetStyleNull() + Me(Me.tableGetProducts.StyleColumn) = System.Convert.DBNull + End Sub + End Class + + Public Class GetProductsRowChangeEvent + Inherits System.EventArgs + + Private eventRow As GetProductsRow + + Private eventAction As System.Data.DataRowAction + + Public Sub New(ByVal row As GetProductsRow, ByVal action As System.Data.DataRowAction) + MyBase.New + Me.eventRow = row + Me.eventAction = action + End Sub + + Public ReadOnly Property Row() As GetProductsRow + 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 AdventureWorksDataSetTableAdapters + + _ + Partial Public Class GetProductsTableAdapter + Inherits System.ComponentModel.Component + + Private WithEvents m_adapter As System.Data.SqlClient.SqlDataAdapter + + Private m_connection As System.Data.SqlClient.SqlConnection + + Private m_commandCollection() As System.Data.SqlClient.SqlCommand + + Private m_clearBeforeFill As Boolean + + Public Sub New() + MyBase.New + Me.m_clearBeforeFill = true + End Sub + + Private ReadOnly Property Adapter() As System.Data.SqlClient.SqlDataAdapter + Get + If (Me.m_adapter Is Nothing) Then + Me.InitAdapter + End If + Return Me.m_adapter + End Get + End Property + + Friend Property Connection() As System.Data.SqlClient.SqlConnection + Get + If (Me.m_connection Is Nothing) Then + Me.InitConnection + End If + Return Me.m_connection + End Get + Set + Me.m_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.m_commandCollection Is Nothing) Then + Me.InitCommandCollection + End If + Return Me.m_commandCollection + End Get + End Property + + Public Property ClearBeforeFill() As Boolean + Get + Return Me.m_clearBeforeFill + End Get + Set + Me.m_clearBeforeFill = value + End Set + End Property + + Private Sub InitAdapter() + Me.m_adapter = New System.Data.SqlClient.SqlDataAdapter + Dim tableMapping As System.Data.Common.DataTableMapping = New System.Data.Common.DataTableMapping + tableMapping.SourceTable = "Table" + tableMapping.DataSetTable = "GetProducts" + tableMapping.ColumnMappings.Add("Name", "Name") + tableMapping.ColumnMappings.Add("CategoryName", "CategoryName") + tableMapping.ColumnMappings.Add("SubCategoryName", "SubCategoryName") + tableMapping.ColumnMappings.Add("ProductNumber", "ProductNumber") + tableMapping.ColumnMappings.Add("Color", "Color") + tableMapping.ColumnMappings.Add("StandardCost", "StandardCost") + tableMapping.ColumnMappings.Add("ListPrice", "ListPrice") + tableMapping.ColumnMappings.Add("Size", "Size") + tableMapping.ColumnMappings.Add("Weight", "Weight") + tableMapping.ColumnMappings.Add("Class", "Class") + tableMapping.ColumnMappings.Add("Style", "Style") + tableMapping.ColumnMappings.Add("ProductID", "ProductID") + Me.m_adapter.TableMappings.Add(tableMapping) + End Sub + + Private Sub InitConnection() + Me.m_connection = New System.Data.SqlClient.SqlConnection + Me.m_connection.ConnectionString = Report_Control_Sample.Settings.Default.AdventureWorksConnectionString + End Sub + + Private Sub InitCommandCollection() + Me.m_commandCollection = New System.Data.SqlClient.SqlCommand(0) {} + Me.m_commandCollection(0) = New System.Data.SqlClient.SqlCommand + Me.m_commandCollection(0).Connection = Me.Connection + Me.m_commandCollection(0).CommandText = "dbo.GetProducts" + Me.m_commandCollection(0).CommandType = System.Data.CommandType.StoredProcedure + Me.m_commandCollection(0).Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, 10, 0, Nothing, System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + End Sub + + _ + Public Overloads Overridable Function Fill(ByVal dataTable As AdventureWorksDataSet.GetProductsDataTable) As System.Nullable(Of 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 AdventureWorksDataSet.GetProductsDataTable + Me.Adapter.SelectCommand = Me.CommandCollection(0) + Dim dataTable As AdventureWorksDataSet.GetProductsDataTable = New AdventureWorksDataSet.GetProductsDataTable + Me.Adapter.Fill(dataTable) + Return dataTable + End Function + + Public Overloads Overridable Function Update(ByVal dataTable As AdventureWorksDataSet.GetProductsDataTable) As Integer + Return Me.Adapter.Update(dataTable) + End Function + + Public Overloads Overridable Function Update(ByVal dataSet As AdventureWorksDataSet) As Integer + Return Me.Adapter.Update(dataSet, "GetProducts") + 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 + End Class +End Namespace diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.xsc b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.xsc new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.xsc @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.xsd b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.xsd new file mode 100644 index 0000000..95ed6c4 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.xsd @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + dbo.GetProducts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.xss b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.xss new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/AdventureWorksDataSet.xss @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Application.Designer.vb b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Application.Designer.vb new file mode 100644 index 0000000..2d34641 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Application.Designer.vb @@ -0,0 +1,37 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50215.312 +' +' 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 on the My Project node in the + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Class MyApplication + + _ + Public Sub New() + MyBase.New(Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.Report_Control_Sample.frmMain + End Sub + End Class +End Namespace diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Application.myapp b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Application.myapp new file mode 100644 index 0000000..c321448 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + frmMain + false + 0 + true + 0 + 0 + true + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/ApplicationEvents.vb b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/ApplicationEvents.vb new file mode 100644 index 0000000..3b9cdcd --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/ApplicationEvents.vb @@ -0,0 +1,15 @@ +Namespace My + + 'The following events are available for MyApplication + ' + 'Startup: Raised when the application starts, before the startup form is created. + 'Shutdown: Raised after all application forms are closed. This event is not raised if the application is terminating abnormally. + 'UnhandledException: Raised if the application encounters an unhandled exception. + 'StartupNextInstance: Raised when launching a single-instance application and the application is already active. + 'NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. + + Class MyApplication + + End Class + +End Namespace diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/AssemblyInfo.vb b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..21810a6 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/AssemblyInfo.vb @@ -0,0 +1,37 @@ +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/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/DataSources/AdventureWorksDataSet+GetProductsDataTable.datasource b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/DataSources/AdventureWorksDataSet+GetProductsDataTable.datasource new file mode 100644 index 0000000..02f45e4 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/DataSources/AdventureWorksDataSet+GetProductsDataTable.datasource @@ -0,0 +1,10 @@ + + + + Report_Control_Sample.AdventureWorksDataSet+GetProductsDataTable, AdventureWorksDataSet.Designer.vb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Resources.Designer.vb b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Resources.Designer.vb new file mode 100644 index 0000000..d7282f2 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Resources.Designer.vb @@ -0,0 +1,64 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50215.312 +' +' 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.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 (resourceMan Is Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Report_Control_Sample.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/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Resources.resx b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/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/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Settings.Designer.vb b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Settings.Designer.vb new file mode 100644 index 0000000..dc58e45 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Settings.Designer.vb @@ -0,0 +1,77 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50215.312 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + + + + _ +Partial Friend NotInheritable Class Settings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As Settings = New Settings + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Object, ByVal e As EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As Settings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public ReadOnly Property AdventureWorksConnectionString() As String + Get + Return CType(Me("AdventureWorksConnectionString"),String) + End Get + End Property +End Class + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Report_Control_Sample.Settings + Get + Return Global.Report_Control_Sample.Settings.Default + End Get + End Property + End Module +End Namespace diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Settings.settings b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Settings.settings new file mode 100644 index 0000000..5fde7a8 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/My Project/Settings.settings @@ -0,0 +1,16 @@ + + + + + + + + <?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=localhost;Initial Catalog=AdventureWorks;Integrated Security=True</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security=True + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/Report Control Sample.vbproj b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/Report Control Sample.vbproj new file mode 100644 index 0000000..569ebf7 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/Report Control Sample.vbproj @@ -0,0 +1,121 @@ + + + + Debug + AnyCPU + 8.0.50215 + 2.0 + {D5DAE4D1-27A6-4AE6-AF50-82B39B99BDCE} + WinExe + Report_Control_Sample.My.MyApplication + Report_Control_Sample + Report Control Sample + WindowsForms + + + true + full + true + true + bin\Debug\ + Report Control Sample.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Report Control Sample.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + + + + + True + True + AdventureWorksDataSet.xsd + + + Form + + + frmMain.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + frmMain.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + AdventureWorksDataSet.xsd + + + MSDataSetGenerator + AdventureWorksDataSet.Designer.vb + Designer + + + AdventureWorksDataSet.xsd + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/Report Control Sample.vbproj.user b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/Report Control Sample.vbproj.user new file mode 100644 index 0000000..33b0772 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/Report Control Sample.vbproj.user @@ -0,0 +1,6 @@ + + + 8.0.50215 + ShowAllFiles + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/Report1.rdlc b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/Report1.rdlc new file mode 100644 index 0000000..6827361 --- /dev/null +++ b/1590594770-1/Chapter09/Report Control Sample/Report Control Sample/Report1.rdlc @@ -0,0 +1,257 @@ + + + + + + SQL + Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security=True + + 4f3aeba9-480e-4350-bc56-97c7bbc2460b + + + true + true + + + + 3.875in + textbox2 + 0.25in + 1 + + 0.375in + true + 0.375in + Pricing Information + +
+ AdventureWorksDataSet_GetProducts + + + 1.875in + false + + + 1.875in + false + + + 1.125in + 3.75in +
+ + + 0.58333in + + + + + Name + 1 + + true + =Fields!Name.Value + + + + + + + StandardCost + + true + =Fields!StandardCost.Value + + + + + + +
+ + true + Name + + + + + + + textbox3 + 4 + + true + Standard Cost + + + + + + + + 0.5in + 1.75in +
+ + + 0.58333in + + + + + textbox7 + 3 + + true + + + + + + + + textbox9 + 2 + + true + + + + + + + +
+
+ + 7.5in + + true + + + + + + + + textbox10 + 16 + + true + + + + + + + + textbox11 + 15 + + true + + + + + + + + + + + =Fields!CategoryName.Value + + +
+ + + 0.25in + + + + + textbox12 + 8 + + true + + + + + + + + textbox13 + 7 + + true + + + + + + + + textbox14 + 6 + + true + + + + + + + +
+ + +
+ + + 0.25in + + + + + textbox15 + 14 + + true + + + + + + + + textbox16 + 13 + + true + + + + + + + + textbox17 + 12 + + true + + + + + + + +
+ + + =Fields!SubCategoryName.Value + + +
+ + + 0.25in + + + + + textbox18 + 5 + + true + + + + + + + + textbox19 + 4 + + true + + + + + + + + textbox20 + 3 + + true + + + + + + + +
+
+ + 3.875in +
+ + + 0.54167in + + + + + Name + 2 + + true + =Fields!Name.Value + + + + + + + Color + 1 + + true + =Fields!Color.Value + + + + + + + StandardCost + + true + =Fields!StandardCost.Value + + + + + + +
+ + true + Name + + + + + + + textbox2 + 19 + + true + Color + + + + + + + textbox3 + 18 + + true + Standard Cost + + + + + + + + 0.5in + 2.625in +
+ + + 0.54167in + + + + + textbox7 + 11 + + true + + + + + + + + textbox8 + 10 + + true + + + + + + + + textbox9 + 9 + + true + + + + + + + +
+ + + 7.5in + + 0.375in + true + 0.375in + Pricing Information + + + AdventureWorksDataSet_GetProducts + + + 1.875in + false + + + 1.875in + false + + + 1.125in + 3.75in +
+ + + 0.58333in + + + + + Name + 1 + + true + =Fields!Name.Value + + + + + + + StandardCost + + true + =Fields!StandardCost.Value + + + + + + +
+ + true + Name + + + + + + + textbox3 + 4 + + true + Standard Cost + + + + + + + + 0.5in + 1.75in +
+ + + 0.58333in + + + + + textbox7 + 3 + + true + + + + + + + + textbox9 + 2 + + true + + + + + + + +
+
+ + 7.5in + + true + + + + + + + + textbox8 + 4 + + true + + + + + + + + textbox9 + 3 + + true + + + + + + 0.58333in + + + + 0.5in + DataSet1 + 0.125in + 3.375in +
+ + + + + + + Name + 2 + + true + =Fields!Name.Value + + + + + + + ListPrice + 1 + + true + =Fields!ListPrice.Value + + + + + + + StandardCost + + true + =Fields!StandardCost.Value + + + + + 0.58333in + + +
+
+ + + + + + + textbox1 + 8 + + true + Name + + + + + + + textbox2 + 7 + + true + List Price + + + + + + + textbox3 + 6 + + true + Standard Cost + + + + + 0.58333in + + +
+ + + 1.125in + + + 1.125in + + + 1.125in + + + 1.75in + + + 2in + + e96cba6f-bfa9-4606-86f9-07513c12ee53 + 1in + + + + DataReaderDest + DataSource1 + + + + System.String + Name + + + System.String + CategoryName + + + System.String + SubCategoryName + + + System.String + ProductNumber + + + System.String + Color + + + System.Decimal + StandardCost + + + System.Decimal + ListPrice + + + System.String + Size + + + System.Decimal + Weight + + + System.String + Class + + + System.String + Style + + + System.Int32 + ProductID + + + + + 6.5in + 11in + en-US + 1in + \ No newline at end of file diff --git a/1590594770-1/Chapter09/SSIS Project/SSIS Project/Report1.rdl.data b/1590594770-1/Chapter09/SSIS Project/SSIS Project/Report1.rdl.data new file mode 100644 index 0000000..2719ad9 Binary files /dev/null and b/1590594770-1/Chapter09/SSIS Project/SSIS Project/Report1.rdl.data differ diff --git a/1590594770-1/Chapter09/SSIS Project/SSIS Project/SSIS Project.rptproj b/1590594770-1/Chapter09/SSIS Project/SSIS Project/SSIS Project.rptproj new file mode 100644 index 0000000..6b6b2a8 --- /dev/null +++ b/1590594770-1/Chapter09/SSIS Project/SSIS Project/SSIS Project.rptproj @@ -0,0 +1,39 @@ + + + $base64$PFNvdXJjZUNvbnRyb2xJbmZvIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOmR3ZD0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9EYXRhV2FyZWhvdXNlL0Rlc2lnbmVyLzEuMCI+DQogIDxFbmFibGVkPmZhbHNlPC9FbmFibGVkPg0KICA8UHJvamVjdE5hbWU+PC9Qcm9qZWN0TmFtZT4NCiAgPEF1eFBhdGg+PC9BdXhQYXRoPg0KICA8TG9jYWxQYXRoPjwvTG9jYWxQYXRoPg0KICA8UHJvdmlkZXI+PC9Qcm92aWRlcj4NCjwvU291cmNlQ29udHJvbEluZm8+ + + + DataSource1.rds + DataSource1.rds + + + + + Report1.rdl + Report1.rdl + + + + + Debug + Win32 + + SSIS Project + + + + DebugLocal + Win32 + + SSIS Project + + + + Production + Win32 + + SSIS Project + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/SSIS Project/SSIS Project/SSIS Project.rptproj.user b/1590594770-1/Chapter09/SSIS Project/SSIS Project/SSIS Project.rptproj.user new file mode 100644 index 0000000..092253a Binary files /dev/null and b/1590594770-1/Chapter09/SSIS Project/SSIS Project/SSIS Project.rptproj.user differ diff --git a/1590594770-1/Chapter09/SSIS Project/readme.txt b/1590594770-1/Chapter09/SSIS Project/readme.txt new file mode 100644 index 0000000..2da8289 --- /dev/null +++ b/1590594770-1/Chapter09/SSIS Project/readme.txt @@ -0,0 +1 @@ +Please see the readme under Integration Services Project 1 \ No newline at end of file diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI.sln b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI.sln new file mode 100644 index 0000000..5db71a0 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SSRS 2005 WMI", "SSRS 2005 WMI\SSRS 2005 WMI.vbproj", "{C815CF92-D56D-4068-AA6B-640912D724CD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C815CF92-D56D-4068-AA6B-640912D724CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C815CF92-D56D-4068-AA6B-640912D724CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C815CF92-D56D-4068-AA6B-640912D724CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C815CF92-D56D-4068-AA6B-640912D724CD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI.suo b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI.suo new file mode 100644 index 0000000..2fe8fc7 Binary files /dev/null and b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI.suo differ diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Application.Designer.vb b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Application.Designer.vb new file mode 100644 index 0000000..6f7ca33 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Application.Designer.vb @@ -0,0 +1,37 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50215.312 +' +' 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 on the My Project node in the + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Class MyApplication + + _ + Public Sub New() + MyBase.New(Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.SSRS_2005_WMI.frmMain + End Sub + End Class +End Namespace diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Application.myapp b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Application.myapp new file mode 100644 index 0000000..c321448 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + frmMain + false + 0 + true + 0 + 0 + true + \ No newline at end of file diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/ApplicationEvents.vb b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/ApplicationEvents.vb new file mode 100644 index 0000000..3b9cdcd --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/ApplicationEvents.vb @@ -0,0 +1,15 @@ +Namespace My + + 'The following events are available for MyApplication + ' + 'Startup: Raised when the application starts, before the startup form is created. + 'Shutdown: Raised after all application forms are closed. This event is not raised if the application is terminating abnormally. + 'UnhandledException: Raised if the application encounters an unhandled exception. + 'StartupNextInstance: Raised when launching a single-instance application and the application is already active. + 'NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. + + Class MyApplication + + End Class + +End Namespace diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/AssemblyInfo.vb b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a53d819 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/AssemblyInfo.vb @@ -0,0 +1,37 @@ +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/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Resources.Designer.vb b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a9e3095 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Resources.Designer.vb @@ -0,0 +1,64 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50215.312 +' +' 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.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 (resourceMan Is Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("SSRS_2005_WMI.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/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Resources.resx b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/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/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Settings.Designer.vb b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Settings.Designer.vb new file mode 100644 index 0000000..df7ac8d --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Settings.Designer.vb @@ -0,0 +1,66 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50215.312 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + + + + _ +Partial Friend NotInheritable Class Settings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As Settings = New Settings + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Object, ByVal e As EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As Settings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If +#End If + Return defaultInstance + End Get + End Property +End Class + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.SSRS_2005_WMI.Settings + Get + Return Global.SSRS_2005_WMI.Settings.Default + End Get + End Property + End Module +End Namespace diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Settings.settings b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/SSRS 2005 WMI.vbproj b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/SSRS 2005 WMI.vbproj new file mode 100644 index 0000000..66a555b --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/SSRS 2005 WMI.vbproj @@ -0,0 +1,96 @@ + + + + Debug + AnyCPU + 8.0.50215 + 2.0 + {C815CF92-D56D-4068-AA6B-640912D724CD} + WinExe + SSRS_2005_WMI.My.MyApplication + SSRS_2005_WMI + SSRS 2005 WMI + WindowsForms + + + true + full + true + true + bin\Debug\ + SSRS 2005 WMI.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SSRS 2005 WMI.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + Form + + + frmMain.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + frmMain.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/SSRS 2005 WMI.vbproj.user b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/SSRS 2005 WMI.vbproj.user new file mode 100644 index 0000000..6481ba3 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/SSRS 2005 WMI.vbproj.user @@ -0,0 +1,5 @@ + + + 8.0.50215 + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.exe b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.exe new file mode 100644 index 0000000..3552866 Binary files /dev/null and b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.exe differ diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.pdb b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.pdb new file mode 100644 index 0000000..d892bb4 Binary files /dev/null and b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.pdb differ diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.vshost.exe b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.vshost.exe new file mode 100644 index 0000000..72b0f71 Binary files /dev/null and b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.vshost.exe differ diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.xml b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.xml new file mode 100644 index 0000000..5242a4c --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/bin/Debug/SSRS 2005 WMI.xml @@ -0,0 +1,24 @@ + + + + +SSRS2005WMI + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/frmMain.Designer.vb b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/frmMain.Designer.vb new file mode 100644 index 0000000..8289488 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/frmMain.Designer.vb @@ -0,0 +1,106 @@ + _ +Partial Public Class frmMain + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overloads 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.btnExecute = New System.Windows.Forms.Button + Me.listResults = New System.Windows.Forms.ListBox + Me.Label1 = New System.Windows.Forms.Label + Me.listMethods = New System.Windows.Forms.ListBox + Me.Label2 = New System.Windows.Forms.Label + Me.btnExecuteMethod = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'btnExecute + ' + Me.btnExecute.Location = New System.Drawing.Point(18, 39) + Me.btnExecute.Name = "btnExecute" + Me.btnExecute.Size = New System.Drawing.Size(99, 35) + Me.btnExecute.TabIndex = 0 + Me.btnExecute.Text = "Get props + methods" + ' + 'listResults + ' + Me.listResults.FormattingEnabled = True + Me.listResults.Location = New System.Drawing.Point(18, 113) + Me.listResults.Name = "listResults" + Me.listResults.Size = New System.Drawing.Size(261, 394) + Me.listResults.TabIndex = 2 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(18, 93) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(112, 13) + Me.Label1.TabIndex = 3 + Me.Label1.Text = "RS Instance Properties" + ' + 'listMethods + ' + Me.listMethods.FormattingEnabled = True + Me.listMethods.Location = New System.Drawing.Point(285, 113) + Me.listMethods.Name = "listMethods" + Me.listMethods.Size = New System.Drawing.Size(261, 394) + Me.listMethods.Sorted = True + Me.listMethods.TabIndex = 4 + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(284, 97) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(106, 13) + Me.Label2.TabIndex = 5 + Me.Label2.Text = "RS Instance Methods" + ' + 'btnExecuteMethod + ' + Me.btnExecuteMethod.Location = New System.Drawing.Point(142, 39) + Me.btnExecuteMethod.Name = "btnExecuteMethod" + Me.btnExecuteMethod.Size = New System.Drawing.Size(99, 35) + Me.btnExecuteMethod.TabIndex = 6 + Me.btnExecuteMethod.Text = "Execute Method" + ' + 'frmMain + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(635, 546) + Me.Controls.Add(Me.btnExecuteMethod) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.listMethods) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.listResults) + Me.Controls.Add(Me.btnExecute) + Me.Name = "frmMain" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "SSRS 2005 WMI Sample" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents btnExecute As System.Windows.Forms.Button + Friend WithEvents listResults As System.Windows.Forms.ListBox + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents listMethods As System.Windows.Forms.ListBox + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents btnExecuteMethod As System.Windows.Forms.Button + +End Class diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/frmMain.resx b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/frmMain.resx new file mode 100644 index 0000000..02bbfa2 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/frmMain.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/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/frmMain.vb b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/frmMain.vb new file mode 100644 index 0000000..d67a201 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/frmMain.vb @@ -0,0 +1,103 @@ +Imports System.Management +Public Class frmMain + Dim WmiNamespace As String = "\\" & My.Computer.Name & "\root\Microsoft\SqlServer\ReportServer\v9" + Dim WmiRSClass As String = "\\" & My.Computer.Name & "\ROOT\Microsoft\SqlServer\ReportServer\v9\Admin:MSReportServer_ConfigurationSetting" + Dim serverClass As ManagementClass + Dim scope As ManagementScope + Private Function ConnecttoWMI() As Boolean + scope = New ManagementScope(WmiNamespace) + + 'Connect to the Reporting Services namespace. + scope.Connect() + 'Create the server class. + serverClass = New ManagementClass(WmiRSClass) + 'Connect to the management object. + serverClass.Get() + + If (serverClass Is Nothing) Then + ConnecttoWMI = False + Else + ConnecttoWMI = True + End If + End Function + + Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecute.Click + Dim name As String = "" + Dim val As Object + Dim strItemtoAdd As String = "" + + listResults.Items.Clear() + listMethods.Items.Clear() + + If (ConnecttoWMI() = False) Then + MsgBox("Are you sure RS is installed on this machine?") + Exit Sub + Else + 'Loop through the instances of the server class. + Dim instances As ManagementObjectCollection = serverClass.GetInstances() + Dim instance As ManagementObject + For Each instance In instances + + + Dim instProps As PropertyDataCollection = instance.Properties + Dim prop As PropertyData + For Each prop In instProps + strItemtoAdd = "" + name = prop.Name + val = prop.Value + + strItemtoAdd = name & ": " + If Not (val Is Nothing) Then + strItemtoAdd += val.ToString() + Else + strItemtoAdd += "" + End If + listResults.Items.Add(strItemtoAdd) + Next + Next + + Dim methods As MethodDataCollection = serverClass.Methods() + Dim method As MethodData + For Each method In methods + strItemtoAdd = method.Name + listMethods.Items.Add(strItemtoAdd) + Next + + End If + End Sub + + Private Sub btnExecuteMethod_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecuteMethod.Click + 'Example executing a method + If (ConnecttoWMI() = False) Then + MsgBox("Are you sure RS is installed on this machine?") + Exit Sub + Else + 'Backup the encryption key for each isntance using the + 'BackupEncryptionKeyMethod + Dim instances As ManagementObjectCollection = serverClass.GetInstances() + Dim instance As ManagementObject + + For Each instance In instances + + Dim inParams As ManagementBaseObject = instance.GetMethodParameters("BackupEncryptionKey") + + inParams("Password") = "Tom15892!!" + + Dim outParams As ManagementBaseObject = instance.InvokeMethod("BackupEncryptionKey", inParams, Nothing) + + Dim strKeyFile As String = "" + + Dim arrKeyfile As System.Array + + arrKeyfile = outParams("KeyFile") + Dim i As Integer = 0 + For i = 0 To arrKeyfile.Length - 1 + strKeyFile += Hex(arrKeyfile(i)) + Next + + + MsgBox("HResult: " & outParams("HRESULT") & " Value: " & strKeyFile) + Next + End If + End Sub +End Class diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.exe b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.exe new file mode 100644 index 0000000..3552866 Binary files /dev/null and b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.exe differ diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.pdb b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.pdb new file mode 100644 index 0000000..d892bb4 Binary files /dev/null and b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.pdb differ diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.vbproj.GenerateResource.Cache b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..4ea07bc Binary files /dev/null and b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.vbproj.GenerateResource.Cache differ diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.xml b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.xml new file mode 100644 index 0000000..5242a4c --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS 2005 WMI.xml @@ -0,0 +1,24 @@ + + + + +SSRS2005WMI + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS_2005_WMI.Resources.resources b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS_2005_WMI.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS_2005_WMI.Resources.resources differ diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS_2005_WMI.frmMain.resources b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS_2005_WMI.frmMain.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/SSRS_2005_WMI.frmMain.resources differ diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..43a3250 Binary files /dev/null and b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/SSRS 2005 WMI.vbproj.FileList.txt b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/SSRS 2005 WMI.vbproj.FileList.txt new file mode 100644 index 0000000..c6e46cd --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/SSRS 2005 WMI/obj/SSRS 2005 WMI.vbproj.FileList.txt @@ -0,0 +1,10 @@ +bin\Debug\SSRS 2005 WMI.exe +bin\Debug\SSRS 2005 WMI.pdb +bin\Debug\SSRS 2005 WMI.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\SSRS_2005_WMI.frmMain.resources +obj\Debug\SSRS_2005_WMI.Resources.resources +obj\Debug\SSRS 2005 WMI.vbproj.GenerateResource.Cache +obj\Debug\SSRS 2005 WMI.exe +obj\Debug\SSRS 2005 WMI.xml +obj\Debug\SSRS 2005 WMI.pdb diff --git a/1590594770-1/Chapter09/SSRS 2005 WMI/readme.txt b/1590594770-1/Chapter09/SSRS 2005 WMI/readme.txt new file mode 100644 index 0000000..b3532c1 --- /dev/null +++ b/1590594770-1/Chapter09/SSRS 2005 WMI/readme.txt @@ -0,0 +1,11 @@ +The Reporting Services WMI sample shows you how to use WMI with Reporting Services. + +To run the application, perform the following steps: + +1) Double click the SSRS 2005 WMI.sln file to load the application into Visual Studio 2005. + +2) Hit ctrl-F5 to start the application without debugging. + +3) Click the Get Props + methods button to see available properties and methods. + +4) Click the Execute Method button to see an example of executing a method through WMI against Reporting Services. diff --git a/1590594770-1/Chapter09/XML Datasource Sample/CreateSPROC.sql b/1590594770-1/Chapter09/XML Datasource Sample/CreateSPROC.sql new file mode 100644 index 0000000..5d31f4f --- /dev/null +++ b/1590594770-1/Chapter09/XML Datasource Sample/CreateSPROC.sql @@ -0,0 +1,35 @@ +USE [AdventureWorks] +GO +/****** Object: StoredProcedure [dbo].[GetProducts] Script Date: 06/12/2005 15:48:47 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ============================================= +-- Author: +-- Create date: +-- Description: +-- ============================================= +CREATE PROCEDURE [dbo].[GetProducts] + -- Add the parameters for the function here +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + -- Insert statements for procedure here + SELECT Production.Product.Name, Production.ProductCategory.Name AS CategoryName, Production.ProductSubcategory.Name AS SubCategoryName, + Production.Product.ProductNumber, Production.Product.Color, Production.Product.StandardCost, Production.Product.ListPrice, Production.Product.Size, + Production.Product.Weight, Production.Product.Class, Production.Product.Style, Production.Product.ProductID +FROM Production.Product INNER JOIN + Production.ProductSubcategory ON Production.Product.ProductSubcategoryID = Production.ProductSubcategory.ProductSubcategoryID INNER JOIN + Production.ProductCategory ON Production.ProductSubcategory.ProductCategoryID = Production.ProductCategory.ProductCategoryID ORDER BY CategoryName, SubCategoryName, Production.Product.ListPrice +END + + +GO +SET ANSI_NULLS OFF +GO +SET QUOTED_IDENTIFIER OFF \ No newline at end of file diff --git a/1590594770-1/Chapter09/XML Datasource Sample/Readme.txt b/1590594770-1/Chapter09/XML Datasource Sample/Readme.txt new file mode 100644 index 0000000..4039296 --- /dev/null +++ b/1590594770-1/Chapter09/XML Datasource Sample/Readme.txt @@ -0,0 +1,29 @@ +This sample shows you how to use the XML Datasource with SSRS. You need to perform the following steps before running the application: + + +1) Run the CreateSPROC.sql script to create a stored procedure in the AdventureWorks database. (You may not have to do this if you already created the SPROC as part of the Integration Services and Reporting Services samples) + +2) Launch Visual Studio 2005 and from the File menu select New and then Website. + +3) Select ASP.NET Web Service as the project type. In the location box, make sure HTTP is selected and for the value type in http://localhost/website2. Make sure Visual Basic is selected as the language and click OK. + +4) After your new project launches, in the Solution Explorer, right-click the App_Code folder and select Add Existing Item from the menu. + +5) Browse to where you installed the samples and under the website2 folder, under the App_Code folder, select Service.vb and click Add. If asked to replace the existing file, click Yes. + +6) Click Yes to reload the file into the editor. On the Build menu, click Build Web Site. The website should not be built and deployed to the server. + +7) You need to go into the IIS Administration program and for the website, turn of anonymous access and turn on only Windows Integrated authentication. To do this, open the IIS Administration Program and find Website2. Right-click Website2 and select Properties. + +8) On the Directory Security tab, under Authentication and access control, click the Edit button. + +9) Uncheck Enable anonymous access and make sure Integrated windows authentication is checked. Click OK. Click OK. + +10) You need to make sure the account ASPNET runs under has permissions to the AdventureWorks database. You can set these permissions through Management Studio under the Security folder then under Logins and finally by selecting your ASPNET account and select the AdventureWorks database and assigning permissions. Also, please note that you will also have to GRANT execute permissions for the ASPNET account on the GetProducts stored procedure. The following T-SQL code shows you how to do this: + +use adventureworks +GRANT EXECUTE ON GetProducts TO [DOMAIN\USER] + +11) Test the webservice to make sure it works by going to http://localhost/website2/service.asmx + +12) Open the project in the Report Project1 folder. This project should use the web service to return back data to the report. You may have to refresh the fields in the dataset if you run into errors between naming in the dataset and naming in the report. diff --git a/1590594770-1/Chapter09/XML Datasource Sample/Report Project1.sln b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1.sln new file mode 100644 index 0000000..13e8c73 --- /dev/null +++ b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F14B399A-7131-4C87-9E4B-1186C45EF12D}") = "Report Project1", "Report Project1\Report Project1.rptproj", "{FB7E5AA5-8BA3-4DCC-A2E7-41DD29286911}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Default = Debug|Default + DebugLocal|Default = DebugLocal|Default + Production|Default = Production|Default + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FB7E5AA5-8BA3-4DCC-A2E7-41DD29286911}.Debug|Default.ActiveCfg = Debug + {FB7E5AA5-8BA3-4DCC-A2E7-41DD29286911}.Debug|Default.Build.0 = DebugLocal + {FB7E5AA5-8BA3-4DCC-A2E7-41DD29286911}.Debug|Default.Deploy.0 = DebugLocal + {FB7E5AA5-8BA3-4DCC-A2E7-41DD29286911}.DebugLocal|Default.ActiveCfg = DebugLocal + {FB7E5AA5-8BA3-4DCC-A2E7-41DD29286911}.DebugLocal|Default.Build.0 = DebugLocal + {FB7E5AA5-8BA3-4DCC-A2E7-41DD29286911}.Production|Default.ActiveCfg = Production + {FB7E5AA5-8BA3-4DCC-A2E7-41DD29286911}.Production|Default.Build.0 = Production + {FB7E5AA5-8BA3-4DCC-A2E7-41DD29286911}.Production|Default.Deploy.0 = Production + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter09/XML Datasource Sample/Report Project1.suo b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1.suo new file mode 100644 index 0000000..a9bfbe3 Binary files /dev/null and b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1.suo differ diff --git a/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/DataSource3.rds b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/DataSource3.rds new file mode 100644 index 0000000..c4c21a7 --- /dev/null +++ b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/DataSource3.rds @@ -0,0 +1,10 @@ + + + DataSource3 + 14243303-c682-497f-b057-555653ffaab0 + + XML + http://localhost/website2/service.asmx + true + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/Report Project1.rptproj b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/Report Project1.rptproj new file mode 100644 index 0000000..daf6183 --- /dev/null +++ b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/Report Project1.rptproj @@ -0,0 +1,40 @@ + + + $base64$PFNvdXJjZUNvbnRyb2xJbmZvIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOmR3ZD0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9EYXRhV2FyZWhvdXNlL0Rlc2lnbmVyLzEuMCI+DQogIDxFbmFibGVkPmZhbHNlPC9FbmFibGVkPg0KICA8UHJvamVjdE5hbWU+PC9Qcm9qZWN0TmFtZT4NCiAgPEF1eFBhdGg+PC9BdXhQYXRoPg0KICA8TG9jYWxQYXRoPjwvTG9jYWxQYXRoPg0KICA8UHJvdmlkZXI+PC9Qcm92aWRlcj4NCjwvU291cmNlQ29udHJvbEluZm8+ + + + DataSource3.rds + DataSource3.rds + + + + + XML Products.rdl + XML Products.rdl + + + + + Debug + Win32 + + http://localhost/reportserver + Report Project1 + + + + DebugLocal + Win32 + + Report Project1 + + + + Production + Win32 + + Report Project1 + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/Report Project1.rptproj.user b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/Report Project1.rptproj.user new file mode 100644 index 0000000..092253a Binary files /dev/null and b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/Report Project1.rptproj.user differ diff --git a/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/Report1.rdl b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/Report1.rdl new file mode 100644 index 0000000..d558b4b --- /dev/null +++ b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/Report1.rdl @@ -0,0 +1,32 @@ + + + 11in + d5f3e6e6-878b-4eda-91fd-5a833bd9fe7d + true + 8.5in + + + bc9cc384-ba1c-4851-bcaf-b3040366cd1c + DataSource2 + + + true + + 2in + + true + + + + + + + + textbox8 + 10 + + true + + + + + + + + textbox9 + 9 + + true + + + + + + 0.25in + + + + + + In + + =Parameters!Category.Value + + =Fields!Category_Name.Value + + + DataSet1 + 0.125in + + +
+ + + + + + + textbox10 + 8 + + true + + + + + + + + textbox11 + 7 + + true + + + + + + + + textbox12 + 6 + + true + + + + + + 0.25in + + +
+
+ + + + + 2 + + + Category_Name + 18 + + true + =Fields!Category_Name.Value + + + + + + + textbox6 + 17 + + true + + + + + + 0.375in + + + true +
+ + true + + =Fields!Category_Name.Value + + +
+ +
+ + + + + + + textbox16 + 5 + + true + + + + + + + + textbox17 + 4 + + true + + + + + + + + textbox18 + 3 + + true + + + + + + 0.25in + + +
+
+ + + + + 2 + + + SubCategory_Name + 16 + + true + =Fields!SubCategory_Name.Value + + + + + + + textbox15 + 15 + + true + + + + + + 0.375in + + + + + + + textbox2 + 14 + + true + Product ID + + + + + + + textbox19 + 13 + + true + Product Name + + + + + + + textbox13 + 12 + + true + List Price + + + + + 0.25in + + + true +
+ + true + + =Fields!SubCategory_Name.Value + + +
+
+
+ + + + + + + Product_ID + 2 + + true + =Fields!ID.Value + + + + + + + Product_Name + 1 + + true + =Fields!Name.Value + + + + + + + Product_Price + + true + =Fields!Price.Value + + + + + 0.25in + + +
+
+ + + + + + + textbox20 + 21 + + true + + + + + + + + textbox1 + 20 + + true + + + + + + + + textbox4 + 19 + + true + + + + + + 0.25in + + +
+ + + 2.16667in + + + 2.16667in + + + 2.16667in + + + 2.25in + + + 3in + + 8ed76986-ab30-4c68-93d2-ee6081c7edea + 1in + + + + <Query><SoapAction>http://AdventureWorks.org/GetProducts</SoapAction></Query> + DataSource3 + + + + System.String + ID + + + System.String + Name + + + System.String + Number + + + System.String + Cost + + + System.String + Price + + + System.String + SubCategory.Name + + + System.String + Category.Name + + + System.String + xmlns + + + + + + <Query><SoapAction>http://AdventureWorks.org/GetProducts</SoapAction> +<ElementPath IgnoreNamespaces="true">GetProductsResponse/GetProductsResult/Category</ElementPath></Query> + DataSource3 + + + + System.String + Name + + + System.String + xmlns + + + + + 6.50001in + 11in + en-US + 1in +
\ No newline at end of file diff --git a/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/XML Products.rdl.data b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/XML Products.rdl.data new file mode 100644 index 0000000..fa975a6 Binary files /dev/null and b/1590594770-1/Chapter09/XML Datasource Sample/Report Project1/XML Products.rdl.data differ diff --git a/1590594770-1/Chapter09/website2/App_Code/Service.vb b/1590594770-1/Chapter09/website2/App_Code/Service.vb new file mode 100644 index 0000000..cb37706 --- /dev/null +++ b/1590594770-1/Chapter09/website2/App_Code/Service.vb @@ -0,0 +1,109 @@ +Imports System.Web +Imports System.Web.Services +Imports System.Web.Services.Protocols +Imports System.Data.SqlClient + + _ + _ +Public Class Service + Inherits System.Web.Services.WebService + Dim DBCon As New SqlConnection("Server=localhost;Database=AdventureWorks; integrated security=SSPI;") + + + Public Class Category + Public Name As String + Public SubCategories As SubCategory() + End Class + + Public Class SubCategory + Public Name As String + Public Products As Product() + End Class + Public Class Product + Public ID As Integer + Public Name As String + Public Number As String + Public Color As String + Public Cost As Double + Public Price As Double + Public Size As String + Public Weight As String + + End Class + Public Sub Service() + + End Sub + + _ + Public Function GetProducts() As Category() + Dim DBCmd As New SqlCommand() + Dim SQLRead As SqlDataReader + Dim Retval As Category() + Dim Cat As Category + Dim Prod As Product + Dim SubCat As SubCategory + Dim CatArray As New ArrayList + Dim SubCatArray As New ArrayList + Dim ProdArray As New ArrayList + + DBCon.Open() + DBCmd.Connection = DBCon + DBCmd.CommandText = "exec GetProducts" + SQLRead = DBCmd.ExecuteReader() + + Cat = New Category + SubCat = New SubCategory + + + + While SQLRead.Read + + If SQLRead("CategoryName").ToString <> Cat.Name Then + If SubCatArray.Count <> 0 Then + Cat.SubCategories = SubCatArray.ToArray(SubCat.GetType) + SubCatArray.Clear() + End If + Cat = New Category + Cat.Name = SQLRead("CategoryName").ToString + CatArray.Add(Cat) + End If + If SQLRead("SubCategoryName").ToString <> SubCat.Name Then + If ProdArray.Count <> 0 Then + SubCat.Products = ProdArray.ToArray(Prod.GetType) + ProdArray.Clear() + End If + SubCat = New SubCategory + SubCat.Name = SQLRead("SubCategoryName").ToString + SubCatArray.Add(SubCat) + 'Cat.SubCategories.Add(SubCat) + End If + + Prod = New Product + 'SubCat.Products.Products.Add(Prod) + ProdArray.Add(Prod) + Prod.ID = CInt(SQLRead("ProductID").ToString) + Prod.Name = SQLRead("Name").ToString + Prod.Color = IIf(SQLRead("Color") Is DBNull.Value, "", SQLRead("Color")).ToString + Prod.Cost = CDbl(SQLRead("StandardCost").ToString) + Prod.Number = SQLRead("ProductNumber").ToString + Prod.Price = CDbl(SQLRead("ListPrice").ToString) + Prod.Size = IIf(SQLRead("Size") Is DBNull.Value, "", SQLRead("Size")).ToString + Prod.Weight = IIf(SQLRead("Weight") Is DBNull.Value, "", SQLRead("Weight")).ToString + + + + End While + If ProdArray.Count <> 0 Then + SubCat.Products = ProdArray.ToArray(Prod.GetType) + ProdArray.Clear() + End If + If SubCatArray.Count <> 0 Then + Cat.SubCategories = SubCatArray.ToArray(SubCat.GetType) + SubCatArray.Clear() + End If + DBCon.Close() + Return CatArray.ToArray(Cat.GetType) + + End Function + +End Class \ No newline at end of file diff --git a/1590594770-1/Chapter09/website2/Service.asmx b/1590594770-1/Chapter09/website2/Service.asmx new file mode 100644 index 0000000..cbd4ad2 --- /dev/null +++ b/1590594770-1/Chapter09/website2/Service.asmx @@ -0,0 +1 @@ +<%@ WebService Language="vb" CodeBehind="~/App_Code/Service.vb" Class="Service" %> diff --git a/1590594770-1/Chapter09/website2/Web.Config b/1590594770-1/Chapter09/website2/Web.Config new file mode 100644 index 0000000..beea0e3 --- /dev/null +++ b/1590594770-1/Chapter09/website2/Web.Config @@ -0,0 +1,40 @@ + + + + + + + + + + + + + diff --git a/1590594770-1/Chapter10/ASSL.txt b/1590594770-1/Chapter10/ASSL.txt new file mode 100644 index 0000000..14f1cbb --- /dev/null +++ b/1590594770-1/Chapter10/ASSL.txt @@ -0,0 +1,3 @@ + + + + + + + + + + + +'; + +CREATE XML SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/ProjectResponseSchema] +AS N' + + + + + + + + + + +'; + +CREATE MESSAGE TYPE [http://schemas.apress.com/prosqlserver/ProjectRequestMessage] +VALIDATION = VALID_XML WITH SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/ProjectRequestSchema]; + +CREATE MESSAGE TYPE [http://schemas.apress.com/prosqlserver/ProjectResponseMessage] +VALIDATION = VALID_XML WITH SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/ProjectResponseSchema]; + +CREATE CONTRACT [http://schemas.apress.com/prosqlserver/ProjectServiceContract] +( + [http://schemas.apress.com/prosqlserver/ProjectRequestMessage] SENT BY INITIATOR, + [http://schemas.apress.com/prosqlserver/ProjectResponseMessage] SENT BY TARGET +); +GO + +CREATE ROUTE ProjectDetailsRoute +WITH + SERVICE_NAME = 'http://schemas.apress.com/prosqlserver/ProjectDetailsService', + ADDRESS = 'TCP://peiriantprawf:4022'; +GO + +CREATE XML SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/EmployeeRequestSchema] +AS N' + + + + + + + + + +'; + +CREATE XML SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/EmployeeResponseSchema] +AS N' + + + + + + + + + +'; + +CREATE MESSAGE TYPE [http://schemas.apress.com/prosqlserver/EmployeeRequestMessage] +VALIDATION = VALID_XML WITH SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/EmployeeRequestSchema]; + +CREATE MESSAGE TYPE [http://schemas.apress.com/prosqlserver/EmployeeResponseMessage] +VALIDATION = VALID_XML WITH SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/EmployeeResponseSchema]; + +CREATE CONTRACT [http://schemas.apress.com/prosqlserver/EmployeeServiceContract] +( + [http://schemas.apress.com/prosqlserver/EmployeeRequestMessage] SENT BY INITIATOR, + [http://schemas.apress.com/prosqlserver/EmployeeResponseMessage] SENT BY TARGET +); +GO + +CREATE PROCEDURE usp_GetHoursVacation +AS +DECLARE @msgBody XML( + [http://schemas.apress.com/prosqlserver/EmployeeRequestSchema]), + @response XML( + [http://schemas.apress.com/prosqlserver/EmployeeResponseSchema]), + @convID uniqueidentifier, + @empID int, + @hours int, + @hoursTaken int, + @totalHours int, + @msgType nvarchar(256), + @respText nvarchar(1000); + +DECLARE @msgTable TABLE +( + message_body varbinary(max), + conversation_handle uniqueidentifier, + message_type_name nvarchar(256) +); +BEGIN + WAITFOR + ( + RECEIVE TOP (1) message_body, conversation_handle, message_type_name + FROM EmployeeDetailsQueue INTO @msgTable + ), TIMEOUT 2000; + + SET @msgBody = (SELECT TOP (1) CAST(message_body AS XML) FROM @msgTable); + SET @convID = (SELECT TOP (1) conversation_handle FROM @msgTable); + SET @msgType = (SELECT TOP (1) message_type_name FROM @msgTable); + + IF @msgType = 'http://schemas.apress.com/prosqlserver/EmployeeRequestMessage' + BEGIN + SET @empID = @msgBody.value('data(//id)[1]', 'int'); + SET @hours = @msgBody.value('data(//id)[1]', 'int'); + SET @hoursTaken = (SELECT VacationHours FROM HumanResources.Employee + WHERE EmployeeID = @empID); + SET @totalHours = @hoursTaken + @hours; + SET @respText = N' + + ' + CAST(@empID AS nvarchar) + ' + ' + CAST(@totalHours AS nvarchar) + ' +'; + + SET @response = CAST(@respText AS XML); + SEND ON CONVERSATION @convID + MESSAGE TYPE [http://schemas.apress.com/prosqlserver/EmployeeResponseMessage] + (@response); + + END CONVERSATION @convID; + END; +END; +GO + +CREATE QUEUE EmployeeDetailsQueue +WITH + STATUS = ON, + RETENTION = OFF, + ACTIVATION + ( + STATUS = ON, + PROCEDURE_NAME = usp_GetHoursVacation, + MAX_QUEUE_READERS = 5, + EXECUTE AS SELF + ); + +CREATE SERVICE [http://schemas.apress.com/prosqlserver/EmployeeDetailsService] +ON QUEUE EmployeeDetailsQueue +( + [http://schemas.apress.com/prosqlserver/EmployeeServiceContract] +); +GO + +CREATE XML SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/VacationRequestSchema] +AS N' + + + + + + + + + + + +'; + +CREATE MESSAGE TYPE [http://schemas.apress.com/prosqlserver/VacationRequest] +VALIDATION = VALID_XML WITH SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/VacationRequestSchema] + +CREATE CONTRACT [http://schemas.apress.com/prosqlserver/VacationRequestContract] +( + [http://schemas.apress.com/prosqlserver/VacationRequest] SENT BY INITIATOR +); +GO + +CREATE PROCEDURE usp_ProcessVacationRequest +AS +DECLARE @msgBody XML( + [http://schemas.apress.com/prosqlserver/VacationRequestSchema]), + @empRequest XML( + [http://schemas.apress.com/prosqlserver/EmployeeRequestSchema]), + @projRequest XML( + [http://schemas.apress.com/prosqlserver/ProjectRequestSchema]), + @empRequestBody nvarchar(1000), + @projRequestBody nvarchar(1000), + @msgType nvarchar(256), + @convID uniqueidentifier, + @empConvID uniqueidentifier, + @projConvID uniqueidentifier, + @email varchar(50), + @employeeID int, + @hours int, + @startTime DateTime; + +DECLARE @msgTable TABLE +( + message_body varbinary(max), + conversation_handle uniqueidentifier, + message_type_name nvarchar(256) +); + +BEGIN + WAITFOR + ( + RECEIVE TOP (1) message_body, conversation_handle, message_type_name + FROM VacationRequestQueue INTO @msgTable + ), TIMEOUT 2000; + + SET @msgBody = (SELECT TOP (1) CAST(message_body AS XML) FROM @msgTable); + SET @convID = (SELECT TOP (1) conversation_handle FROM @msgTable); + SET @msgType = (SELECT TOP (1) message_type_name FROM @msgTable); + END CONVERSATION @convID; + + IF @msgType = 'http://schemas.apress.com/prosqlserver/VacationRequest' + BEGIN + SET @email = @msgBody.value('data(//email)[1]', 'varchar(50)'); + SET @hours = @msgBody.value('data(//hours)[1]', 'int'); + SET @startTime = @msgBody.value('data(//startTime)[1]', 'datetime'); + SET @employeeID = @msgBody.value('data(//employeeId)[1]', 'int'); + + SET @empRequestBody = N' + ' + CAST(@employeeID AS varchar) + ' + ' + CAST(@hours AS varchar) + ' +'; + SET @empRequest = CAST(@empRequestBody AS XML) + + SET @projRequestBody = N' + ' + @email + ' + ' + CONVERT(nvarchar, @startTime, 126) + '+00:00 + ' + CAST(@hours AS varchar) + ' +'; + SET @projRequest = CAST(@projRequestBody AS XML) + + BEGIN DIALOG CONVERSATION @empConvID + FROM SERVICE [http://schemas.apress.com/prosqlserver/EmployeeProjectDetailsService] + TO SERVICE 'http://schemas.apress.com/prosqlserver/EmployeeDetailsService' + ON CONTRACT [http://schemas.apress.com/prosqlserver/EmployeeServiceContract]; + + SEND ON CONVERSATION @empConvID + MESSAGE TYPE [http://schemas.apress.com/prosqlserver/EmployeeRequestMessage] + (@empRequest); + + BEGIN DIALOG CONVERSATION @projConvID + FROM SERVICE [http://schemas.apress.com/prosqlserver/EmployeeProjectDetailsService] + TO SERVICE 'http://schemas.apress.com/prosqlserver/ProjectDetailsService' + ON CONTRACT [http://schemas.apress.com/prosqlserver/ProjectServiceContract] + WITH RELATED_CONVERSATION = @empConvID, ENCRYPTION=OFF; + + SEND ON CONVERSATION @projConvID + MESSAGE TYPE [http://schemas.apress.com/prosqlserver/ProjectRequestMessage] + (@projRequest); + END +END; +GO + +CREATE QUEUE EmployeeProjectDetailsQueue +WITH STATUS = ON, RETENTION = OFF; + +CREATE SERVICE [http://schemas.apress.com/prosqlserver/EmployeeProjectDetailsService] +ON QUEUE EmployeeProjectDetailsQueue +( + [http://schemas.apress.com/prosqlserver/EmployeeServiceContract], + [http://schemas.apress.com/prosqlserver/ProjectServiceContract] +); +GO + +CREATE QUEUE VacationRequestQueue +WITH + STATUS = ON, + RETENTION = OFF, + ACTIVATION + ( + STATUS = ON, + PROCEDURE_NAME = usp_ProcessVacationRequest, + MAX_QUEUE_READERS = 5, + EXECUTE AS SELF + ); + +CREATE SERVICE [http://schemas.apress.com/prosqlserver/VacationRequestProcessorService] +ON QUEUE VacationRequestQueue +( + [http://schemas.apress.com/prosqlserver/VacationRequestContract] +); +GO + +CREATE PROCEDURE usp_ReadResponseMessages +AS +DECLARE @empMsgBody XML([http://schemas.apress.com/prosqlserver/EmployeeResponseSchema]), + @projMsgBody XML([http://schemas.apress.com/prosqlserver/ProjectResponseSchema]), + @groupId uniqueidentifier, + @empConvId uniqueidentifier, + @projConvId uniqueidentifier, + @activeProj int, + @hours int, + @empId int, + @email nvarchar(50), + @startTime datetime; + +DECLARE @msgTable TABLE +( + message_body varbinary(max), + message_type_name nvarchar(256), + conversation_handle uniqueidentifier +); +BEGIN + WAITFOR + ( + GET CONVERSATION GROUP @groupID + FROM EmployeeProjectDetailsQueue + ), TIMEOUT 500; + WHILE @groupID IS NOT NULL + BEGIN + WAITFOR + ( + RECEIVE message_body, message_type_name, conversation_handle + FROM EmployeeProjectDetailsQueue INTO @msgTable + ), TIMEOUT 2000; + + IF (SELECT COUNT(*) FROM @msgTable) > 0 + BEGIN + SET @empMsgBody = (SELECT TOP (1) CAST(message_body AS XML) + FROM @msgTable + WHERE message_type_name = 'http://schemas.apress.com/prosqlserver/EmployeeResponseMessage'); + SET @empConvID = (SELECT TOP (1) conversation_handle FROM @msgTable + WHERE message_type_name = 'http://schemas.apress.com/prosqlserver/EmployeeResponseMessage'); + SET @hours = @empMsgBody.value('data(//hoursVacation)[1]', 'int'); + SET @empId = @empMsgBody.value('data(//id)[1]', 'int'); + + SET @projMsgBody = (SELECT TOP (1) CAST(message_body AS XML) + FROM @msgTable + WHERE message_type_name = 'http://schemas.apress.com/prosqlserver/ProjectResponseMessage'); + SET @projConvID = (SELECT TOP (1) conversation_handle FROM @msgTable + WHERE message_type_name = 'http://schemas.apress.com/prosqlserver/ProjectResponseMessage'); + SET @activeProj = @projMsgBody.value('data(//activeProjects)[1]', 'int'); + SET @email = @projMsgBody.value('data(//email)[1]', 'varchar'); + SET @startTime = @projMsgBody.value('data(//startTime)[1]', 'datetime'); + + IF @hours > 160 + EXEC msdb.dbo.sp_send_dbmail + @profile_name = 'Default Profile', + @recipients = @email, + @subject = 'Vacation request', + @body = 'Your request for vacation has been refused because you have insufficient hours remaining of your holiday entitlement.'; + ELSE IF @startTime < DATEADD(Week, 1, GETDATE()) + EXEC msdb.dbo.sp_send_dbmail + @profile_name = 'Default Profile', + @recipients = @email, + @subject = 'Default Profile', + @body = 'Your request for vacation has been refused because you have not given sufficient notice. Please request holiday at least a week in advance.'; + ELSE IF @activeProj > 1 + EXEC msdb.dbo.sp_send_dbmail + @profile_name = 'Default Profile', + @recipients = @email, + @subject = 'Vacation request', + @body = 'Your request for vacation has been refused because you have too many active projects at that time.'; + ELSE + BEGIN + UPDATE HumanResources.Employee + SET VacationHours = @hours + WHERE EmployeeID = @empId; + EXEC msdb.dbo.sp_send_dbmail + @profile_name = 'Default Profile', + @recipients = @email, + @subject = 'Vacation request', + @body = 'Your request for vacation has been granted.'; + END + + END CONVERSATION @empConvID; + END CONVERSATION @projConvID; + END; + + WAITFOR + ( + GET CONVERSATION GROUP @groupID + FROM EmployeeProjectDetailsQueue + ), TIMEOUT 500; + END; +END; +GO + +CREATE USER projUser FOR LOGIN [JulianSkinner\Julian]; +GO + +CREATE CERTIFICATE projUserCert +AUTHORIZATION projUser +FROM FILE = 'C:\Apress\ProSqlServer\Chapter12\projUserCert.cer'; +GO + +GRANT CONNECT TO projUser; +GRANT SEND ON SERVICE::[http://schemas.apress.com/prosqlserver/EmployeeProjectDetailsService] +TO projUser; + +-- If you don't already have a Master Key for the AdventureWorks database, uncomment these lines. +-- You should also change the password. +--CREATE MASTER KEY ENCRYPTION BY PASSWORD = '45Gme*3^&fwu'; +--GO + +CREATE CERTIFICATE awUserCert +WITH SUBJECT = 'ecspi.julianskinner.local', + START_DATE = '01/01/2005', + EXPIRY_DATE = '01/01/2006' + +BACKUP CERTIFICATE awUserCert TO FILE = 'C:\Apress\ProSqlServer\Chapter12\awUserCert.cer'; + +CREATE REMOTE SERVICE BINDING ProjectDetailsServiceBinding +TO SERVICE 'http://schemas.apress.com/prosqlserver/ProjectDetailsService' +WITH USER = projUser; +GO + +CREATE SERVICE [http://schemas.apress.com/prosqlserver/VacationRequestInitiatorService] +ON QUEUE VacationRequestQueue +( + [http://schemas.apress.com/prosqlserver/VacationRequestContract] +); +GO + +CREATE PROCEDURE usp_RequestVacation + @employeeId int, + @email varchar(50), + @hours int, + @startDate varchar(50) +AS +DECLARE @dialogHandle uniqueidentifier, + @body nvarchar(1000), + @msg XML, + @date nvarchar(100) +BEGIN + SET @body = N' + + ' + CAST(@employeeID AS varchar) + ' + ' + @email + ' + ' + @startDate + ' + ' + CAST(@hours AS nvarchar) + ' +'; + SET @msg = CAST(@body AS XML) + + BEGIN DIALOG CONVERSATION @dialogHandle + FROM SERVICE [http://schemas.apress.com/prosqlserver/VacationRequestInitiatorService] + TO SERVICE 'http://schemas.apress.com/prosqlserver/VacationRequestProcessorService' + ON CONTRACT [http://schemas.apress.com/prosqlserver/VacationRequestContract]; + + SEND ON CONVERSATION @dialogHandle + MESSAGE TYPE [http://schemas.apress.com/prosqlserver/VacationRequest] + (@msg); + END CONVERSATION @dialogHandle; +END; diff --git a/1590594770-1/Chapter12/Projects_endpoint.sql b/1590594770-1/Chapter12/Projects_endpoint.sql new file mode 100644 index 0000000..5af6806 --- /dev/null +++ b/1590594770-1/Chapter12/Projects_endpoint.sql @@ -0,0 +1,25 @@ +USE master +GO + +IF NOT EXISTS(SELECT principal_id FROM sys.symmetric_keys WHERE name='##MS_DatabaseMasterKey##') + CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'gs53&"f"!385'; +GO + +CREATE CERTIFICATE projEndpointCert +WITH SUBJECT = 'peiriantprawf.julianskinner.local', + START_DATE = '01/01/2005', + EXPIRY_DATE = '01/01/2006' +ACTIVE FOR BEGIN_DIALOG = ON; +GO + +CREATE ENDPOINT ServiceBrokerEndpoint + STATE = STARTED + AS TCP (LISTENER_PORT = 4022) + FOR SERVICE_BROKER + ( + AUTHENTICATION = CERTIFICATE projEndpointCert, + ENCRYPTION = SUPPORTED + ); +GO + +BACKUP CERTIFICATE projEndpointCert TO FILE = 'C:\Apress\ProSqlServer\Chapter12\projEndpointCert.cer'; diff --git a/1590594770-1/Chapter12/Projects_security.sql b/1590594770-1/Chapter12/Projects_security.sql new file mode 100644 index 0000000..6ad7384 --- /dev/null +++ b/1590594770-1/Chapter12/Projects_security.sql @@ -0,0 +1,15 @@ +USE Projects +GO + +CREATE USER awUser FOR LOGIN [JulianSkinner\Administrator]; +GO + +CREATE CERTIFICATE awUserCert +AUTHORIZATION awUser +FROM FILE = 'C:\Apress\ProSqlServer\Chapter12\awUserCert.cer'; +GO + +GRANT CONNECT TO awUser; +GRANT SEND ON SERVICE::[http://schemas.apress.com/prosqlserver/ProjectDetailsService] +TO awUser; +GO diff --git a/1590594770-1/Chapter12/Projects_service.sql b/1590594770-1/Chapter12/Projects_service.sql new file mode 100644 index 0000000..cb3db0a --- /dev/null +++ b/1590594770-1/Chapter12/Projects_service.sql @@ -0,0 +1,204 @@ +USE master +GO + +CREATE CERTIFICATE awEndpointCert +FROM FILE = 'C:\Apress\ProSqlServer\Chapter12\awEndpointCert.cer'; +GO + +CREATE LOGIN sbLogin +FROM CERTIFICATE awEndpointCert; +GO + +GRANT CONNECT ON ENDPOINT::ServiceBrokerEndpoint +TO sbLogin; +GO + +CREATE DATABASE Projects; +GO + +USE Projects +GO + +ALTER DATABASE Projects SET ENABLE_BROKER; +GO + +CREATE ROUTE EmployeeProjectDetailsRoute +WITH + SERVICE_NAME = 'http://schemas.apress.com/prosqlserver/EmployeeProjectDetailsService', + ADDRESS = 'TCP://ecspi:4022'; +GO + +CREATE TABLE Project +( + ProjectID int IDENTITY PRIMARY KEY, + ProjectName nvarchar(100), + StartDate datetime, + EndDate datetime +); + +CREATE TABLE Employee +( + EmployeeID int IDENTITY PRIMARY KEY, + FirstName nvarchar(256), + LastName nvarchar(256), + Email nvarchar(512) +); + +CREATE TABLE ProjectEmployee +( + ProjectID int FOREIGN KEY REFERENCES Project(ProjectID), + EmployeeID int FOREIGN KEY REFERENCES Employee(EmployeeID) +); +GO + +INSERT INTO Project VALUES ('Pro SQL Server 2005', '01/01/2005', '10/15/2005'); +INSERT INTO Employee VALUES ('John', 'Doe', 'JohnDoe@apress.com'); +INSERT INTO ProjectEmployee VALUES (1, 1); +GO + +CREATE XML SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/ProjectRequestSchema] +AS N' + + + + + + + + + + +'; + +CREATE XML SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/ProjectResponseSchema] +AS N' + + + + + + + + + + +'; + +CREATE MESSAGE TYPE [http://schemas.apress.com/prosqlserver/ProjectRequestMessage] +VALIDATION = VALID_XML WITH SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/ProjectRequestSchema]; + +CREATE MESSAGE TYPE [http://schemas.apress.com/prosqlserver/ProjectResponseMessage] +VALIDATION = VALID_XML WITH SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/ProjectResponseSchema]; +GO + +CREATE CONTRACT [http://schemas.apress.com/prosqlserver/ProjectServiceContract] +( + [http://schemas.apress.com/prosqlserver/ProjectRequestMessage] SENT BY INITIATOR, + [http://schemas.apress.com/prosqlserver/ProjectResponseMessage] SENT BY TARGET +); +GO + +CREATE PROCEDURE usp_GetProjectDetailsForEmployee +AS +DECLARE @msgBody XML( + [http://schemas.apress.com/prosqlserver/ProjectRequestSchema]), + @convID uniqueidentifier, + @email varchar(512), + @hours int, + @startTime datetime, + @endTime datetime, + @projectCount int, + @response XML( + [http://schemas.apress.com/prosqlserver/ProjectResponseSchema]), + @respText nvarchar(1000), + @msgType nvarchar(256); + +DECLARE @msgTable TABLE +( + message_body varbinary(max), + conversation_handle uniqueidentifier, + message_type_name nvarchar(256) +); +BEGIN + WAITFOR + ( + RECEIVE TOP (1) message_body, conversation_handle, message_type_name + FROM ProjectServiceQueue INTO @msgTable + ), TIMEOUT 2000; + + SET @msgBody = (SELECT TOP (1) CAST(message_body AS XML) FROM @msgTable); + SET @msgType = (SELECT TOP (1) message_type_name FROM @msgTable); + SET @convID = (SELECT TOP (1) conversation_handle FROM @msgTable); + IF @msgType = 'http://schemas.apress.com/prosqlserver/ProjectRequestMessage' + BEGIN + SET @email = @msgBody.value('data(//email)[1]', 'varchar(50)'); + SET @hours = @msgBody.value('data(//hours)[1]', 'int'); + SET @startTime = @msgBody.value('data(//startTime)[1]', 'datetime'); + SET @endTime = DATEADD(week, @hours/40, @startTime) + + SET @projectCount = (SELECT COUNT(*) + FROM Project p + INNER JOIN ProjectEmployee pe + ON p.ProjectID = pe.ProjectID + INNER JOIN Employee e + ON pe.EmployeeID = e.EmployeeID + WHERE e.Email = @email + AND (p.StartDate < @startTime AND p.EndDate > @startTime) + OR (p.StartDate < @endTime AND p.EndDate > @endTime) + OR (p.StartDate > @startTime AND p.EndDate < @endTime)); + + SET @respText = N' + + ' + @email + ' + ' + CONVERT(nvarchar, @startTime, 126) + '+00:00 + ' + CAST(@projectCount AS nvarchar) + ' +'; + + SET @response = CAST(@respText AS XML); + SEND ON CONVERSATION @convID + MESSAGE TYPE + [http://schemas.apress.com/prosqlserver/ProjectResponseMessage] + (@response); + + END CONVERSATION @convID; + END; +END; +GO + +CREATE QUEUE ProjectServiceQueue +WITH + STATUS = ON, + RETENTION = OFF, + ACTIVATION + ( + STATUS = ON, + PROCEDURE_NAME = usp_GetProjectDetailsForEmployee, + MAX_QUEUE_READERS = 5, + EXECUTE AS SELF + ) + +CREATE SERVICE [http://schemas.apress.com/prosqlserver/ProjectDetailsService] +ON QUEUE ProjectServiceQueue +( + [http://schemas.apress.com/prosqlserver/ProjectServiceContract] +); +GO + +CREATE ROUTE EmployeeProjectDetailsRoute +WITH + SERVICE_NAME = + 'http://schemas.apress.com/prosqlserver/EmployeeProjectDetailsService', + ADDRESS = 'TCP://ecspi:4022'; +GO + +CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'gs53&"f"!385'; +GO + +CREATE CERTIFICATE projUserCert +WITH SUBJECT = 'peiriantprawf.julianskinner.local', + START_DATE = '01/01/2005', + EXPIRY_DATE = '01/01/2006' +ACTIVE FOR BEGIN_DIALOG = ON; +GO + +BACKUP CERTIFICATE projUserCert TO FILE = 'C:\Apress\ProSqlServer\Chapter12\projUserCert.cer' diff --git a/1590594770-1/Chapter12/SimpleExample.sql b/1590594770-1/Chapter12/SimpleExample.sql new file mode 100644 index 0000000..580293f --- /dev/null +++ b/1590594770-1/Chapter12/SimpleExample.sql @@ -0,0 +1,182 @@ +USE AdventureWorks +GO + +IF EXISTS(SELECT object_id FROM sys.procedures WHERE name='usp_RequestHoliday') + DROP PROCEDURE usp_RequestHoliday; + +IF EXISTS(SELECT object_id FROM sys.procedures WHERE name='usp_ProcessHolidayRequest') + DROP PROCEDURE usp_ProcessHolidayRequest; + +IF EXISTS(SELECT service_id FROM sys.services WHERE name='http://schemas.apress.com/prosqlserver/HolidayRequestProcessorService') + DROP SERVICE [http://schemas.apress.com/prosqlserver/HolidayRequestProcessorService]; + +IF EXISTS(SELECT service_id FROM sys.services WHERE name='http://schemas.apress.com/prosqlserver/HolidayRequestInitiatorService') + DROP SERVICE [http://schemas.apress.com/prosqlserver/HolidayRequestInitiatorService]; + +IF EXISTS(SELECT object_id FROM sys.service_queues WHERE name='HolidayRequestQueue') + DROP QUEUE HolidayRequestQueue; + +IF EXISTS(SELECT service_contract_id FROM sys.service_contracts WHERE name='http://schemas.apress.com/prosqlserver/HolidayRequestContract') + DROP CONTRACT [http://schemas.apress.com/prosqlserver/HolidayRequestContract]; + +IF EXISTS(SELECT message_type_id FROM sys.service_message_types WHERE name='http://schemas.apress.com/prosqlserver/HolidayRequest') + DROP MESSAGE TYPE [http://schemas.apress.com/prosqlserver/HolidayRequest]; + +IF EXISTS(SELECT xml_collection_id FROM sys.xml_schema_collections WHERE name='http://schemas.apress.com/prosqlserver/HolidayRequestSchema') + DROP XML SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/HolidayRequestSchema]; +GO + +CREATE XML SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/HolidayRequestSchema] +AS N' + + + + + + + + + + + +'; +GO + +CREATE MESSAGE TYPE [http://schemas.apress.com/prosqlserver/HolidayRequest] +VALIDATION = VALID_XML WITH SCHEMA COLLECTION [http://schemas.apress.com/prosqlserver/HolidayRequestSchema]; + +CREATE CONTRACT [http://schemas.apress.com/prosqlserver/HolidayRequestContract] +( + [http://schemas.apress.com/prosqlserver/HolidayRequest] SENT BY INITIATOR +); +GO + +CREATE PROCEDURE usp_ProcessHolidayRequest +AS +DECLARE @msgBody XML([http://schemas.apress.com/prosqlserver/HolidayRequestSchema]), + @convID uniqueidentifier, + @email varchar(50), + @employeeID int, + @hours int, + @startTime DateTime, + @hoursTaken int, + @msgType nvarchar(256); + +DECLARE @msgTable TABLE +( + message_body varbinary(max), + conversation_handle uniqueidentifier, + message_type_name nvarchar(256) +); +BEGIN + WAITFOR + ( + RECEIVE TOP (1) message_body, conversation_handle, message_type_name + FROM HolidayRequestQueue + INTO @msgTable + ), TIMEOUT 2000; + + SET @msgBody = (SELECT TOP (1) CAST(message_body AS XML) FROM @msgTable); + SET @convID = (SELECT TOP (1) conversation_handle FROM @msgTable); + SET @msgType = (SELECT TOP (1) message_type_name FROM @msgTable); + END CONVERSATION @convID; + IF @msgType = 'http://schemas.apress.com/prosqlserver/HolidayRequest' + BEGIN + SET @email = @msgBody.value('data(//email)[1]', 'varchar(50)'); + SET @hours = @msgBody.value('data(//hours)[1]', 'int'); + SET @startTime = @msgBody.value('data(//startTime)[1]', 'datetime'); + SET @employeeID = @msgBody.value('data(//employeeId)[1]', 'int'); + SET @hoursTaken = (SELECT VacationHours FROM HumanResources.Employee + WHERE EmployeeID = @employeeID); + + IF @hoursTaken + @hours > 160 + EXEC msdb.dbo.sp_send_dbmail + @profile_name = 'Default Profile', + @recipients = @email, + @subject = 'Vacation request', + @body = 'Your request for vacation has been refused because you +have insufficient hours remaining of your holiday entitlement.'; + ELSE IF @startTime < DATEADD(Week, 1, GETDATE()) + EXEC msdb.dbo.sp_send_dbmail + @profile_name = 'Default Profile', + @recipients = @email, + @subject = 'Vacation request', + @body = 'Your request for vacation has been refused because you +have not given sufficient notice. Please request holiday at least a week in +advance.'; + ELSE + BEGIN + UPDATE HumanResources.Employee + SET VacationHours = VacationHours + @hours; + EXEC msdb.dbo.sp_send_dbmail + @profile_name = 'Default Profile', + @recipients = @email, + @subject = 'Vacation request', + @body = 'Your request for vacation has been granted.'; + END + END +END +GO + +CREATE QUEUE HolidayRequestQueue +WITH + STATUS = ON, + RETENTION = OFF, + ACTIVATION + ( + STATUS = ON, + PROCEDURE_NAME = usp_ProcessHolidayRequest, + MAX_QUEUE_READERS = 5, + EXECUTE AS SELF + ); +GO + +CREATE SERVICE [http://schemas.apress.com/prosqlserver/HolidayRequestProcessorService] +ON QUEUE HolidayRequestQueue +( + [http://schemas.apress.com/prosqlserver/HolidayRequestContract] +); + +CREATE SERVICE [http://schemas.apress.com/prosqlserver/HolidayRequestInitiatorService] +ON QUEUE HolidayRequestQueue +( + [http://schemas.apress.com/prosqlserver/HolidayRequestContract] +); +GO + +CREATE PROCEDURE usp_RequestHoliday + @employeeId int, + @email varchar(50), + @hours int, + @startDate varchar(50) +AS +DECLARE @dialogHandle uniqueidentifier, + @body nvarchar(1000), + @msg XML, + @date nvarchar(100) +BEGIN + SET @body = N' + + ' + CAST(@employeeID AS varchar) + ' + ' + @email + ' + ' + @startDate + ' + ' + CAST(@hours AS nvarchar) + ' +'; + SET @msg = CAST(@body AS XML) + + BEGIN DIALOG CONVERSATION @dialogHandle + FROM SERVICE + [http://schemas.apress.com/prosqlserver/HolidayRequestInitiatorService] + TO SERVICE + 'http://schemas.apress.com/prosqlserver/HolidayRequestProcessorService' + ON CONTRACT + [http://schemas.apress.com/prosqlserver/HolidayRequestContract]; + + SEND ON CONVERSATION @dialogHandle + MESSAGE TYPE [http://schemas.apress.com/prosqlserver/HolidayRequest] + (@msg); + END CONVERSATION @dialogHandle; +END +GO + +EXEC usp_RequestHoliday 140, 'someone@somewhere.com', 8, '2005-11-01T09:00:00+00:00' diff --git a/1590594770-1/Chapter12/readme.txt b/1590594770-1/Chapter12/readme.txt new file mode 100644 index 0000000..0eaf79c --- /dev/null +++ b/1590594770-1/Chapter12/readme.txt @@ -0,0 +1,65 @@ +Instructions for running the Simple Service Broker Example +========================================================== + +To run this example, you will need to enable and configure Database Mail in (A) +and create a profile that the example can use to send e-mails. Please see +Chapter 13 for instructions on how to do that. + +If the profile you want to use isn't called 'Default Profile', you will +need to change the calls to sp_send_dbmail in the usp_ProcessHolidayRequest +stored procedure to use your profile. + + + + +Instructions for running the Distributed Service Broker Example +=============================================================== + +To run this example, you need to create the objects in the correct order +in the correct instance of SQL Server 2005. To indicate which instance of +SQL Server to run a SQL script or perform another action on, we use the +following abbreviations: + +(P) - The instance of SQL Server 2005 that hosts the Projects database +(A) - The instance of SQL Server 2005 that hosts the AdventureWorks database + + +The scripts create certificates and save them to file in a folder called +C:\Apress\ProSqlServer\Chapter12, so you will need to ensure that this folder +exists on both machines, or you will need to change the code to save the +certificates to another location. + + +To run the example, please follow these instructions: + +(1) Enable and configure Database Mail in (A), if you haven't already done so. +(2) Run the Projects_endpoint.sql script (P). +(3) Copy the generated certificate file projEndpointCert.cer from the (P) machine + to a directory of the same name on the (A) machine. +(4) Run the AW_endpoint.sql script (A). +(5) Copy the generated certificate file awEndpointCert.cer from the (A) machine + to the directory of the same name on the (P) machine. +(6) Run the Projects_service.sql script (P). +(7) Copy the generated certificate file projUserCert.cer from the (P) machine + to the directory of the same name on the (A) machine. +(8) Change the address in the CREATE ROUTE statement in the AW_services.sql script + so that it points to the (P) machine in your setup and change the name of the + login for the CREATE USER projUser statement to an existing login on your system. + If you haven't created a database master key for AdventureWorks, uncomment the + CREATE MASTER KEY statement. +(9) Run the AW_services.sql script on the (A) machine. +(10) Copy the generated certificate file awUserCert.cer from the (A) machine + to the directory of the same name on the (P) machine. +(11) Change the name of the login in the CREATE USER awUser statemet to an existing login + and run the Projects_security.sql script on the (P) machine. +(12) Run the following command in the AdventureWorks database to make a vacation request. + Change the parameters as appropriate, making sure that you pass in a valid e-mail address + where you can receive e-mail: + + EXEC usp_RequestVacation 140, 'someone@somewhere.com', 8, '2005-08-01T09:00:00+00:00' + +(13) Wait for a few seconds for the services to respond, and then execute the following command: + + EXEC usp_ReadResponseMessages; + + You should receive an e-mail after a short period. \ No newline at end of file diff --git a/1590594770-1/Chapter13/DatabaseMailXPs.txt b/1590594770-1/Chapter13/DatabaseMailXPs.txt new file mode 100644 index 0000000..b68e07a --- /dev/null +++ b/1590594770-1/Chapter13/DatabaseMailXPs.txt @@ -0,0 +1,8 @@ +SP_CONFIGURE 'show advanced', 1 +GO +RECONFIGURE +GO +SP_CONFIGURE "Database Mail XPs", 1 +GO +RECONFIGURE +GO \ No newline at end of file diff --git a/1590594770-1/Chapter13/MultipleProxyAccounts.txt b/1590594770-1/Chapter13/MultipleProxyAccounts.txt new file mode 100644 index 0000000..6e38906 --- /dev/null +++ b/1590594770-1/Chapter13/MultipleProxyAccounts.txt @@ -0,0 +1,20 @@ +CREATE CREDENTIAL [DevCredential] + WITH IDENTITY='<>', + SECRET='<>' + +USE MSDB +GO +sp_add_proxy @proxy_name = 'SSISDevProxy', +@enabled = 1, +@description = 'Proxy account used by developers to test their SSIS packages', +@credential_name = 'DevCredential' + +sp_grant_proxy_to_subsystem + @proxy_name = N'SSISDevProxy', + @subsystem_name = N'SSIS' + + +sp_grant_login_to_proxy + @login_name = N'Tammie', +@proxy_name = N'SSISDevProxy' + diff --git a/1590594770-1/Chapter13/SQLServerAgent.txt b/1590594770-1/Chapter13/SQLServerAgent.txt new file mode 100644 index 0000000..4c6500a --- /dev/null +++ b/1590594770-1/Chapter13/SQLServerAgent.txt @@ -0,0 +1,6 @@ +SP_CONFIGURE 'show advanced', 1 +GO +RECONFIGURE +GO +SP_CONFIGURE + diff --git a/1590594770-1/Chapter13/SendingMail.txt b/1590594770-1/Chapter13/SendingMail.txt new file mode 100644 index 0000000..b0ab5d0 --- /dev/null +++ b/1590594770-1/Chapter13/SendingMail.txt @@ -0,0 +1,6 @@ +Use msdb +GO +EXEC sp_send_dbmail @profile_name='myDatabaseMailProfile', +@recipients='username"foo.bar', +@subject='Test message', +@body='This is the body of the test message.' diff --git a/1590594770-1/Chapter13/WMIEvents.txt b/1590594770-1/Chapter13/WMIEvents.txt new file mode 100644 index 0000000..9b8d8dd --- /dev/null +++ b/1590594770-1/Chapter13/WMIEvents.txt @@ -0,0 +1,21 @@ +EXEC msdb.dbo.sp_add_operator @name=N'MyAgentOperator', + @enabled=1, + @pager_days=0, + @netsend_address=N'robs_laptop' +GO + + +EXEC msdb.dbo.sp_add_alert @name=N'Create_Database_Alert', + @enabled=1, + @delay_between_responses=0, + @include_event_description_in=0, +@wmi_namespace=N'\\.\root\Microsoft\SqlServer\ServerEvents\MSSQLSERVER', + @wmi_query=N'SELECT * FROM CREATE_DATABASE' +GO + + +EXEC msdb.dbo.sp_add_notification + @alert_name=N'Create_Database_Alert', + @operator_name=N'MyAgentOperator', + @notification_method = 4 +GO diff --git a/1590594770-1/Chapter13/backup_database_generic.sql b/1590594770-1/Chapter13/backup_database_generic.sql new file mode 100644 index 0000000..431dc98 --- /dev/null +++ b/1590594770-1/Chapter13/backup_database_generic.sql @@ -0,0 +1,4 @@ +File: backup_database_generic.sql +:CONNECT $(myConnection) +BACKUP DATABASE $(myDatabase) TO DISK='C:\backups\$(myDatabase).bak' + diff --git a/1590594770-1/Chapter13/backup_database_main.sql b/1590594770-1/Chapter13/backup_database_main.sql new file mode 100644 index 0000000..ac8c496 --- /dev/null +++ b/1590594770-1/Chapter13/backup_database_main.sql @@ -0,0 +1,7 @@ +File: backup_database_main.sql +:SETVAR myConnection . +:SETVAR myDatabase ReportServer + +:R "backup_database_generic.sql" + +GO diff --git a/1590594770-1/Chapter13/backup_databases.sql b/1590594770-1/Chapter13/backup_databases.sql new file mode 100644 index 0000000..a016bc6 --- /dev/null +++ b/1590594770-1/Chapter13/backup_databases.sql @@ -0,0 +1,12 @@ +File: backup_databases.sql +--Make a connection to SERVERONE using Windows Authentication +:CONNECT SERVERONE –E +--Issue a backup database command for ReportServer +BACKUP DATABASE [ReportServer] TO DISK='C:\backups\ReportServer.bak' +GO + +--Make a connection to SERVERTWO using Windows Authentication +:CONNECT SERVERTWO –E +--Issue a backup database command for Products database +BACKUP DATABASE [Products] TO DISK='D:\SQLServer\Backups\Products.bak' +GO diff --git a/1590594770-1/Chapter13/sp_send_dbmail.txt b/1590594770-1/Chapter13/sp_send_dbmail.txt new file mode 100644 index 0000000..c54bfa7 --- /dev/null +++ b/1590594770-1/Chapter13/sp_send_dbmail.txt @@ -0,0 +1,5 @@ +Sp_send_dbmail @profile_name='MyProfile', +@recipients='testuser@apress.com', +@subject='Test Message', +@body='This is the body of the message.', +@importance='HIGH' diff --git a/1590594770-1/Chapter13/sysjobsteplogs.txt b/1590594770-1/Chapter13/sysjobsteplogs.txt new file mode 100644 index 0000000..a9d45b5 --- /dev/null +++ b/1590594770-1/Chapter13/sysjobsteplogs.txt @@ -0,0 +1,4 @@ +USE MSDB +GO +sp_help_jobsteplog @job_name='FullDBBackup' +GO \ No newline at end of file diff --git a/1590594770-1/Chapter14/BookSales.txt b/1590594770-1/Chapter14/BookSales.txt new file mode 100644 index 0000000..8487a1a --- /dev/null +++ b/1590594770-1/Chapter14/BookSales.txt @@ -0,0 +1,40 @@ +1700670127 2004-10-13 12:23:54.890000000 31.434 +2190414452 2004-12-11 12:23:55.080000000 91.5634 +9163370433 2004-10-23 12:23:55.080000000 93.8803 +8240890662 2004-11-02 12:23:55.080000000 72.5189 +9724485384 2004-11-01 12:23:55.080000000 42.3559 +3818073842 2004-10-10 12:23:55.080000000 35.5185 +4354109840 2004-11-07 12:23:55.080000000 77.4156 +3841883691 2004-10-19 12:23:55.090000000 5.2721 +8248344093 2004-11-23 12:23:55.090000000 27.8866 +7742829934 2004-09-29 12:23:55.090000000 96.8699 +3972918159 2004-11-30 12:23:55.090000000 80.8913 +3387357000 2004-11-05 12:23:55.090000000 37.0749 +3020951299 2004-10-31 12:23:55.090000000 55.7052 +5062025755 2004-10-01 12:23:55.090000000 25.1956 +7794466091 2004-12-15 12:23:55.090000000 79.8708 +3613708504 2004-11-09 12:23:55.090000000 17.2435 +7033565864 2004-10-22 12:23:55.090000000 92.4496 +4632544057 2004-10-08 12:23:55.090000000 89.7585 +5004909486 2004-09-23 12:23:55.090000000 31.6866 +1916341917 2004-12-02 12:23:55.090000000 42.531 +9828905102 2005-03-12 12:24:05.837000000 31.4099 +4401326876 2005-02-01 12:24:05.837000000 29.9687 +4439395032 2005-02-14 12:24:05.837000000 13.013 +6062292933 2005-02-12 12:24:05.837000000 5.6384 +2497442656 2004-12-29 12:24:05.837000000 92.9495 +4405919414 2005-02-19 12:24:05.837000000 39.628 +7499038595 2004-12-29 12:24:05.837000000 55.5942 +799884766 2005-03-02 12:24:05.837000000 32.4062 +7137023232 2005-01-04 12:24:05.837000000 64.077 +9857116326 2005-03-25 12:24:05.837000000 21.5201 +6858375361 2005-02-04 12:24:05.837000000 79.6188 +2811816672 2005-02-07 12:24:05.837000000 77.5774 +6066791506 2005-02-17 12:24:05.837000000 51.4393 +8398729596 2005-02-15 12:24:05.837000000 27.2878 +6016191510 2005-03-28 12:24:05.837000000 15.7501 +5739941273 2005-01-19 12:24:05.837000000 71.9712 +2507570361 2005-03-12 12:24:05.837000000 56.2592 +6272684851 2005-03-13 12:24:05.847000000 93.4991 +388103114 2005-04-03 12:24:05.847000000 76.8347 +9602390361 2005-02-15 12:24:05.847000000 2.4937 diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring.sln b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring.sln new file mode 100644 index 0000000..df48b99 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DatabaseMirroring", "DatabaseMirroring\DatabaseMirroring.vbproj", "{F95378BD-AF81-4770-AC62-9C2A6383198E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F95378BD-AF81-4770-AC62-9C2A6383198E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F95378BD-AF81-4770-AC62-9C2A6383198E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F95378BD-AF81-4770-AC62-9C2A6383198E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F95378BD-AF81-4770-AC62-9C2A6383198E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring.suo b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring.suo new file mode 100644 index 0000000..bc9e772 Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring.suo differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/DatabaseMirroring.vbproj b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/DatabaseMirroring.vbproj new file mode 100644 index 0000000..744ba73 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/DatabaseMirroring.vbproj @@ -0,0 +1,118 @@ + + + Debug + AnyCPU + 8.0.40903 + 2.0 + {F95378BD-AF81-4770-AC62-9C2A6383198E} + WinExe + DatabaseMirroring.My.MyApplication + DatabaseMirroring + DatabaseMirroring + WindowsForms + + + true + full + true + true + true + bin\ + DatabaseMirroring.xml + 42016,42017,42018,42019,42032 + + + false + false + true + false + true + bin\ + DatabaseMirroring.xml + 42016,42017,42018,42019,42032 + + + + + + + + + + + + + + + + + + + + frmSelectDB.vb + + + Form + + + Form + + + frmMain.vb + Form + + + Code + + + True + MyApplication.myapp + Code + + + True + True + MyResources.resx + Code + + + True + MySettings.settings + Code + + + Code + + + + + frmMain.vb + + + VbMyResourcesResXFileCodeGenerator + MyResources.vb + My.Resources + + + + + + MyApplicationCodeGenerator + MyApplication.vb + + + SettingsSingleFileGenerator + MySettings.vb + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/DatabaseMirroring.vbproj.user b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/DatabaseMirroring.vbproj.user new file mode 100644 index 0000000..aafb693 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/DatabaseMirroring.vbproj.user @@ -0,0 +1,7 @@ + + + 8.0.40903 + ProjectFiles + 0 + + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/AssemblyInfo.vb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..207f843 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/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/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyApplication.myapp b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyApplication.myapp new file mode 100644 index 0000000..121bf2d --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyApplication.myapp @@ -0,0 +1,10 @@ + + + true + DatabaseMirroring.DatabaseMirroring.frmMain + false + 0 + true + 0 + 0 + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyApplication.vb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyApplication.vb new file mode 100644 index 0000000..a443a45 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyApplication.vb @@ -0,0 +1,32 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.40903.27 +' +' 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 Class MyApplication + + _ + Public Sub New() + MyBase.New(Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.ShutDownStyle = Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = My.Forms.frmMain + End Sub + End Class +End Namespace diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyEvents.vb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyEvents.vb new file mode 100644 index 0000000..5fe787f --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyEvents.vb @@ -0,0 +1,13 @@ +Namespace My + Partial Friend Class MyApplication + + 'Use the editor window dropdowns in the Application pane of the Project Designer to handle MyApplication Events + ' + 'Startup: Raised when the application starts, before the startup form is created. + 'Shutdown: Raised after all application forms are closed. This event is not raised if the application is terminating abnormally. + 'UnhandledException: Raised if the application encounters an unhandled exception. + 'StartupNextInstance: Raised when launching a single-instance application and the application is already active. + 'NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. + + End Class +End Namespace diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyResources.resx b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyResources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyResources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyResources.vb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyResources.vb new file mode 100644 index 0000000..edd4aae --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MyResources.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' 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 +Imports System.IO +Imports System.Resources + +Namespace My.Resources + + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + 'This class was auto-generated by the Strongly Typed Resource Builder + 'class via a tool like ResGen or Visual Studio.NET. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + _ + Module MyResources + + Private _resMgr As System.Resources.ResourceManager + + Private _resCulture As System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Public ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If (_resMgr Is Nothing) Then + Dim temp As System.Resources.ResourceManager = New System.Resources.ResourceManager("DatabaseMirroring.MyResources", GetType(MyResources).Assembly) + System.Threading.Thread.MemoryBarrier + _resMgr = temp + End If + Return _resMgr + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Public Property Culture() As System.Globalization.CultureInfo + Get + Return _resCulture + End Get + Set + _resCulture = value + End Set + End Property + End Module +End Namespace diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MySettings.settings b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MySettings.settings new file mode 100644 index 0000000..0bcb11d --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MySettings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MySettings.vb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MySettings.vb new file mode 100644 index 0000000..3d12c6f --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/My Project/MySettings.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + + +Partial Friend NotInheritable Class MySettings + Inherits System.Configuration.ApplicationSettingsBase + + Private Shared m_Value As MySettings + + Private Shared m_SyncObject As Object = New Object + + _ + Public Shared ReadOnly Property Value() As MySettings + Get + If (MySettings.m_Value Is Nothing) Then + System.Threading.Monitor.Enter(MySettings.m_SyncObject) + If (MySettings.m_Value Is Nothing) Then + Try + MySettings.m_Value = New MySettings + Finally + System.Threading.Monitor.Exit(MySettings.m_SyncObject) + End Try + End If + End If + Return MySettings.m_Value + End Get + End Property +End Class diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/app.config b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/app.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/app.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.exe b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.exe new file mode 100644 index 0000000..59c890d Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.exe differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.exe.config b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.exe.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.pdb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.pdb new file mode 100644 index 0000000..f4d5d8a Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.pdb differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.vshost.exe b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.vshost.exe new file mode 100644 index 0000000..72b0f71 Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.vshost.exe differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.vshost.exe.config b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.vshost.exe.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.vshost.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.xml b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.xml new file mode 100644 index 0000000..e20b78b --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/bin/DatabaseMirroring.xml @@ -0,0 +1,11 @@ + + + + +DatabaseMirroring + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmMain.Designer.vb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmMain.Designer.vb new file mode 100644 index 0000000..9be7322 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmMain.Designer.vb @@ -0,0 +1,480 @@ +Partial Public Class frmMain + Inherits System.Windows.Forms.Form + + _ + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + End Sub + + 'Form overrides dispose to clean up the component list. + _ + Protected Overloads 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.lblPrinicpal = New System.Windows.Forms.Label + Me.LblMirror = New System.Windows.Forms.Label + Me.lblWitness = New System.Windows.Forms.Label + Me.txtPrincipalEndPoint = New System.Windows.Forms.TextBox + Me.txtMirrorEndPoint = New System.Windows.Forms.TextBox + Me.txtWitnessEndPoint = New System.Windows.Forms.TextBox + Me.checkWitness = New System.Windows.Forms.CheckBox + Me.lblStep1 = New System.Windows.Forms.Label + Me.lblStep2 = New System.Windows.Forms.Label + Me.btnSelectDB = New System.Windows.Forms.Button + Me.btnSetup = New System.Windows.Forms.Button + Me.lblStep3 = New System.Windows.Forms.Label + Me.lblDataFlow = New System.Windows.Forms.Label + Me.txtWitnessServer = New System.Windows.Forms.TextBox + Me.txtMirrorServer = New System.Windows.Forms.TextBox + Me.txtPrincipalServer = New System.Windows.Forms.TextBox + Me.lblWitnessServer = New System.Windows.Forms.Label + Me.lblMirrorServer = New System.Windows.Forms.Label + Me.lblPrincipalServer = New System.Windows.Forms.Label + Me.lblServerNames = New System.Windows.Forms.Label + Me.lblServerAddresses = New System.Windows.Forms.Label + Me.btnFail = New System.Windows.Forms.Button + Me.Label4 = New System.Windows.Forms.Label + Me.listInterval = New System.Windows.Forms.ListBox + Me.lblDatabaseName = New System.Windows.Forms.Label + Me.lblDBMirrorStatus = New System.Windows.Forms.Label + Me.lblDBMirrorStatusText = New System.Windows.Forms.Label + Me.lblPrincipalText = New System.Windows.Forms.Label + Me.lblPrincipal = New System.Windows.Forms.Label + Me.lblBackupRestorePath = New System.Windows.Forms.Label + Me.txtBackupRestorePath = New System.Windows.Forms.TextBox + Me.timerMirroring = New System.Windows.Forms.Timer(Me.components) + Me.btnTurnOff = New System.Windows.Forms.Button + Me.lblConnectedServer = New System.Windows.Forms.Label + Me.lblConnectedServerText = New System.Windows.Forms.Label + Me.lblDataFlowText = New System.Windows.Forms.Label + Me.SuspendLayout() + ' + 'lblPrinicpal + ' + Me.lblPrinicpal.AutoSize = True + Me.lblPrinicpal.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblPrinicpal.Location = New System.Drawing.Point(17, 125) + Me.lblPrinicpal.Name = "lblPrinicpal" + Me.lblPrinicpal.Size = New System.Drawing.Size(137, 14) + Me.lblPrinicpal.TabIndex = 0 + Me.lblPrinicpal.Text = "Principal Server &Address:" + ' + 'LblMirror + ' + Me.LblMirror.AutoSize = True + Me.LblMirror.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.LblMirror.Location = New System.Drawing.Point(17, 145) + Me.LblMirror.Name = "LblMirror" + Me.LblMirror.Size = New System.Drawing.Size(123, 14) + Me.LblMirror.TabIndex = 1 + Me.LblMirror.Text = "Mi&rror Server Address:" + ' + 'lblWitness + ' + Me.lblWitness.AutoSize = True + Me.lblWitness.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblWitness.Location = New System.Drawing.Point(17, 165) + Me.lblWitness.Name = "lblWitness" + Me.lblWitness.Size = New System.Drawing.Size(189, 14) + Me.lblWitness.TabIndex = 2 + Me.lblWitness.Text = "W&itness Server Address (Optional):" + ' + 'txtPrincipalEndPoint + ' + Me.txtPrincipalEndPoint.Location = New System.Drawing.Point(216, 125) + Me.txtPrincipalEndPoint.Name = "txtPrincipalEndPoint" + Me.txtPrincipalEndPoint.Size = New System.Drawing.Size(400, 20) + Me.txtPrincipalEndPoint.TabIndex = 4 + Me.txtPrincipalEndPoint.Text = "TCP://Server:Port" + ' + 'txtMirrorEndPoint + ' + Me.txtMirrorEndPoint.Location = New System.Drawing.Point(216, 142) + Me.txtMirrorEndPoint.Name = "txtMirrorEndPoint" + Me.txtMirrorEndPoint.Size = New System.Drawing.Size(400, 20) + Me.txtMirrorEndPoint.TabIndex = 5 + Me.txtMirrorEndPoint.Text = "TCP://Server:Port" + ' + 'txtWitnessEndPoint + ' + Me.txtWitnessEndPoint.Location = New System.Drawing.Point(216, 159) + Me.txtWitnessEndPoint.Name = "txtWitnessEndPoint" + Me.txtWitnessEndPoint.Size = New System.Drawing.Size(400, 20) + Me.txtWitnessEndPoint.TabIndex = 6 + Me.txtWitnessEndPoint.Text = "TCP://Server:Port" + ' + 'checkWitness + ' + Me.checkWitness.AutoSize = True + Me.checkWitness.Checked = True + Me.checkWitness.CheckState = System.Windows.Forms.CheckState.Checked + Me.checkWitness.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.checkWitness.Location = New System.Drawing.Point(17, 185) + Me.checkWitness.Name = "checkWitness" + Me.checkWitness.Size = New System.Drawing.Size(93, 17) + Me.checkWitness.TabIndex = 7 + Me.checkWitness.Text = "&Use Witness" + ' + 'lblStep1 + ' + Me.lblStep1.AutoSize = True + Me.lblStep1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblStep1.Location = New System.Drawing.Point(17, 220) + Me.lblStep1.Name = "lblStep1" + Me.lblStep1.Size = New System.Drawing.Size(178, 14) + Me.lblStep1.TabIndex = 7 + Me.lblStep1.Text = "Step 3: Select Database to Mirror" + ' + 'lblStep2 + ' + Me.lblStep2.AutoSize = True + Me.lblStep2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblStep2.Location = New System.Drawing.Point(17, 290) + Me.lblStep2.Name = "lblStep2" + Me.lblStep2.Size = New System.Drawing.Size(362, 14) + Me.lblStep2.TabIndex = 8 + Me.lblStep2.Text = "Step 4: Setup Mirroring (Backup, Restore, Endpoints, start mirroring)" + ' + 'btnSelectDB + ' + Me.btnSelectDB.Location = New System.Drawing.Point(21, 240) + Me.btnSelectDB.Name = "btnSelectDB" + Me.btnSelectDB.Size = New System.Drawing.Size(110, 23) + Me.btnSelectDB.TabIndex = 8 + Me.btnSelectDB.Text = "&Select Database" + ' + 'btnSetup + ' + Me.btnSetup.Enabled = False + Me.btnSetup.Location = New System.Drawing.Point(17, 365) + Me.btnSetup.Name = "btnSetup" + Me.btnSetup.Size = New System.Drawing.Size(110, 23) + Me.btnSetup.TabIndex = 11 + Me.btnSetup.Text = "Se&tup Mirroring" + ' + 'lblStep3 + ' + Me.lblStep3.AutoSize = True + Me.lblStep3.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblStep3.Location = New System.Drawing.Point(17, 419) + Me.lblStep3.Name = "lblStep3" + Me.lblStep3.Size = New System.Drawing.Size(188, 14) + Me.lblStep3.TabIndex = 11 + Me.lblStep3.Text = "Step 5: Fail Mirroring over to Mirror" + ' + 'lblDataFlow + ' + Me.lblDataFlow.AutoSize = True + Me.lblDataFlow.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblDataFlow.Location = New System.Drawing.Point(21, 507) + Me.lblDataFlow.Name = "lblDataFlow" + Me.lblDataFlow.Size = New System.Drawing.Size(57, 14) + Me.lblDataFlow.TabIndex = 12 + Me.lblDataFlow.Text = "Data Flow" + ' + 'txtWitnessServer + ' + Me.txtWitnessServer.Location = New System.Drawing.Point(216, 64) + Me.txtWitnessServer.Name = "txtWitnessServer" + Me.txtWitnessServer.Size = New System.Drawing.Size(400, 20) + Me.txtWitnessServer.TabIndex = 3 + Me.txtWitnessServer.Text = "Server\InstanceName" + ' + 'txtMirrorServer + ' + Me.txtMirrorServer.Location = New System.Drawing.Point(216, 47) + Me.txtMirrorServer.Name = "txtMirrorServer" + Me.txtMirrorServer.Size = New System.Drawing.Size(400, 20) + Me.txtMirrorServer.TabIndex = 2 + Me.txtMirrorServer.Text = "Server\InstanceName" + ' + 'txtPrincipalServer + ' + Me.txtPrincipalServer.Location = New System.Drawing.Point(216, 30) + Me.txtPrincipalServer.Name = "txtPrincipalServer" + Me.txtPrincipalServer.Size = New System.Drawing.Size(400, 20) + Me.txtPrincipalServer.TabIndex = 1 + Me.txtPrincipalServer.Text = "Server\InstanceName" + ' + 'lblWitnessServer + ' + Me.lblWitnessServer.AutoSize = True + Me.lblWitnessServer.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblWitnessServer.Location = New System.Drawing.Point(17, 70) + Me.lblWitnessServer.Name = "lblWitnessServer" + Me.lblWitnessServer.Size = New System.Drawing.Size(189, 14) + Me.lblWitnessServer.TabIndex = 16 + Me.lblWitnessServer.Text = "&Witness Server Address (Optional):" + ' + 'lblMirrorServer + ' + Me.lblMirrorServer.AutoSize = True + Me.lblMirrorServer.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblMirrorServer.Location = New System.Drawing.Point(17, 50) + Me.lblMirrorServer.Name = "lblMirrorServer" + Me.lblMirrorServer.Size = New System.Drawing.Size(123, 14) + Me.lblMirrorServer.TabIndex = 15 + Me.lblMirrorServer.Text = "&Mirror Server Address:" + ' + 'lblPrincipalServer + ' + Me.lblPrincipalServer.AutoSize = True + Me.lblPrincipalServer.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblPrincipalServer.Location = New System.Drawing.Point(17, 30) + Me.lblPrincipalServer.Name = "lblPrincipalServer" + Me.lblPrincipalServer.Size = New System.Drawing.Size(137, 14) + Me.lblPrincipalServer.TabIndex = 14 + Me.lblPrincipalServer.Text = "&Principal Server Address:" + ' + 'lblServerNames + ' + Me.lblServerNames.AutoSize = True + Me.lblServerNames.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblServerNames.Location = New System.Drawing.Point(17, 7) + Me.lblServerNames.Name = "lblServerNames" + Me.lblServerNames.Size = New System.Drawing.Size(329, 14) + Me.lblServerNames.TabIndex = 20 + Me.lblServerNames.Text = "Step 1: Enter SQL Server Names for your Mirror Configuration" + ' + 'lblServerAddresses + ' + Me.lblServerAddresses.AutoSize = True + Me.lblServerAddresses.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblServerAddresses.Location = New System.Drawing.Point(17, 99) + Me.lblServerAddresses.Name = "lblServerAddresses" + Me.lblServerAddresses.Size = New System.Drawing.Size(312, 14) + Me.lblServerAddresses.TabIndex = 21 + Me.lblServerAddresses.Text = "Step 2: Enter Server Endpoint Addresses you want created" + ' + 'btnFail + ' + Me.btnFail.Enabled = False + Me.btnFail.Location = New System.Drawing.Point(21, 439) + Me.btnFail.Name = "btnFail" + Me.btnFail.Size = New System.Drawing.Size(110, 23) + Me.btnFail.TabIndex = 12 + Me.btnFail.Text = "&Fail!" + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(17, 345) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(334, 14) + Me.Label4.TabIndex = 23 + Me.Label4.Text = "Please select an interval to insert data into database (in seconds):" + ' + 'listInterval + ' + Me.listInterval.FormattingEnabled = True + Me.listInterval.Items.AddRange(New Object() {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"}) + Me.listInterval.Location = New System.Drawing.Point(343, 342) + Me.listInterval.Name = "listInterval" + Me.listInterval.ScrollAlwaysVisible = True + Me.listInterval.Size = New System.Drawing.Size(49, 17) + Me.listInterval.TabIndex = 10 + ' + 'lblDatabaseName + ' + Me.lblDatabaseName.AutoSize = True + Me.lblDatabaseName.Location = New System.Drawing.Point(152, 245) + Me.lblDatabaseName.Name = "lblDatabaseName" + Me.lblDatabaseName.Size = New System.Drawing.Size(0, 0) + Me.lblDatabaseName.TabIndex = 25 + ' + 'lblDBMirrorStatus + ' + Me.lblDBMirrorStatus.AutoSize = True + Me.lblDBMirrorStatus.Location = New System.Drawing.Point(133, 370) + Me.lblDBMirrorStatus.Name = "lblDBMirrorStatus" + Me.lblDBMirrorStatus.Size = New System.Drawing.Size(124, 14) + Me.lblDBMirrorStatus.TabIndex = 26 + Me.lblDBMirrorStatus.Text = "Database Mirror Status: " + ' + 'lblDBMirrorStatusText + ' + Me.lblDBMirrorStatusText.AutoSize = True + Me.lblDBMirrorStatusText.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblDBMirrorStatusText.Location = New System.Drawing.Point(255, 370) + Me.lblDBMirrorStatusText.Name = "lblDBMirrorStatusText" + Me.lblDBMirrorStatusText.Size = New System.Drawing.Size(74, 14) + Me.lblDBMirrorStatusText.TabIndex = 27 + Me.lblDBMirrorStatusText.Text = "Unconfigured" + ' + 'lblPrincipalText + ' + Me.lblPrincipalText.AutoSize = True + Me.lblPrincipalText.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblPrincipalText.Location = New System.Drawing.Point(255, 390) + Me.lblPrincipalText.Name = "lblPrincipalText" + Me.lblPrincipalText.Size = New System.Drawing.Size(74, 14) + Me.lblPrincipalText.TabIndex = 29 + Me.lblPrincipalText.Text = "Unconfigured" + ' + 'lblPrincipal + ' + Me.lblPrincipal.AutoSize = True + Me.lblPrincipal.Location = New System.Drawing.Point(133, 390) + Me.lblPrincipal.Name = "lblPrincipal" + Me.lblPrincipal.Size = New System.Drawing.Size(77, 14) + Me.lblPrincipal.TabIndex = 28 + Me.lblPrincipal.Text = "Principal Role:" + ' + 'lblBackupRestorePath + ' + Me.lblBackupRestorePath.AutoSize = True + Me.lblBackupRestorePath.Location = New System.Drawing.Point(17, 322) + Me.lblBackupRestorePath.Name = "lblBackupRestorePath" + Me.lblBackupRestorePath.Size = New System.Drawing.Size(189, 14) + Me.lblBackupRestorePath.TabIndex = 30 + Me.lblBackupRestorePath.Text = "Path for Backup/Restore Operations:" + ' + 'txtBackupRestorePath + ' + Me.txtBackupRestorePath.Location = New System.Drawing.Point(216, 319) + Me.txtBackupRestorePath.Name = "txtBackupRestorePath" + Me.txtBackupRestorePath.Size = New System.Drawing.Size(400, 20) + Me.txtBackupRestorePath.TabIndex = 9 + Me.txtBackupRestorePath.Text = "Local path (such as C:\) or \\server\share\" + ' + 'timerMirroring + ' + ' + 'btnTurnOff + ' + Me.btnTurnOff.Enabled = False + Me.btnTurnOff.Location = New System.Drawing.Point(21, 468) + Me.btnTurnOff.Name = "btnTurnOff" + Me.btnTurnOff.Size = New System.Drawing.Size(110, 23) + Me.btnTurnOff.TabIndex = 13 + Me.btnTurnOff.Text = "Turn off M&irroring" + ' + 'lblConnectedServer + ' + Me.lblConnectedServer.AutoSize = True + Me.lblConnectedServer.Location = New System.Drawing.Point(21, 527) + Me.lblConnectedServer.Name = "lblConnectedServer" + Me.lblConnectedServer.Size = New System.Drawing.Size(109, 14) + Me.lblConnectedServer.TabIndex = 33 + Me.lblConnectedServer.Text = "Connected to server:" + ' + 'lblConnectedServerText + ' + Me.lblConnectedServerText.AutoSize = True + Me.lblConnectedServerText.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblConnectedServerText.Location = New System.Drawing.Point(131, 527) + Me.lblConnectedServerText.Name = "lblConnectedServerText" + Me.lblConnectedServerText.Size = New System.Drawing.Size(74, 14) + Me.lblConnectedServerText.TabIndex = 34 + Me.lblConnectedServerText.Text = "Unconfigured" + ' + 'lblDataFlowText + ' + Me.lblDataFlowText.AutoSize = True + Me.lblDataFlowText.Location = New System.Drawing.Point(22, 560) + Me.lblDataFlowText.Name = "lblDataFlowText" + Me.lblDataFlowText.Size = New System.Drawing.Size(0, 0) + Me.lblDataFlowText.TabIndex = 35 + ' + 'frmMain + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) + Me.ClientSize = New System.Drawing.Size(659, 599) + Me.Controls.Add(Me.lblDataFlowText) + Me.Controls.Add(Me.lblConnectedServerText) + Me.Controls.Add(Me.lblConnectedServer) + Me.Controls.Add(Me.btnTurnOff) + Me.Controls.Add(Me.txtBackupRestorePath) + Me.Controls.Add(Me.lblBackupRestorePath) + Me.Controls.Add(Me.lblPrincipalText) + Me.Controls.Add(Me.lblPrincipal) + Me.Controls.Add(Me.lblDBMirrorStatusText) + Me.Controls.Add(Me.lblDBMirrorStatus) + Me.Controls.Add(Me.lblDatabaseName) + Me.Controls.Add(Me.listInterval) + Me.Controls.Add(Me.Label4) + Me.Controls.Add(Me.btnFail) + Me.Controls.Add(Me.lblServerAddresses) + Me.Controls.Add(Me.lblServerNames) + Me.Controls.Add(Me.txtWitnessServer) + Me.Controls.Add(Me.txtMirrorServer) + Me.Controls.Add(Me.txtPrincipalServer) + Me.Controls.Add(Me.lblWitnessServer) + Me.Controls.Add(Me.lblMirrorServer) + Me.Controls.Add(Me.lblPrincipalServer) + Me.Controls.Add(Me.lblDataFlow) + Me.Controls.Add(Me.lblStep3) + Me.Controls.Add(Me.btnSetup) + Me.Controls.Add(Me.btnSelectDB) + Me.Controls.Add(Me.lblStep2) + Me.Controls.Add(Me.lblStep1) + Me.Controls.Add(Me.checkWitness) + Me.Controls.Add(Me.txtWitnessEndPoint) + Me.Controls.Add(Me.txtMirrorEndPoint) + Me.Controls.Add(Me.txtPrincipalEndPoint) + Me.Controls.Add(Me.lblWitness) + Me.Controls.Add(Me.LblMirror) + Me.Controls.Add(Me.lblPrinicpal) + Me.Location = New System.Drawing.Point(13, 14) + Me.Name = "frmMain" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Database Mirroring Sample Application" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents lblPrinicpal As System.Windows.Forms.Label + Friend WithEvents LblMirror As System.Windows.Forms.Label + Friend WithEvents lblWitness As System.Windows.Forms.Label + Friend WithEvents txtPrincipalEndPoint As System.Windows.Forms.TextBox + Friend WithEvents txtMirrorEndPoint As System.Windows.Forms.TextBox + Friend WithEvents txtWitnessEndPoint As System.Windows.Forms.TextBox + Friend WithEvents checkWitness As System.Windows.Forms.CheckBox + Friend WithEvents lblStep1 As System.Windows.Forms.Label + Friend WithEvents lblStep2 As System.Windows.Forms.Label + Friend WithEvents btnSelectDB As System.Windows.Forms.Button + Friend WithEvents btnSetup As System.Windows.Forms.Button + Friend WithEvents lblStep3 As System.Windows.Forms.Label + Friend WithEvents lblDataFlow As System.Windows.Forms.Label + Friend WithEvents txtWitnessServer As System.Windows.Forms.TextBox + Friend WithEvents txtMirrorServer As System.Windows.Forms.TextBox + Friend WithEvents txtPrincipalServer As System.Windows.Forms.TextBox + Friend WithEvents lblWitnessServer As System.Windows.Forms.Label + Friend WithEvents lblMirrorServer As System.Windows.Forms.Label + Friend WithEvents lblPrincipalServer As System.Windows.Forms.Label + Friend WithEvents lblServerNames As System.Windows.Forms.Label + Friend WithEvents lblServerAddresses As System.Windows.Forms.Label + Friend WithEvents btnFail As System.Windows.Forms.Button + Friend WithEvents Label4 As System.Windows.Forms.Label + Friend WithEvents listInterval As System.Windows.Forms.ListBox + Friend WithEvents lblDatabaseName As System.Windows.Forms.Label + Friend WithEvents lblDBMirrorStatus As System.Windows.Forms.Label + Friend WithEvents lblDBMirrorStatusText As System.Windows.Forms.Label + Friend WithEvents lblPrincipalText As System.Windows.Forms.Label + Friend WithEvents lblPrincipal As System.Windows.Forms.Label + Friend WithEvents lblBackupRestorePath As System.Windows.Forms.Label + Friend WithEvents txtBackupRestorePath As System.Windows.Forms.TextBox + Friend WithEvents timerMirroring As System.Windows.Forms.Timer + Friend WithEvents btnTurnOff As System.Windows.Forms.Button + Friend WithEvents lblConnectedServer As System.Windows.Forms.Label + Friend WithEvents lblConnectedServerText As System.Windows.Forms.Label + Friend WithEvents lblDataFlowText As System.Windows.Forms.Label + +End Class diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmMain.resx b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmMain.resx new file mode 100644 index 0000000..a85ac79 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmMain.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmMain.vb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmMain.vb new file mode 100644 index 0000000..699337d --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmMain.vb @@ -0,0 +1,529 @@ +Imports System.Data.SqlClient + +Public Class frmMain + + Dim sqlConnection As New SqlConnection + Dim sqlCommand As New SqlCommand + Dim strConnectionStringPrincipal As String = "" + Dim strConnectionStringMirror As String = "" + Dim strConnectionStringWitness As String = "" + Dim strPrincipalName As String = "" + Dim strMirrorName As String = "" + Dim strWitnessName As String = "" + Dim strDatabaseName As String = "" + Dim strBackupRestorePath As String = "" + Dim iPubsCounter As Integer = 9901 + + Private Sub btnSelectDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectDB.Click + 'Bring up a list of databases off the Principal Server + 'Launch the Select Database Form + Me.Hide() + frmSelectDB.Show() + + End Sub + + Private Sub btnSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetup.Click + 'Attempt to setup mirroring based on the information provided by the user + 'The application will backup to the root of C:/ and restore the database to + 'the root of C:/ + + 'Set the cursor so the user knows we're working + Me.Cursor = System.Windows.Forms.Cursors.WaitCursor + + 'First, connect to the Principal and make sure it's in Full Recovery Mode + + + Dim boolError As Boolean = False + Dim strSQL As String = "" + strDatabaseName = lblDatabaseName.Text() + strPrincipalName = txtPrincipalServer.Text() + strMirrorName = txtMirrorServer.Text() + strWitnessName = txtWitnessServer.Text() + strBackupRestorePath = txtBackupRestorePath.Text() + + 'Create our connection string + strConnectionStringPrincipal = "Initial Catalog = " & strDatabaseName & _ + ";Data Source = " & strPrincipalName & ";Trusted_Connection=Yes;" + + 'Attempt to make it full recovery + strSQL = "ALTER DATABASE [" & strDatabaseName & "] SET RECOVERY FULL;" + boolError = ExecuteNonQuery(strConnectionStringPrincipal, strSQL) + If (boolError) Then + MsgBox("Error making recovery model full for principal. Exiting setup.") + SetCursorBack() + Exit Sub + Else + MsgBox("Success! Recovery model set to full.") + End If + + 'Backup the database + strSQL = "BACKUP DATABASE [" & strDatabaseName & "] TO DISK = N'" & strBackupRestorePath & _ + strDatabaseName & ".bak' WITH NOFORMAT, INIT, NAME = N'" & strDatabaseName & _ + "-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10" + boolError = ExecuteNonQuery(strConnectionStringPrincipal, strSQL) + If (boolError) Then + MsgBox("Error backing up principal. Exiting setup.") + SetCursorBack() + Exit Sub + Else + MsgBox("Success! " & strDatabaseName & " successfully backed up.") + End If + + 'Restore the database to the mirror + strConnectionStringMirror = "Initial Catalog = Master" & _ + ";Data Source = " & strMirrorName & ";Trusted_Connection=Yes;" + + strSQL = "RESTORE DATABASE [" & strDatabaseName & "] FROM DISK = N'" & strBackupRestorePath & _ + strDatabaseName & ".bak' WITH FILE = 1, MOVE N'" & _ + strDatabaseName & "' TO N'" & strBackupRestorePath & strDatabaseName & ".mdf', MOVE N'" & _ + strDatabaseName & "_log' TO N'C:\" & strDatabaseName & ".ldf', " & _ + "NORECOVERY, NOUNLOAD, REPLACE, STATS = 10" + boolError = ExecuteNonQuery(strConnectionStringMirror, strSQL) + If (boolError) Then + MsgBox("Error restoring to mirror. Exiting setup.") + SetCursorBack() + Exit Sub + Else + MsgBox("Success! " & strDatabaseName & " restored to mirror.") + End If + + 'Create the endpoints. Start on the principal + + 'See if the endpoint already exists and if so, drop it + 'since we can only have one mirroring endpoint per server + strSQL = "SELECT name from sys.endpoints WHERE name = 'MirroringPrincipalSampleEndPoint'" + + Dim strReturnValue As String = CStr(ExecuteScalar(strConnectionStringPrincipal, strSQL)) + If strReturnValue = "MirroringPrincipalSampleEndPoint" Then + 'It exists, drop it + strSQL = "DROP ENDPOINT MirroringPrincipalSampleEndPoint" + boolError = ExecuteNonQuery(strConnectionStringPrincipal, strSQL) + If (boolError) Then + MsgBox("Error dropping endpoint on the Principal. Exiting setup.") + SetCursorBack() + Exit Sub + End If + End If + + + Dim strPrincipalPort As String = RetrievePortNumber(txtPrincipalEndPoint.Text) + + strSQL = "CREATE ENDPOINT [MirroringPrincipalSampleEndPoint] STATE = STARTED" & _ + " AS TCP (LISTENER_PORT = " & strPrincipalPort & ", LISTENER_IP = ALL," & _ + " RESTRICT_IP=NONE) FOR DATABASE_MIRRORING (ROLE = PARTNER," & _ + " ENCRYPTION = DISABLED)" + + 'Create the endpoint + boolError = ExecuteNonQuery(strConnectionStringPrincipal, strSQL) + If (boolError) Then + MsgBox("Error creating endpoint on the Principal. Exiting setup.") + SetCursorBack() + Exit Sub + Else + MsgBox("Success! Created endpoint on Principal.") + End If + + 'Create the mirror endpoint + 'If it exists, drop it + strSQL = "SELECT name from sys.endpoints WHERE name = 'MirroringMirrorSampleEndPoint'" + + strReturnValue = CStr(ExecuteScalar(strConnectionStringMirror, strSQL)) + If strReturnValue = "MirroringMirrorSampleEndPoint" Then + 'It exists, drop it + strSQL = "DROP ENDPOINT MirroringMirrorSampleEndPoint" + boolError = ExecuteNonQuery(strConnectionStringMirror, strSQL) + If (boolError) Then + MsgBox("Error dropping endpoint on the Mirror. Exiting setup.") + SetCursorBack() + Exit Sub + End If + End If + + + Dim strMirrorPort As String = RetrievePortNumber(txtMirrorEndPoint.Text) + + strSQL = "CREATE ENDPOINT [MirroringMirrorSampleEndPoint] STATE = STARTED" & _ + " AS TCP (LISTENER_PORT = " & strMirrorPort & ", LISTENER_IP = ALL," & _ + " RESTRICT_IP=NONE) FOR DATABASE_MIRRORING (ROLE = PARTNER," & _ + " ENCRYPTION = DISABLED)" + + 'Create the endpoint + boolError = ExecuteNonQuery(strConnectionStringMirror, strSQL) + If (boolError) Then + MsgBox("Error creating endpoint on the Mirror. Exiting setup.") + SetCursorBack() + Exit Sub + Else + MsgBox("Success! Created endpoint on Mirror.") + End If + + + strConnectionStringWitness = "Initial Catalog = Master" & _ + ";Data Source = " & strWitnessName & ";Trusted_Connection=Yes;" + + 'Check to see if they want to use a witness. + If checkWitness.Checked = True Then + + 'Create the witness endpoint + 'If it exists, drop it + strSQL = "SELECT name from sys.endpoints WHERE name = 'MirroringWitnessSampleEndPoint'" + + strReturnValue = CStr(ExecuteScalar(strConnectionStringWitness, strSQL)) + If strReturnValue = "MirroringWitnessSampleEndPoint" Then + 'It exists, drop it + strSQL = "DROP ENDPOINT MirroringWitnessSampleEndPoint" + boolError = ExecuteNonQuery(strConnectionStringWitness, strSQL) + If (boolError) Then + MsgBox("Error dropping endpoint on the Witness. Exiting setup.") + SetCursorBack() + Exit Sub + End If + End If + + + Dim strWitnessPort As String = RetrievePortNumber(txtWitnessEndPoint.Text) + + strSQL = "CREATE ENDPOINT [MirroringWitnessSampleEndPoint] STATE = STARTED" & _ + " AS TCP (LISTENER_PORT = " & strWitnessPort & ", LISTENER_IP = ALL," & _ + " RESTRICT_IP=NONE) FOR DATABASE_MIRRORING (ROLE = WITNESS," & _ + " ENCRYPTION = DISABLED)" + + 'Create the endpoint + boolError = ExecuteNonQuery(strConnectionStringWitness, strSQL) + If (boolError) Then + MsgBox("Error creating endpoint on the Witness. Exiting setup.") + SetCursorBack() + Exit Sub + Else + MsgBox("Success! Created endpoint on Witness.") + End If + + End If + + 'Alter the mirror database to set the partner + strSQL = "ALTER DATABASE " & strDatabaseName & " SET PARTNER = '" & txtPrincipalEndPoint.Text & "'" + + boolError = ExecuteNonQuery(strConnectionStringMirror, strSQL) + If (boolError) Then + MsgBox("Error setting partner on the Mirror. Exiting setup.") + SetCursorBack() + Exit Sub + Else + MsgBox("Success! Set partner on the mirror.") + End If + + + 'Alter the principal database to set the partner + strSQL = "ALTER DATABASE " & strDatabaseName & " SET PARTNER = '" & txtMirrorEndPoint.Text & "'" + + boolError = ExecuteNonQuery(strConnectionStringPrincipal, strSQL) + If (boolError) Then + MsgBox("Error setting partner on the Principal. Exiting setup.") + SetCursorBack() + Exit Sub + Else + MsgBox("Success! Set partner on the principal.") + End If + + + 'Check to see if they want to use a witness. + If checkWitness.Checked = True Then + 'Set Witness + strSQL = "ALTER DATABASE " & strDatabaseName & " SET WITNESS = '" & txtWitnessEndPoint.Text & "'" + + boolError = ExecuteNonQuery(strConnectionStringPrincipal, strSQL) + If (boolError) Then + MsgBox("Error setting witness on the Principal. Exiting setup.") + SetCursorBack() + Exit Sub + Else + MsgBox("Success! Set witness on the principal.") + End If + + + End If + + + 'Set the timer interval and turn it on + timerMirroring.Interval = Int(listInterval.SelectedItem) * 1000 + timerMirroring.Enabled = True + + 'Enable the Fail and Turn Off controls + btnFail.Enabled = True + btnTurnOff.Enabled = True + + SetCursorBack() + End Sub + Private Function RetrievePortNumber(ByVal strTCPAddress As String) As String + 'Parse out the port from the endpoint string in the UI + Dim iColon As Integer = InStr(strTCPAddress, ":") + 'That's the first colon, go to the second one + iColon = InStr(iColon + 1, strTCPAddress, ":") + + + 'Take everything to the right of the colon + RetrievePortNumber = Mid(strTCPAddress, iColon + 1) + + End Function + Private Sub SetCursorBack() + Me.Cursor = System.Windows.Forms.Cursors.Default + End Sub + Private Function ExecuteNonQuery(ByVal strConnectString As String, ByVal strSQLCommand As String) As Boolean + Dim strSQL As String = "" + Dim sqlConnection As New SqlConnection(strConnectString) + + Try + With sqlConnection + .Open() + Dim sqlCommand As New SqlCommand(strSQLCommand, sqlConnection) + sqlCommand.ExecuteNonQuery() + 'Close the connection + .Close() + ExecuteNonQuery = False + End With + + Catch + MsgBox("Error! Error#" & Err.Number & " Description: " & Err.Description) + 'Close our connection + sqlConnection.Close() + ExecuteNonQuery = True + End Try + + End Function + Private Function ExecuteNonQueryForMirror(ByVal strConnectString As String, ByVal strSQLCommand As String) As Boolean + 'Execute non-query after mirror is established + + Dim strSQL As String = "" + Dim sqlConnection As New SqlConnection(strConnectString) + + Try + With sqlConnection + .Open() + 'Write out the datasource of the connection to see + 'if we're talking to the prinicipal or the mirror + lblConnectedServerText.Text = sqlConnection.DataSource() + + Dim sqlCommand As New SqlCommand(strSQLCommand, sqlConnection) + sqlCommand.ExecuteNonQuery() + + + 'Close the connection + .Close() + ExecuteNonQueryForMirror = False + End With + + Catch + MsgBox("Error! Error#" & Err.Number & " Description: " & Err.Description) + 'Close our connection + sqlConnection.Close() + ExecuteNonQueryForMirror = True + End Try + + End Function + Private Function ExecuteScalar(ByVal strConnectString As String, ByVal strSQLCommand As String) As Object + Dim strSQL As String = "" + Dim sqlConnection As New SqlConnection(strConnectString) + + Try + With sqlConnection + .Open() + Dim sqlCommand As New SqlCommand(strSQLCommand, sqlConnection) + Dim oReturnValue As Object = sqlCommand.ExecuteScalar() + 'Close the connection + .Close() + If IsDBNull(oReturnValue) Then + oReturnValue = "" + End If + ExecuteScalar = oReturnValue + End With + + Catch + MsgBox("Error! Error#" & Err.Number & " Description: " & Err.Description) + 'Close our connection + sqlConnection.Close() + ExecuteScalar = True + End Try + + End Function + Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'REMOVE THIS! + txtPrincipalServer.Text = "thomrizwinxp6" + txtMirrorServer.Text = "thomrizwinxp6\server2" + txtWitnessServer.Text = "thomrizwinxp6\server3" + + txtPrincipalEndPoint.Text = "TCP://thomrizwinxp6.redmond.corp.microsoft.com:6000" + txtMirrorEndPoint.Text = "TCP://thomrizwinxp6.redmond.corp.microsoft.com:6001" + txtWitnessEndPoint.Text = "TCP://thomrizwinxp6.redmond.corp.microsoft.com:6002" + txtBackupRestorePath.Text = "C:\" + + listInterval.SelectedItem = "5" + End Sub + + Private Sub timerMirroring_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timerMirroring.Tick + SetDBMirrorStatusandPrincipal() + InsertDataIntoDatabase() + + End Sub + Private Sub InsertDataIntoDatabase() + Dim strSQL As String = "" + Dim boolError As Boolean = False + + strConnectionStringPrincipal = "Initial Catalog = " & strDatabaseName & _ + ";Data Source = " & strPrincipalName & ";Trusted_Connection=Yes;" + + If UCase(strDatabaseName) = "PUBS" Then + 'Insert data into pubs + 'Increment the counter + iPubsCounter += 1 + strSQL = "INSERT INTO [publishers] (pub_id, pub_name, city, state, country)" & _ + " VALUES ('" & CStr(iPubsCounter) & "','Test','Test','WA','Test')" + + boolError = ExecuteNonQueryForMirror(strConnectionStringPrincipal, strSQL) + If (boolError) Then + lblDataFlowText.Text = "Error inserting data." + Else + lblDataFlowText.Text = "Added publisher #" & iPubsCounter + End If + + End If + End Sub + Private Sub SetDBMirrorStatusandPrincipal() + 'Try to query the principal to get the status of the database mirroring + Dim strReturnValue As String = "" + Dim strSQL As String = "" + + strConnectionStringPrincipal = "Initial Catalog = Master" & _ + ";Data Source = " & strPrincipalName & ";Trusted_Connection=Yes;" + + + 'First, get the state description + strSQL = "SELECT mirroring_state_desc from sys.databases WHERE name = '" & strDatabaseName & "'" + + strReturnValue = ExecuteScalar(strConnectionStringPrincipal, strSQL) + If strReturnValue = "" Then + strReturnValue = "Unconfigured" + End If + lblDBMirrorStatusText.Text = strReturnValue + + + 'Get the Principal's role + strSQL = "SELECT mirroring_role_desc from sys.databases WHERE name = '" & strDatabaseName & "'" + + strReturnValue = ExecuteScalar(strConnectionStringPrincipal, strSQL) + If strReturnValue = "" Then + strReturnValue = "Unconfigured" + End If + + lblPrincipalText.Text = strReturnValue + + End Sub + Private Sub btnTurnOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTurnOff.Click + Dim boolError As Boolean = False + Dim strSQL As String = "" + Dim boolError2 As Boolean = False + + If strMirrorName = "" Then + 'Set the mirror name + strMirrorName = txtMirrorServer.Text() + End If + + If strDatabaseName = "" Then + MsgBox("Please select a database first.") + Exit Sub + End If + + 'Disable the timer + timerMirroring.Enabled = False + + + 'Try to delete the new records in pubs + strConnectionStringPrincipal = "Initial Catalog = " & strDatabaseName & _ + ";Data Source = " & strPrincipalName & ";Trusted_Connection=Yes;" + + strSQL = "SELECT mirroring_role_desc FROM sys.databases WHERE name = '" & strDatabaseName & "'" + Dim strRole As String = ExecuteScalar(strConnectionStringPrincipal, strSQL) + strSQL = "DELETE FROM publishers WHERE pub_name = 'Test'" + + If (boolError) Then + 'Something wrong, must be down + 'Try to failover mirror + boolError2 = ExecuteNonQuery(strConnectionStringMirror, strSQL) + Else + If UCase(strRole) = "PRINCIPAL" Then + boolError2 = ExecuteNonQuery(strConnectionStringPrincipal, strSQL) + Else + boolError2 = ExecuteNonQuery(strConnectionStringMirror, strSQL) + End If + End If + + If (boolError2) Then + MsgBox("Error trying to delete added records to pubs.") + Else + MsgBox("Success deleting added records to pubs.") + End If + + + 'Attempt to turn off mirroring + strConnectionStringMirror = "Initial Catalog = Master" & _ + ";Data Source = " & strMirrorName & ";Trusted_Connection=Yes;" + + strSQL = "ALTER DATABASE [" & strDatabaseName & "] SET PARTNER OFF" + + 'Talk to the mirror just in case they failed mirror over to principal + boolError = ExecuteNonQuery(strConnectionStringMirror, strSQL) + If (boolError) Then + MsgBox("Error turning off Database Mirroring. Exiting.") + Exit Sub + Else + MsgBox("Success! Mirroring turned off.") + lblDBMirrorStatusText.Text = "Unconfigured" + lblConnectedServerText.Text = "Unconfigured" + lblPrincipalText.Text = "Unconfigured" + End If + + + + + End Sub + Friend Sub SetDatabaseName() + strDatabaseName = lblDatabaseName.Text() + End Sub + + Private Sub btnFail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFail.Click + 'Fail over to the mirror by figuring out the current principal + 'Connect to the principal and see if it's still the principal + Dim strSQL As String = "" + Dim boolError As Boolean = False + Dim boolError2 As Boolean = False + + strConnectionStringPrincipal = "Initial Catalog = Master" & _ + ";Data Source = " & strPrincipalName & ";Trusted_Connection=Yes;" + + + + strSQL = "SELECT mirroring_role_desc FROM sys.databases WHERE name = '" & strDatabaseName & "'" + Dim strRole As String = ExecuteScalar(strConnectionStringPrincipal, strSQL) + strSQL = "ALTER DATABASE [" & strDatabaseName & "] SET PARTNER FAILOVER" + + If (boolError) Then + 'Something wrong, must be down + 'Try to failover mirror + boolError2 = ExecuteNonQuery(strConnectionStringMirror, strSQL) + Else + If UCase(strRole) = "PRINCIPAL" Then + boolError2 = ExecuteNonQuery(strConnectionStringPrincipal, strSQL) + Else + boolError2 = ExecuteNonQuery(strConnectionStringMirror, strSQL) + End If + End If + + End Sub + + + Private Sub lblDatabaseName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblDatabaseName.TextChanged + If lblDatabaseName.Text <> "" Then + 'Enable the setup control + btnSetup.Enabled = True + End If + End Sub +End Class diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmSelectDB.Designer.vb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmSelectDB.Designer.vb new file mode 100644 index 0000000..2f3cc0b --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmSelectDB.Designer.vb @@ -0,0 +1,91 @@ +Partial Public Class frmSelectDB + Inherits System.Windows.Forms.Form + + _ + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + End Sub + + 'Form overrides dispose to clean up the component list. + _ + Protected Overloads 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.lblDBSelect = New System.Windows.Forms.Label + Me.listDatabases = New System.Windows.Forms.ListBox + Me.btnOK = New System.Windows.Forms.Button + Me.btnCancel = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'lblDBSelect + ' + Me.lblDBSelect.AutoSize = True + Me.lblDBSelect.Location = New System.Drawing.Point(12, 0) + Me.lblDBSelect.Name = "lblDBSelect" + Me.lblDBSelect.Size = New System.Drawing.Size(273, 27) + Me.lblDBSelect.TabIndex = 0 + Me.lblDBSelect.Text = "Please select a database to mirror from the list below:" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "(This sample only works " & _ + "with pubs)" + ' + 'listDatabases + ' + Me.listDatabases.FormattingEnabled = True + Me.listDatabases.Location = New System.Drawing.Point(12, 32) + Me.listDatabases.Name = "listDatabases" + Me.listDatabases.Size = New System.Drawing.Size(536, 407) + Me.listDatabases.TabIndex = 1 + ' + 'btnOK + ' + Me.btnOK.Location = New System.Drawing.Point(12, 445) + Me.btnOK.Name = "btnOK" + Me.btnOK.TabIndex = 2 + Me.btnOK.Text = "&OK" + ' + 'btnCancel + ' + Me.btnCancel.Location = New System.Drawing.Point(93, 445) + Me.btnCancel.Name = "btnCancel" + Me.btnCancel.TabIndex = 3 + Me.btnCancel.Text = "&Cancel" + ' + 'frmSelectDB + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) + Me.ClientSize = New System.Drawing.Size(567, 507) + Me.Controls.Add(Me.btnCancel) + Me.Controls.Add(Me.btnOK) + Me.Controls.Add(Me.listDatabases) + Me.Controls.Add(Me.lblDBSelect) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "frmSelectDB" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Select Database" + Me.TopMost = True + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents lblDBSelect As System.Windows.Forms.Label + Friend WithEvents listDatabases As System.Windows.Forms.ListBox + Friend WithEvents btnOK As System.Windows.Forms.Button + Friend WithEvents btnCancel As System.Windows.Forms.Button +End Class diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmSelectDB.vb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmSelectDB.vb new file mode 100644 index 0000000..f281f37 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/frmSelectDB.vb @@ -0,0 +1,90 @@ +Imports System.Data.SqlClient + +Public Class frmSelectDB + Dim strDatabaseServerName As String = "" + Dim strConnectionString As String = "" + Dim strSQL As String = "" + + + Private Sub frmSelectDB_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed + frmMain.Show() + End Sub + + Private Sub frmSelectDB_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.GotFocus + + + End Sub + + + Private Sub frmSelectDB_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Attempt to open connection to the principal database from main + strDatabaseServerName = frmMain.txtPrincipalServer.Text() + strConnectionString = "Initial Catalog = Master;Data Source = " & strDatabaseServerName & ";Trusted_Connection=Yes;" + strSQL = "SELECT name FROM sys.databases" + Dim sqlConnection As New SqlConnection(strConnectionString) + Dim sqlDataAdapter As New SqlDataAdapter + + sqlDataAdapter.SelectCommand = New SqlCommand(strSQL, sqlConnection) + Try + With sqlConnection + .Open() + Dim sqlDS As System.Data.DataSet = New System.Data.DataSet("Databases") + sqlDataAdapter.Fill(sqlDS) + Dim tRow As System.Data.DataRow + For Each tRow In sqlDS.Tables.Item(0).Rows + 'Make sure to not include Master, Tempdb, Model and msdb + If Not (UCase(tRow("Name")) = "MASTER" Or UCase(tRow("Name")) = "TEMPDB" Or UCase(tRow("Name")) = "MODEL" Or UCase(tRow("Name")) = "MSDB") Then + listDatabases.Items.Add(tRow("Name").ToString()) + End If + Next + 'Close the connection + .Close() + End With + + Catch + MsgBox("Error! Error#" & Err.Number & " Description: " & Err.Description) + 'Close our connection + sqlConnection.Close() + listDatabases.Items.Add("Error. Please close form and try again.") + listDatabases.Enabled = False + + End Try + End Sub + + Private Sub listDatabases_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles listDatabases.DoubleClick + If UCase(listDatabases.SelectedItem.ToString()) = "PUBS" Then + Else + MsgBox("This application only works with pubs.") + Exit Sub + End If + Me.Hide() + SetDatabaseNameLabel() + frmMain.Show() + End Sub + + Private Sub listDatabases_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listDatabases.SelectedIndexChanged + + End Sub + Private Sub SetDatabaseNameLabel() + 'Return back the name of the database + frmMain.lblDatabaseName.Text = listDatabases.Items.Item(listDatabases.SelectedIndex()).ToString() + frmMain.SetDatabaseName() + End Sub + + Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click + Me.Hide() + frmMain.Show() + End Sub + + Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click + If UCase(listDatabases.SelectedItem.ToString()) = "PUBS" Then + Else + MsgBox("This application only works with pubs.") + Exit Sub + End If + + Me.Hide() + SetDatabaseNameLabel() + frmMain.Show() + End Sub +End Class \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/DatabaseMirroring.vbproj.FileList.txt b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/DatabaseMirroring.vbproj.FileList.txt new file mode 100644 index 0000000..07adbf4 --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/DatabaseMirroring.vbproj.FileList.txt @@ -0,0 +1,11 @@ +bin\DatabaseMirroring.exe.config +obj\Debug\DatabaseMirroring.exe +obj\Debug\DatabaseMirroring.xml +obj\Debug\DatabaseMirroring.pdb +bin\DatabaseMirroring.exe +bin\DatabaseMirroring.pdb +bin\DatabaseMirroring.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\DatabaseMirroring.frmMain.resources +obj\Debug\DatabaseMirroring.MyResources.resources +obj\Debug\DatabaseMirroring.vbproj.GenerateResource.Cache diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.MyResources.resources b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.MyResources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.MyResources.resources differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.exe b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.exe new file mode 100644 index 0000000..59c890d Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.exe differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.frmMain.resources b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.frmMain.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.frmMain.resources differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.pdb b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.pdb new file mode 100644 index 0000000..f4d5d8a Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.pdb differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.vbproj.GenerateResource.Cache b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..9683bca Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.vbproj.GenerateResource.Cache differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.xml b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.xml new file mode 100644 index 0000000..e20b78b --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/DatabaseMirroring.xml @@ -0,0 +1,11 @@ + + + + +DatabaseMirroring + + + + + + \ No newline at end of file diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/ResGen.cache b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/ResGen.cache new file mode 100644 index 0000000..c3fbee5 Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/ResGen.cache differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/TempPE/My Project.MyResources.vb.dll b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/TempPE/My Project.MyResources.vb.dll new file mode 100644 index 0000000..4acf81f Binary files /dev/null and b/1590594770-1/Chapter15/DatabaseMirroring/DatabaseMirroring/obj/Debug/TempPE/My Project.MyResources.vb.dll differ diff --git a/1590594770-1/Chapter15/DatabaseMirroring/readme.txt b/1590594770-1/Chapter15/DatabaseMirroring/readme.txt new file mode 100644 index 0000000..0db960b --- /dev/null +++ b/1590594770-1/Chapter15/DatabaseMirroring/readme.txt @@ -0,0 +1,14 @@ +The Database Mirroring sample shows you how to deploy and test Database Mirroring. + +Please note that you must have the Pubs database on your server in order for the sample application to work and have enabled database mirroring using the 1400 trace flag. Please refer to the chapter on how to turn on database mirroring using the trace flag. + +To download the pubs database, please download the scripts for Pubs from the following location http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&displaylang=en + + +To run the application, perform the following steps: + +1) Double click the DatabaseMirroring.sln file to load the application into Visual Studio 2005. + +2) Hit ctrl-F5 to start the application without debugging. + +3) Follow the instructions on the screen to configure and test Database Mirroring. diff --git a/2436.pdf b/2436.pdf new file mode 100644 index 0000000..76d4621 Binary files /dev/null and b/2436.pdf differ diff --git a/2437.pdf b/2437.pdf new file mode 100644 index 0000000..2b23169 Binary files /dev/null and b/2437.pdf differ diff --git a/2898.html b/2898.html new file mode 100644 index 0000000..256bbcf --- /dev/null +++ b/2898.html @@ -0,0 +1 @@ + Pro SQL Server 2005

Pro SQL Server 2005

 

ISSUE: Ch. 3 (p. 53) First sentence of 2nd paragraph: "In this chapter, we have grouped the changes into four major categories:"
There are only 3 bullet points instead of the expected 4. Also, bullet point 3 refers to the DDL, but this isn't really covered until Ch. 4.

 

SOLUTION: Ch. 3 (p. 53) First sentence of 2nd paragraph, should read, ÒIn this chapter, we will look at the changes that have been made to T-SQL with a focus on developers.  These changes fall into two major categories:

  *          Data Manipulation Language (DML): Changes to the base T-SQL statements used to manipulate data

  *          General development: Changes to some of the basic tools of programming, such as much improved error handling. Ò

Issue: Discussion regarding ÒSurface Area ConfiguratorÓ

Solution: Chapter 2, Page 45: Surface Area Configurator should be Surface Area Configuration (which is the actual name of the tool).

 

Issue: About Random Sampling: It should be pointed out that the sample is not truly random, as it reads whole pages only. This is also the reason why the number of rows/percent returned may not match.

Solution: This is clearly a misunderstanding of the meaning of the term "random". TABLESAMPLE reads random pages and therefore the sample is random.

 

Issue: Chapter 5, Page 150: SQL string should be "TerritoryID", not "TerritoryId". Same for the sample code. This occurs 3 times and results in errors when executing the stored procedure from within SQL Server Management Studio.

Solution: This is a problem only if your server or database is set to a case-sensitive collation.

Issue: Chapter 6, Page 195:

 

 "It is important to understand when dealing with aggregates that the intermediate result will be serialized and deserialized once per row of aggregated data."

 

This should be changed to:

 

"It is important to understand when dealing with aggregates that the intermediate result can be serialized and deserialized many times during the course of data aggregation."

 

Issue: Chap 7 page 229.  Your definition of IgnoreDuplicateKeys is just plain off.  Refer to BOL.

 

Solution: A Boolean property that specifies whether to ignore when duplicate keys are being inserted into the table.  The default value is false, which means that attempts to insert a duplicate key will result in an error and cause the Bulk Load to fail.  If you set this property to true and there is a duplicate key, the duplicate record will not be inserted into the table and you will not receive an error.

 

 

Errata

Issue: Chapter 1 Page 9:
Table 1-5 states that Standard Edition is not supported on Windows XP Pro SP2, this is wrong.
Table 1-6 states that IA64-editions can be installed on X64 platform, this is wrong.
There is no table for the X64-platform.

 

Issue: Chapter 1, Page 9

Table 1-5,Line 7 in the table. This table contains  Operating Systems that SQL Server 2005  Editions may be installed on. Line 7 is for Windows XP Professional SP2. The checkmark is absent in the column for Standard Edition, which means that Standard Edition could not be installed on Windows XP SP2. But Microsoft Web Page at http://www.microsoft.com/sql/editions/standard/sysreqs.mspx

"SQL Server 2005 Standard Edition System Requirements"

says: "...Microsoft Windows 2000 Server with Service Pack (SP) 4 or later; Windows 2000 Professional Edition with SP 4 or later; Windows XP with SP 2 or later; Windows Server 2003 Enterprise Edition, Standard Edition, or Datacenter Edition with SP 1 or later; Windows Small Business Server 2003 with SP 1 or later..." which means that we can install Standard Edition on Windows XP SP2

 

Issue: Chapter 10, Page 353

Description of the problem: The first word on the page is demoralized. "Demoralized" should be changed to "denormalized".

 

Issue: Chapter 10, Page350

Description of the problem: at the bottom of the page it says (what is referred to as a START or Snowflake schema). "Start" should be changed to "star".

\ No newline at end of file diff --git a/9781590594773.jpg b/9781590594773.jpg new file mode 100644 index 0000000..2a3a5c4 Binary files /dev/null and b/9781590594773.jpg differ diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..88efe22 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2006 Robin Dewson, Adam Machanic, Jan D. Narkiewicz, Thomas Rizzo, Joseph Sack, Robert Walters, Julian Skinner, and Louis Davidson + +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..99e2394 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*Pro SQL Server 2005*](http://www.apress.com/9781590594773) by Robin Dewson, Adam Machanic, Jan D. Narkiewicz, Thomas Rizzo, Joseph Sack, Robert Walters, Julian Skinner, and Louis Davidson (Apress, 2006). + +![Cover image](9781590594773.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/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file