Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Apress
committed
Oct 7, 2016
0 parents
commit 050f1d2
Showing
319 changed files
with
24,773 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Binary file not shown.
105 changes: 105 additions & 0 deletions
105
1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Form1.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
108 changes: 108 additions & 0 deletions
108
1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Form1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
|
||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// The main entry point for the application. | ||
/// </summary> | ||
[STAThread] | ||
static void Main() | ||
{ | ||
Application.EnableVisualStyles(); | ||
//Application.EnableRTLMirroring(); | ||
Application.Run(new Form1()); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.*")] |
61 changes: 61 additions & 0 deletions
61
1590594770-1/Chapter02/SMO Sample CSharp/SMO Sample CSharp/Properties/Resources.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
//------------------------------------------------------------------------------ | ||
// <autogenerated> | ||
// 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. | ||
// </autogenerated> | ||
//------------------------------------------------------------------------------ | ||
|
||
namespace SMO_Sample_CSharp.Properties { | ||
using System; | ||
using System.IO; | ||
using System.Resources; | ||
|
||
|
||
/// <summary> | ||
/// A strongly-typed resource class, for looking up localized strings, etc. | ||
/// </summary> | ||
// 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() { | ||
} | ||
|
||
/// <summary> | ||
/// Returns the cached ResourceManager instance used by this class. | ||
/// </summary> | ||
[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; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Overrides the current thread's CurrentUICulture property for all | ||
/// resource lookups using this strongly typed resource class. | ||
/// </summary> | ||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] | ||
public static System.Globalization.CultureInfo Culture { | ||
get { | ||
return _resCulture; | ||
} | ||
set { | ||
_resCulture = value; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.