Archive for August, 2011

Oracle Database shutdown and start up Commands

Sometimes, Programmers may have to go through some Database Administrative Tasks on Oracle Development Database. Here, I tried to put together Some Linux/Oracle Commands useful to shutdown and start up Oracle Database.

First of all, Log on to System(Linux) as “oracle” user or su to “oracle” using the following command.


$ su - oracle

Continue reading

Cookie with ASP.NET (C#)

Here, I am providing some helpful code snippets to work with Cookie in ASP.NET. if you don’t have any idea on Cookie, please surf here. This will help to get good idea on Cookie.

This one shows how to set and save values in Cookie.


//Set Cookie
HttpCookie userCookie = new HttpCookie("UserInfo");
userCookie["userName"] = TextBox1.Text;
userCookie["userPassword"] = TextBox2.Text;
userCookie.Expires = DateTime.Now.AddDays(3);
Response.Cookies.Add(userCookie);

Continue reading

Session with ASP.NET(C#)

if you are new with session, you are in the right place. Here, I will try to put together some code snippets to show various uses of Session. Let’s start with how to assign a Integer value in Session followed by how to retrieve it.


// Assign "userCode" variable to Session  
int userCode = 7;
Session.Add("UserCode", userCode);

//Retrieve "userCode" from Session
int userCode;
userCode= (int)Session["UserCode"];

Continue reading

Web Form Default Control Focus using Master Page

It’s straight-forward to set Default Focus with simple Web Form. Just set “defaultfocus” property to “ControlName” in “form” tag to get Default Control Focus in Web Form.


form id="form1" runat="server" defaultfocus="studentCodeTextBox"

However, it can not be done this way while using Master Page. Here, it has to be set at Page Load Event.


protected void Page_Load(object sender, EventArgs e)
{        
  Page.Form.DefaultFocus = userNameTextBox.ClientID;
}

Continue reading

Javascript with ASP.NET Master Page

I faced difficulties while using javascript in Web Form with Master Page. I was trying to use a Javascript Calender in asp.net page and this requires the FORM name and CONTROL name to initiate the calender. So, I started with the following code snippet.

                
new tcal ({
'formname': 'Form1',
'controlname': 'dateTextBox'				
});			 

Continue reading

Javascript to disable Right Click

This is an handy script to disable right click in webpages. Just put this script in between javascript tag and have right click disabled on your webpage.


     var message="Sorry, Right Click is disabled.";
   //To disable the right click on the page
    function click(e) 
    {
        if (document.all)
         {
            if (event.button == 2) 
            {
            alert(message);
            return false;
            }
         }
        if (document.layers) 
         {
            if (e.which == 3) 
            {
            alert(message);
            return false;
            }
         }
    }
    if (document.layers) 
    {
        document.captureEvents(Event.MOUSEDOWN);
    }
    document.onmousedown=click;

Thanks
A Rahim Khan

Reindexing in SQL Server 2005

This is an handy script to rebuild index in SQL Server 2005.


--USE DATABASENAME
USE StudentAsiaDB;

DECLARE @TableName varchar(255);

DECLARE TableCursor CURSOR FOR
SELECT table_name FROM information_schema.tables
WHERE table_type = 'base table'

OPEN TableCursor

FETCH NEXT FROM TableCursor INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN

PRINT 'Reindexing ' + @TableName
DBCC DBREINDEX(@TableName,' ',90)
FETCH NEXT FROM TableCursor INTO @TableName

END
CLOSE TableCursor
DEALLOCATE TableCursor

Thanks
A Rahim Khan