Skip to content

Instantly share code, notes, and snippets.

View sin2akshay's full-sized avatar
💻
Coding

Akshay Kumar sin2akshay

💻
Coding
View GitHub Profile
@sin2akshay
sin2akshay / getDataIntoDataTable.cs
Created April 24, 2018 11:11
C# - Executing a SQL Query in DB2 Database. Using a datatable to get the data.
/// <summary>
/// Common method for Getting data as Datatable with connection string
/// </summary>
/// <param name="ConnectionString"></param>
/// <param name="CmdText"></param>
/// <param name="TableName">Table Name</param>
/// <returns></returns>
public DataTable GetDataTable(string ConnectionString, string CmdText,string TableName)
{
DB2Connection Con;
@sin2akshay
sin2akshay / TransFileToSpecifiedFolder.cs
Created April 24, 2018 11:18
C# - Transfer file from one Folder to other
/// <summary>
/// Transfer file from one Folder to other
/// </summary>
/// <param name="path">Path to Target Folder</param>
/// <param name="FileName">Full Path to Source File</param>
public void TransFileToSpecifiedFolder(string path, string FileName)
{
//Deleting file from destination folder if it exists, else exception occurs
string path2 = path + "\\" + Path.GetFileName(FileName);
try
@sin2akshay
sin2akshay / cs_dataset-sp.cs
Last active April 24, 2018 12:32 — forked from appforest/cs_dataset-sp
C# - Calling a SQL Server Stored Procedure. Using a dataset to get the data.
string CS = ConfigurationManager.ConnectionStrings["test_connectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlDataAdapter da = new SqlDataAdapter("testProcedure3", con); // Using a Store Procedure.
//SqlDataAdapter da = new SqlDataAdapter("SELECT 'this is a test text' as test", con); To use a hard coded query.
da.SelectCommand.CommandType = CommandType.StoredProcedure; // Comment if using hard coded query.
DataSet ds = new DataSet(); // Definition: Memory representation of the database.
da.SelectCommand.Parameters.AddWithValue("@ggg", 95); // Repeat for each parameter present in the Store Procedure.
da.Fill(ds); // Fill the dataset with the query data
@sin2akshay
sin2akshay / ExecuteSPtoDT.cs
Last active May 3, 2018 07:50
Populating a DataTable from a Stored Procedure in DB2 or SQL
//https://stackoverflow.com/questions/13402003/how-to-populate-a-datatable-from-a-stored-procedure
//For SQL
DataTable table = new DataTable();
using(var con = new SqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString))
using(var cmd = new SqlCommand("usp_GetABCD", con))
using(var da = new SqlDataAdapter(cmd))
{
cmd.CommandType = CommandType.StoredProcedure;
da.Fill(table);
@sin2akshay
sin2akshay / LinkSaves.txt
Last active May 9, 2018 15:18
WeRateDogs Udacity Project References
https://github.com/kdow/WeRateDogs/blob/master/wrangle_act.ipynb
https://github.com/nikg41/WeRateDogs/blob/master/act_report.ipynb
https://github.com/RedRock42/Udacity-Nanodegree-Portfolio/blob/master/P4.Wrangling%20%26%20Analyzing%20Twitter%20Data/Wrangle%20Act.ipynb
https://github.com/spinks/WeRateDogs/blob/master/wrangle_act.ipynb
https://github.com/nathan-booth/weratedogs/blob/master/wrangle_act.ipynb
https://github.com/OrangeWong/WeRateDogs/blob/master/wrangle_act.ipynb
https://github.com/nikhil16-bhaskar/WeRateDogs/blob/master/Wrangling_act.ipynb
https://github.com/sridharvaranasi/Twitter-WeRateDogs-DataWrangling-Project-Using-Python [Very bad report]
https://github.com/anoru/Wrangling-Data-WeRateDogs [Detailed Report, Good Visualization]
@sin2akshay
sin2akshay / ObjectModel.Collection.cs
Last active May 10, 2018 06:23
Code to understand using System.Collections.ObjectModel.Collection<T> Class
using System;
using System.Linq;
using System.Collections;
using System.Collections.ObjectModel;
class MainClass {
public static void Main (string[] args) {
Console.WriteLine ("Hello World");
Collection<int> intCollection = new Collection<int>();
intCollection.Add(1);
@sin2akshay
sin2akshay / RunDebugMethod.cs
Created May 11, 2018 12:59 — forked from dguder/RunDebugMethod.cs
Runs a service from console for debugging
// The main entry point for the process
static void Main()
{
#if (!DEBUG)
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service1() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
#else
// Debug code: this allows the process to run as a non-service.
// It will kick off the service start point, but never kill it.
@sin2akshay
sin2akshay / MapsExercise.go
Last active May 24, 2018 11:46
Tour of Golang | Exercise: Maps - https://tour.golang.org/moretypes/23
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
a := strings.Fields(s)
m := make(map[string]int)
@sin2akshay
sin2akshay / FibonacciClosure.go
Created May 25, 2018 06:03
Tour of Golang | Exercise: Fibonacci closure - https://tour.golang.org/moretypes/26
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
a, b := 0, 1
return func() int {
a, b = b, a+b
@sin2akshay
sin2akshay / WinServices_References.txt
Last active August 7, 2018 05:19
Tutorial Links for Windows Services and Timers
1. Windows Service with Timer - https://www.aspsnippets.com/Articles/Simple-Windows-Service-that-runs-periodically-and-once-a-day-at-specific-time-using-C-and-VBNet.aspx
2. Demo VS Setup Project - https://www.codeproject.com/Articles/12548/Visual-Studio-Windows-Application-Setup-Project
3. Setup Project with Windows Service - https://www.codeproject.com/Articles/568476/Creating-an-MSI-Setup-Package-for-Csharp-Windows
4. Setup Project with Windows Service - http://cherupally.blogspot.com/2009/09/how-to-create-setup-project-to-install.html
5. https://www.c-sharpcorner.com/UploadFile/b7531b/create-simple-window-service-and-setup-project-with-installa/
https://dzone.com/articles/create-windows-services-in-c
>>https://docs.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer#adding-features-to-the-service