Friday, 30 October 2009

SQL: Try Catch

EG1:BEGIN TRY
-- Table does not exist; object name resolution
-- error not caught.
SELECT * FROM NonexistentTable;
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_MESSAGE() AS ErrorMessage;
END CATCH



EG2:CREATE PROCEDURE usp_ExampleProc
AS
SELECT * FROM NonexistentTable;
GO

BEGIN TRY
EXECUTE usp_ExampleProc;
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_MESSAGE() AS ErrorMessage;
END CATCH;

SQL: Reset column identity

--Check what currently is
DBCC CHECKIDENT (’tablename’, NORESEED)

--Reset
DBCC CHECKIDENT (’tablename’, RESEED, 1)

Thursday, 29 October 2009

ASP: Photoshop titles

http://abduzeedo.com/shiny-caligraphy-text-effect-photoshop#

Salary Calc

http://www.thesalarycalculator.co.uk/salary.php

ASP: Creating fading edges in images

Creating Faded Edges
There are several ways to create edges on an image which fade away into the background. One way is as follows:
1. Begin with a canvas which is larger than the image to be blurred, around all four edges. One way to do this is to use the Image->Canvas Size dialog.
2. Use the marquee tool to select an area which is a few pixels in from the edge of the image.



3. Use Select->Invert to select the border around the image.


4.

Use Select->Feather to blur the selected area by a few pixels. A value of 4 pixels was used here.

5.

Now, use Filter->Blur-> Gaussian Blur to produce the final effect. A value of 4.1 was used.



6.

Finally, crop any unneeded whitespace around the image and save it.


http://www.mtholyoke.edu/help/creating-pages/imaging/xfade.shtml

Tuesday, 27 October 2009

ADO .NET: Connect to SP

conn.Open();

SqlCommand cmd1 = new SqlCommand("[staging].[USP_ETL_INSERT_FILE_ETLQUEUE]");
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.Add(new SqlParameter("@CartesisID", cartesisID));
cmd1.Parameters.Add(new SqlParameter("@ReportingPeriod",reportingPeriod));
cmd1.Parameters.Add(new SqlParameter("@FilePath", fileNameFull));
cmd1.Parameters.Add(new SqlParameter("@UploadedBy", Request.ServerVariables["AUTH_USER"]));
cmd1.Connection = conn;
cmd1.ExecuteNonQuery();
conn.Close();

//Execute SSIS Package
string packagelocation = System.Configuration.ConfigurationSettings.AppSettings["SSISLocation"].ToString();
string packageConfiglocation = System.Configuration.ConfigurationSettings.AppSettings["SSISConfigLocation"].ToString();
packagelocation = packagelocation + "VerifyFile.dtsx";
Package verifyPackage = app.LoadPackage(packagelocation, null);
verifyPackage.ImportConfigurationFile(packageConfiglocation + "VerifyFileConfig.dtsConfig");
verifyPackage.Variables["FileName"].Value = fileNameFull;
DTSExecResult result = verifyPackage.Execute();

Thursday, 22 October 2009

EXCEL: Convert xls to txt, csv

Open the Excel file and paste this code into the Source code. Change file type, delimiter and location in the DoTheExport() funtion

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ExportToTextFile' This exports a sheet or range to a text file, using a' user-defined separator character.''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Sub DoTheExport() ExportToTextFile FName:="C:\HRDW\200908.txt", Sep:="~", _ SelectionOnly:=False, AppendData:=TrueEnd Sub
Public Sub ExportToTextFile(FName As String, _ Sep As String, SelectionOnly As Boolean, _ AppendData As Boolean)
Dim WholeLine As StringDim FNum As IntegerDim RowNdx As LongDim ColNdx As IntegerDim StartRow As LongDim EndRow As LongDim StartCol As IntegerDim EndCol As IntegerDim CellValue As String
Application.ScreenUpdating = FalseOn Error GoTo EndMacro:FNum = FreeFile
If SelectionOnly = True Then With Selection StartRow = .Cells(1).Row StartCol = .Cells(1).Column EndRow = .Cells(.Cells.Count).Row EndCol = .Cells(.Cells.Count).Column End WithElse With ActiveSheet.UsedRange StartRow = .Cells(1).Row StartCol = .Cells(1).Column EndRow = .Cells(.Cells.Count).Row EndCol = .Cells(.Cells.Count).Column End WithEnd If
If AppendData = True Then Open FName For Append Access Write As #FNumElse Open FName For Output Access Write As #FNumEnd If
For RowNdx = StartRow To EndRow WholeLine = "" For ColNdx = StartCol To EndCol If Cells(RowNdx, ColNdx).Value = "" Then CellValue = Chr(34) & Chr(34) Else CellValue = Cells(RowNdx, ColNdx).Text End If WholeLine = WholeLine & CellValue & Sep Next ColNdx WholeLine = Left(WholeLine, Len(WholeLine) - Len(Sep)) Print #FNum, WholeLineNext RowNdx
EndMacro:On Error GoTo 0Application.ScreenUpdating = TrueClose #FNum
End Sub''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' END ExportTextFile''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''