Skip to content

Instantly share code, notes, and snippets.

View karenpayneoregon's full-sized avatar
🎯
Focusing

Karen Payne karenpayneoregon

🎯
Focusing
View GitHub Profile
@karenpayneoregon
karenpayneoregon / DataOperations.cs
Created June 28, 2019 14:10
Rough example of creating a list of DataTable using TSQL OFFSET and FETCH NEXT
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BaseConnectionLibrary.ConnectionClasses;
namespace SQL_SplittingTable
Imports SpreadsheetLight
''' <summary>
''' Commonly used methods for SpreadSheetLight library.
''' Anytime there are methods that are used over and over again
''' consider placing those methods in this module.
'''
''' To use them simply call the method as this module has
''' public scope in the project it resides or in a class project
''' another main project references.
''' </summary>
@karenpayneoregon
karenpayneoregon / Form1.vb
Created February 25, 2020 12:53
Simple example for interface, INotifyPropertyChanged, data binding
Imports System.ComponentModel
Imports System.Runtime.CompilerServices
''' <summary>
''' Requires two ListBox controls, ListBox1, ListBox2
'''
''' Shows a simple use of a Interface and a simple use
''' of a BindingList. Note by implementing INotifyPropertyChanged and a BindingList
''' we can update a ListBox while without the BindingList the change is not
''' reflected in the second listbox.
'''
@karenpayneoregon
karenpayneoregon / CustomerEntity.vb
Created May 6, 2020 19:58
Read only property for StackOverflow question
Imports System.ComponentModel
Imports System.ComponentModel.DataAnnotations
Imports System.Runtime.CompilerServices
Public Class CustomerEntity
Inherits BaseEntity
Implements INotifyPropertyChanged
Private _customerIdentifier1 As Integer
Private _companyName1 As String
Imports System.IO
''' <summary>
''' Simple extension method to export all checked rows,
''' all columns except for the first column which would be
''' the check box column
''' </summary>
Module DataGridViewExtensions
''' <summary>
''' Export to text file
''' </summary>
@karenpayneoregon
karenpayneoregon / GroupingForm.vb
Created July 1, 2020 23:27
Group by two DataColumns
Imports System.Text
''' <summary>
''' Requires
''' 1 Button named DistinctGroupButton
''' 1 DataGridView named DataGridView1
''' </summary>
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim dt As New DataTable With {.TableName = "MyTable"}
dt.Columns.Add(New DataColumn With {.ColumnName = "Identifier", .DataType = GetType(Integer),
@karenpayneoregon
karenpayneoregon / NorthWind2020.sql
Last active October 4, 2020 04:34
New version for Microsoft NorthWind database
This file has been truncated, but you can view the full file.
USE [master]
GO
/****** Object: Database [NorthWind2020] Script Date: 7/10/2020 7:51:02 AM ******/
CREATE DATABASE [NorthWind2020]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'NorthWind2020', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\NorthWind2020.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
LOG ON
( NAME = N'NorthWind2020_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\NorthWind2020_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
GO
@karenpayneoregon
karenpayneoregon / CustomersNorthWind2020_customers.sql
Last active July 10, 2020 14:55
Using NorthWind2020 select customers
SELECT Cust.CustomerIdentifier,
Cust.CompanyName,
Cust.ContactId,
CT.ContactTitle,
C.FirstName,
C.LastName,
Cust.Street,
Cust.City,
Cust.Region,
Cust.PostalCode,
@karenpayneoregon
karenpayneoregon / NorthWind2020_Categories.sql
Created July 10, 2020 14:58
Select categories query suitable for a ComboBox, ListBox etc.
SELECT CategoryID,
CategoryName
FROM NorthWind2020.dbo.Categories;
DECLARE @OrderIdentifier INT= 10248;
SELECT O.OrderID,
O.CustomerIdentifier,
O.EmployeeID,
E.Title + ' ' + E.FirstName + ' ' + E.LastName AS Employee,
O.OrderDate,
O.RequiredDate,
O.ShippedDate,
O.ShipVia,
O.Freight,