Skip to content

Instantly share code, notes, and snippets.

@abhi1010
abhi1010 / gist:11365686
Created April 28, 2014 08:41
View all the columns of a given table
SELECT
column_name "Name",
nullable "Null?",
concat(concat(concat(data_type,'('),data_length),')') "Type"
FROM user_tab_columns
WHERE table_name='ASGDLX_TBLBRAND'
where "ASGDLX_TBLBRAND" is the table name.
public IEnumerable<OdbcDataReader> ReadFile(string strExcelPath, string strWorkSheetName)
{
OdbcConnection connODBC = new OdbcConnection("Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=" + strExcelPath + ";DefaultDir=c:\\;");
OdbcDataReader readerODBC = null;
connODBC.Open();
OdbcCommand commandODBC = new OdbcCommand("select * from [" + strWorkSheetName + "$]", connODBC);
readerODBC = commandODBC.ExecuteReader();
while (readerODBC.Read())
{
@abhi1010
abhi1010 / autoresize_label
Created May 6, 2014 07:07
Dynamically Resize Label
public void Resize(Label label1)
{
Graphics g = Graphics.FromHwnd(this.Handle); //gets the graphics form the form
SizeF size = g.MeasureString(label1.Text, label1.Font); //gets the size of the text which will be displayed
label1.Size = new Size((int)size.Width, label1.Size.Height); //sets the length of the label (same height)
}
@abhi1010
abhi1010 / autoresize_label_better
Created May 6, 2014 07:08
Auto Resize a Label
public void Resize(Label label1)
{
Graphics g = this.CreateGraphics(); //gets the graphics based on the client area
SizeF size = g.MeasureString(str, label1.Font); //gets the size of the text which will be displayed
label1.Size = new Size((int)size.Width, label1.Size.Height); //sets the length of the label (same height)
}
@abhi1010
abhi1010 / recursive_read_directory.cs
Created May 6, 2014 07:13
Recursively Read Directories
private static void Directories(string strFolderPath, string fType)
{
DirectoryInfo info = new DirectoryInfo(strFolderPath);
ArrayList fileList = new ArrayList();
SubDirectories(fType, ref fileList, info.FullName, "");
return fileList;
}
private static void SubDirectories(string fType, ref ArrayList fileList, string location, string tab)
{
DirectoryInfo subDir = new DirectoryInfo(location);
<input type="image" name="HoverImageButton2" id="HoverImageButton2"
onmouseover="ShowImageHoverButton(this, '/wiz.net/WizLibrary/img/but-backtolisting1.jpg')"
onmouseout="ShowImageHoverButton(this, '/wiz.net/WizLibrary/img/but-takeaction1.jpg')"
src="../img/but-takeaction1.jpg" style="border-width:0px;" />
@abhi1010
abhi1010 / gist:bfb075b6787d2616fde6
Created May 6, 2014 07:24
Custom Web Controls - On Pre Render
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
string resourceName = "ExtendedControls.HoverImageButtonJS.js";
ClientScriptManager cs = this.Page.ClientScript;
cs.RegisterClientScriptResource(typeof(WizWerx.Web.UI.ExtendedControls.HoverImageButton), resourceName);
}
@abhi1010
abhi1010 / gist:88222d3f94911fbec6f4
Created May 6, 2014 07:26
Custom Web Controls - Configuration
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="ext" namespace="Company.Web.UI.ExtendedControls" assembly="ExtendedControls"/>
</controls>
</pages>
</system.web>
</configuration>
@abhi1010
abhi1010 / gist:135e9bbf44f3d9a53cb8
Created May 6, 2014 07:28
Custom Web Controls - Full Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing.Design;
namespace CodersDigest.Web.UI.ExtendedControls
@abhi1010
abhi1010 / gist:d0b66ef7b0f076e88042
Created May 6, 2014 07:33
Custom Web Controls - OnInit
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.Attributes.Add("onmouseover", "ShowImageHoverButton(this, '" + this.ResolveUrl(ImageHoverUrl) + "')");
this.Attributes.Add("onmouseout", "ShowImageHoverButton(this, '" + this.ResolveUrl(ImageUrl) + "')");
}