Tuesday 21 April 2009

How to generate randam string of 8 characters

|start cfscript|

RPassword = "";
// Get the random characters for password

RandomCharacters=1;

for (RandomCharacters;RandomCharacters < 8; RandomCharacters++ )
{
//character code from A To Z
ranPassword = RandRange(0097,0122);
RPassword = ListAppend(RPassword, CHR(ranPassword));
}

//Get the random numbers from 1 to 9 for password

RPassword = ListAppend(RPassword,RandRange(1,9));

//Get rid of commas

RPassword = Replace(RPassword,',','', 'all');

|end cfscript|

How to make call using Ajax/ JQuery

First thing you got to include Jquery library
Second thing:
create some functions inside jqueries ready function like this:
$(document).ready(
function()
{
// if you want to take any action on load
});
Third:
There are few ways to do this call and here are 3 ways of them:

1) This is a get call
$("#DivToDisplayResult).load('pageToBeCalled.cfm',{
Param1: param1value,
Param2: param2value,
Param2: param2value,
Param2: param2value,
……..
},
// following function is required, which is being called after we get the result back
function(responseText, textStatus, XMLHttpRequest){
//alert(responseText);
}
2) $.getJSON('pageToBeCalled.cfm',{UserProfileCode: userProfCode}, function(j){
// here you can put the action and you would get result in “j” variable
// like
$("#divName").html(j);
});
3) Post
$.post(
pageToBeCalled.cfm,
{
Param1: param1value,
Param2: param2value,
Param2: param2value, },
function(j) {
//here you can take action by reading “j” variable
}
);

MS SQL: Backup database Stored Procedure

Here is a stored procedure to create a full backup of the database.
Run the code on the master database.
To backup a db run:
sp_backupdatabase 'databasename'
To verify the backup we need to use use CHECKSUM.

USE "master"
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE "dbo"."sp_backupdatabase" (
@DBName nvarchar(50)
)
WITH ENCRYPTION
AS
BEGIN
SET NOCOUNT ON;
DECLARE @sqlCommand NVARCHAR(1000)
DECLARE @dateTime NVARCHAR(20)
SELECT @dateTime = REPLACE(CONVERT(VARCHAR, GETDATE(),111),'/','') + REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','')
SET @sqlCommand = 'BACKUP DATABASE ' + @DBName + ' TO DISK = ''D:\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\' + @DBName + '_backup_' + @dateTime + '.BAK'' WITH CHECKSUM'
EXECUTE sp_executesql @sqlCommand
END

Thursday 9 April 2009

The Italy earthquake

I really feel sorry for people of L'Aquila and other towns in central Italy and Italy for what they have been experiencing after this. Prey god be merciful, but its the way now people behaving, and what wrongful deeds they are doing cost to other innocent people to suffer.

May god help the families of the sufferers to come out from this shock and great loss bravely.

My New Kitchen

Its all fitted now and looks amazing, will post some pics of it soon, looking forward to long weekend (Easter one, tomorrow), when painter will come to paint and lay tiles on wall opposite to sink and Hob.

It was worth spending money with KBBC, Kitchen fitting company.