Skip to content

Commit 6727b1d

Browse files
committed
Cleanup and Re-Syncing of Repository files
1 parent eaafce2 commit 6727b1d

25 files changed

Lines changed: 886 additions & 1066 deletions

README.md

Lines changed: 141 additions & 147 deletions
Large diffs are not rendered by default.

api.guide.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# API Guide and Class Documentation
2+
3+
## Table of Contents
4+
5+
- [Functions](#functions)
6+
- [Dismount-Database](#dismount-database)
7+
- [Get-Database](#get-database)
8+
- [Get-DatabaseTable](#get-database-table)
9+
- [Invoke-DatabaseNonQuery](#invoke-database-non-query)
10+
- [Invoke-DatabaseQuery](#invoke-database-query)
11+
- [Mount-Database](#mount-database)
12+
- [New-SqlQueryDataSet](#new-sql-query-data-set)
13+
- [Classes](#classes)
14+
- [SqlQueryDataSet Parent Class Details](#sql-query-data-set-parent-class-details)
15+
- [Class SqlQueryDataSet Properties](#class-sql-query-data-set-properties)
16+
- [Class SqlQueryDataSet Methods](#class-sql-query-data-set-methods)
17+
- [Child Class SqlQueryTable Properties](#child-class-sql-query-table-properties)
18+
- [Child Class SqlQueryTable Methods](#child-class-sql-query-table-methods)
19+
20+
## Functions
21+
22+
```powershell
23+
Get-Command -Module "SqlQueryClass" -Syntax
24+
25+
- Dismount-Database [[-connectionString] <Object>] [[-Database] <Object>] [-Quiet]
26+
- Get-Database [[-connectionString] <Object>] [[-query] <Object>] [-Quiet]
27+
- Get-DatabaseTable [[-connectionString] <Object>] [[-query] <Object>] [-Quiet]
28+
- Invoke-DatabaseNonQuery [[-connectionString] <Object>] [[-NonQuery] <Object>] [-Quiet]
29+
- Invoke-DatabaseQuery [[-connectionString] <Object>] [[-query] <Object>] [-Quiet]
30+
- Mount-Database [[-connectionString] <Object>] [[-Database] <Object>] [[-DatabaseFilePath] <Object>] [-Quiet]
31+
- New-SqlQueryDataSet [[-SQLServer] <string>] [[-Database] <string>] [[-ConnectionString] <string>] [[-Query] <string>] [[-TableName] <string>] [[-DisplayResults] <bool>] [<CommonParameters>]
32+
```
33+
34+
New-SqlQueryDataSet is the Constructor method for creating an instance of Parent Class [SqlQueryDataSet] and is the main cmdlet.
35+
36+
To see the examples, type: "Get-Help New-SqlQueryDataSet -Examples"
37+
For more information, type: "Get-Help New-SqlQueryDataSet -Detailed"
38+
For technical information, type: "Get-Help New-SqlQueryDataSet -Full"
39+
40+
### Dismount-Database
41+
42+
```powershell
43+
NAME
44+
Dismount-Database
45+
SYNTAX
46+
Dismount-Database [[-connectionString] <Object>] [[-Database] <Object>] [-Quiet]
47+
DESCRIPTION
48+
Detaches a database from the SQL Server.
49+
PARAMETERS
50+
-connectionString: The connection string to the SQL Server.
51+
-Database: The name of the database to detach.
52+
-Quiet: Suppresses output.
53+
```
54+
55+
### Get-Database
56+
57+
```powershell
58+
NAME
59+
Get-Database
60+
SYNTAX
61+
Get-Database [[-connectionString] <Object>] [[-query] <Object>] [-Quiet]
62+
DESCRIPTION
63+
Executes a query against the SQL Server and returns the results.
64+
PARAMETERS
65+
-connectionString: The connection string to the SQL Server.
66+
-query: The SQL query to execute.
67+
-Quiet: Suppresses output.
68+
```
69+
70+
### Get-DatabaseTable
71+
72+
```powershell
73+
NAME
74+
Get-DatabaseTable
75+
SYNTAX
76+
Get-DatabaseTable [[-connectionString] <Object>] [[-query] <Object>] [-Quiet]
77+
DESCRIPTION
78+
Executes a query against the SQL Server and returns the results as a table.
79+
PARAMETERS
80+
-connectionString: The connection string to the SQL Server.
81+
-query: The SQL query to execute.
82+
-Quiet: Suppresses output.
83+
```
84+
85+
### Invoke-DatabaseNonQuery
86+
87+
```powershell
88+
NAME
89+
Invoke-DatabaseNonQuery
90+
SYNTAX
91+
Invoke-DatabaseNonQuery [[-connectionString] <Object>] [[-NonQuery] <Object>] [-Quiet]
92+
DESCRIPTION
93+
Executes a non-query SQL command against the SQL Server.
94+
PARAMETERS
95+
-connectionString: The connection string to the SQL Server.
96+
-NonQuery: The non-query SQL command to execute.
97+
-Quiet: Suppresses output.
98+
```
99+
100+
### Invoke-DatabaseQuery
101+
102+
```powershell
103+
NAME
104+
Invoke-DatabaseQuery
105+
SYNTAX
106+
Invoke-DatabaseQuery [[-connectionString] <Object>] [[-query] <Object>] [-Quiet]
107+
DESCRIPTION
108+
Executes a query against the SQL Server and returns the results.
109+
PARAMETERS
110+
-connectionString: The connection string to the SQL Server.
111+
-query: The SQL query to execute.
112+
-Quiet: Suppresses output.
113+
```
114+
115+
### Mount-Database
116+
117+
```powershell
118+
NAME
119+
Mount-Database
120+
SYNTAX
121+
Mount-Database [[-connectionString] <Object>] [[-Database] <Object>] [[-DatabaseFilePath] <Object>] [-Quiet]
122+
DESCRIPTION
123+
Attaches a database to the SQL Server.
124+
PARAMETERS
125+
-connectionString: The connection string to the SQL Server.
126+
-Database: The name of the database to attach.
127+
-DatabaseFilePath: The file path of the database to attach.
128+
-Quiet: Suppresses output.
129+
```
130+
131+
### New-SqlQueryDataSet
132+
133+
```powershell
134+
NAME
135+
New-SqlQueryDataSet
136+
SYNOPSIS
137+
New-SqlQueryDataSet -- Creates and returns an Object instance of the [SqlQueryDataSet] class configured with or without the specified parameters.
138+
SYNTAX
139+
New-SqlQueryDataSet [[-SQLServer] <String>] [[-Database] <String>] [[-ConnectionString] <String>] [[-Query] <String>] [[-TableName] <String>] [[-DisplayResults] <Boolean>] [<CommonParameters>]
140+
DESCRIPTION
141+
This function initializes a new instance of the [SqlQueryDataSet] class and the resulting object is configured is based which parameters were specified.
142+
All parameters are optional as the can be configured later using the [SqlQueryDataSet]$object returned when calling $object = New-SqlQueryDataSet
143+
When using $SQLServer and $Database, both must be specified together. The [SqlQueryDataSet] class will auto generate a SQL ConnectionString.
144+
Specifying $ConnectionString overrides auto generation even when $SQLServer and $Database are also specified.
145+
Based on which parameters are passed, this CmdLet will use one of the overloaded class constructors and configure instance settings with the other parameters:
146+
- [SqlQueryDataSet]::new()
147+
- [SqlQueryDataSet]::new(string SQLServer, string Database)
148+
- [SqlQueryDataSet]::new(string SQLServer, string Database, string Query)
149+
Explanation of Parameter Sets:
150+
- **`ServerDatabase`**: This parameter set allows the user to specify the SQL Server and Database separately without needing a full connection string.
151+
- **`ServerDatabaseWithConnectionString`**: This parameter set allows the user to provide both the SQL Server and Database separately, or use a connection string.
152+
- **`ConnectionString`**: This parameter set allows the user to provide a connection string directly.
153+
REMARKS
154+
To see the examples, type: "Get-Help New-SqlQueryDataSet -Examples"
155+
For more information, type: "Get-Help New-SqlQueryDataSet -Detailed"
156+
For technical information, type: "Get-Help New-SqlQueryDataSet -Full"
157+
```
158+
159+
## Classes
160+
161+
### [SqlQueryDataSet] Parent Class Details
162+
163+
Instances of [SqlQueryDataSet] Parent Class are created using the New-SqlQueryDataSet() helper CmdLet. The object returned is of type [SqlQueryDataSet]. The properties and methods are used to manage and configure database information and connections, manage creation of the Child Class, execute queries, and save the results. Instances of Child Classes are collected in the Tables property of the Parent Class. Tables is a collection of [SqlQueryTable] objects. One is created for every unique query that was added or executed.
164+
165+
Each instance of the [SqlQueryTable] Class holds the Query configuration and execution results.
166+
167+
For technical information, see:
168+
169+
- Get-Help New-SqlQueryDataSet -Full
170+
- New-SqlQueryDataSets.tests.ps1 in the Tests (C:\Git\SqlQueryClass\tests\) folder has full usage examples used to validate usage
171+
172+
### Class [SqlQueryDataSet] Properties
173+
174+
Name | Type
175+
----------------- | ----------------------------------------------------------------------
176+
SQLServer | [System.String]
177+
Database | [System.String]
178+
ConnectionTimeout | [System.Int32]
179+
CommandTimeout | [System.Int32]
180+
ConnectionString | [System.String]
181+
SQLConnection | [System.Object]
182+
TableIndex | [System.Int32]
183+
Tables | [System.Collections.Generic.List`1[[SqlQueryTable, PowerShell Class Assembly, Version=1.0.0.2, Culture=neutral, PublicKeyToken=null]]]
184+
TableNames | [System.Collections.Hashtable]
185+
DisplayResults | [System.Boolean]
186+
KeepAlive | [System.Boolean]
187+
188+
### Class [SqlQueryDataSet] Methods
189+
190+
Name | Syntax
191+
-------------------------- | -------------------------------------------------------------
192+
AddQuery | int AddQuery(string Query)
193+
AddQuery | int AddQuery(string TableName, string Query)
194+
GetTableFromQuery | System.Object GetTableFromQuery(string Query)
195+
GetTableFromTableName | System.Object GetTableFromTableName(string TableName)
196+
BuildOleDbConnectionString | string BuildOleDbConnectionString()
197+
LoadQueryFromFile | void LoadQueryFromFile(string Path)
198+
OpenConnection | void OpenConnection()
199+
CloseConnection | void CloseConnection()
200+
GetSqlCommand | System.Data.SqlClient.SqlCommand GetSqlCommand(string query)
201+
Clear | void Clear()
202+
Execute | System.Object Execute()
203+
Execute | System.Object Execute(SqlQueryTable table)
204+
Execute | System.Object Execute(int TableIndex)
205+
Execute | System.Object Execute(string SqlQuery)
206+
Execute | System.Object Execute(ResultType ResultType)
207+
ExecuteNonQuery | System.Object ExecuteNonQuery(string SqlQuery)
208+
ExecuteQuery | System.Object ExecuteQuery(string SqlQuery)
209+
ExecuteQuery | System.Object ExecuteQuery(string TableName, string SqlQuery)
210+
ExecuteAsDataTable | System.Object ExecuteAsDataTable(string SqlQuery)
211+
ExecuteAsDataAdapter | System.Object ExecuteAsDataAdapter(string SqlQuery)
212+
ExecuteAsDataSet | System.Object ExecuteAsDataSet(string SqlQuery)
213+
ExecuteAsDataRows | System.Object ExecuteAsDataRows(string SqlQuery)
214+
SaveChanges | System.Object SaveChanges()
215+
GetDBTableSchema | System.Object GetDBTableSchema(string TableName)
216+
GetDBTableIndexesV17 | System.Object GetDBTableIndexesV17(string TableName)
217+
GetDBTableIndexes | System.Object GetDBTableIndexes(string TableName)
218+
GetCreateBasicDLL | System.Object GetCreateBasicDLL(string TableName)
219+
GetCreateDDL | System.Object GetCreateDDL(string TableName)
220+
ParseSQLQuery | System.Object ParseSQLQuery(string Query)
221+
222+
### Child Class [SqlQueryTable] Properties
223+
224+
Name | Type
225+
-------------- | -----------------
226+
TableIndex | [System.Int32]
227+
TableName | [System.String]
228+
Query | [System.String]
229+
SQLCommand | [System.Object]
230+
SqlDataAdapter | [System.Object]
231+
ResultType | [ResultType]
232+
Result | [System.Object]
233+
isDirty | [System.Boolean]
234+
QueryFile | [System.String]
235+
Parent | [SqlQueryDataSet]
236+
237+
### Child Class [SqlQueryTable] Methods
238+
239+
Class Has No Methods

contributor.guide.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
- [Setup](#setup)
66
- [Source Files used in the Module](#source-files-used-in-the-module)
77
- [Module Build Process](#module-build-process)
8-
- [Publishing `GuiMyPS` Module to GitHub](#publishing-GuiMyPS-module-to-github)
8+
- [Publishing `SqlQueryClass` Module to GitHub](#publishing-sqlqueryclass-module-to-github)
99
- [Code Review and Feedback](#code-review-and-feedback)
1010
- [Merge the Pull Request](#merge-the-pull-request)
1111
- [Cleanup](#cleanup)
12-
- [Publishing `GuiMyPS` Module to PowerShell Gallery](#publishing-GuiMyPS-module-to-powershell-gallery)
12+
- [Publishing `SqlQueryClass` Module to PowerShell Gallery](#publishing-sqlqueryclass-module-to-powershell-gallery)
1313

1414
## Setup
1515

1616
- Uses SQL Express but should work with other SQL Databases with proper connection strings and credentials
1717
- Requires VS Code
18-
- For Contributors, Fork the [GuiMyPS](https://github.com/BrooksV/GuiMyPS) repository
18+
- For Contributors, Fork the [SqlQueryClass](https://github.com/BrooksV/SqlQueryClass) repository
1919
- Clone the repository or fork to local pc. I like using c:\git as my local repository folder. Subfolder $ProjectName will be created with the GitHub repository contents
2020
- Install [Manjunath Beli's ModuleTools](https://github.com/belibug/ModuleTools) module as the module build process uses ModuleTools
2121

@@ -29,6 +29,8 @@
2929

3030
- Public functions that are exported, are separate files in the .\src\public folder.
3131
- Private functions that are local to the Module, are separate files in the .\src\private folder.
32+
- - Class Definitions and Enums are not accessible outside of the Module and cannot be accessed directly like Public Functions are. This is a PowerShell limitation.
33+
- - - Classes [SqlQueryDataSet] and [SqlQueryDataSetParms] and enum ResultType used in the Module are defined in file .\src\private\SqlQueryClass.ps1 file. The classes have properties and methods used to maintain a Database connections and result sets making it useful WPF Data binding.
3234
- Resources are files and folders in the .\src\resources folder that needs to be included with the Manifest and Module
3335

3436
## Module Build Process
@@ -50,10 +52,10 @@
5052
Invoke-MTBuild -Verbose
5153
```
5254

53-
- - Outputs to the .\dist\GuiMyPS folder
54-
- - Combines the file contents of the files in Public and Private folder into .\dist\GuiMyPS\GuiMyPS.psd1 and exports the Public Functions
55-
- - Generates the .\dist\GuiMyPS\GuiMyPS.psd1 Manifest file from the settings in .\project.json
56-
- - Resources (.\src\resources) folder content is copied to .\dist\GuiMyPS folder
55+
- - Outputs to the .\dist\SqlQueryClass folder
56+
- - Combines the file contents of the files in Public and Private folder into .\dist\SqlQueryClass\SqlQueryClass.psd1 and exports the Public Functions
57+
- - Generates the .\dist\SqlQueryClass\SqlQueryClass.psd1 Manifest file from the settings in .\project.json
58+
- - Resources (.\src\resources) folder content is copied to .\dist\SqlQueryClass folder
5759
- Run the Pester Teats using Invoke-MTTest (Find-Module -Name ModuleTools)
5860

5961
1. Make corrections, repeat the build process.
@@ -62,7 +64,7 @@
6264
- Upstream your branch.
6365
- Create a Pull request.
6466

65-
## Publishing `GuiMyPS` Module to GitHub
67+
## Publishing `SqlQueryClass` Module to GitHub
6668

6769
1. Stage and Commit Your Changes
6870

@@ -83,7 +85,7 @@
8385
```
8486
8587
1. Create a Pull Request on remote repository
86-
- Go to [GuiMyPS GitHub repository](https://github.com/BrooksV/GuiMyPS)
88+
- Go to [SqlQueryClass GitHub repository](https://github.com/BrooksV/SqlQueryClass)
8789
- Click on "Compare & pull request" for your branch
8890
- Provide a meaningful title and description for the PR
8991
- Select the base branch (main) to merge into
@@ -116,7 +118,7 @@ git branch -d features/database-table-access
116118

117119
These steps will ensure your changes are integrated into the main branch and your repository remains organized.
118120

119-
## Publishing `GuiMyPS` Module to PowerShell Gallery
121+
## Publishing `SqlQueryClass` Module to PowerShell Gallery
120122

121123
```powershell
122124
$data = Get-MTProjectInfo

project.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
{
2-
"ProjectName": "GuiMyPS",
3-
"Description": "Module helps in creating and running WPF GUI based PowerShell Applications.",
4-
"Version": "0.0.1",
2+
"ProjectName": "SqlQueryClass",
3+
"Description": "The SqlQueryClass module provides a set of functions and cmdlets for working with SQL databases. It includes functionality for connecting, executing SQL queries, and managing output as DataTable, DataAdapter, DataSet, SqlReader, or NonQuery result objects.",
4+
"Version": "0.1.3",
5+
"ResourceCopyMode": "Content",
56
"Manifest": {
67
"Author": "Brooks Vaughn",
78
"PowerShellHostVersion": "5.1",
8-
"GUID": "b9f7d4c6-e924-4a7b-a117-e169dc71f010",
9+
"GUID": "8375edbe-fb0f-4cb6-acb0-9964b45725c0",
910
"Tags": [
1011
"PowerShell",
11-
"WPF",
12-
"XAML",
13-
"GUI"
12+
"Database",
13+
"SQL",
14+
"SQLServer",
15+
"SQLQuery",
16+
"DataAdapter",
17+
"DataSet",
18+
"DataTable"
1419
],
15-
"ProjectUri": "https://github.com/BrooksV/GuiMyPS",
16-
"LicenseUri": "https://github.com/BrooksV/GuiMyPS/blob/main/LICENSE"
20+
"ProjectUri": "https://github.com/BrooksV/SqlQueryClass",
21+
"LicenseUri": "https://github.com/BrooksV/SqlQueryClass/blob/main/LICENSE"
1722
},
1823
"Pester": {
1924
"TestResult": {

0 commit comments

Comments
 (0)