Data Dictionary Queries for SQL Server & Oracle

For SQL Server

–Finding all details of Primary Key constraint
select * from sysobjects
where xtype=’PK’

–Finding all details of Foreign Key constraint
select * from sysobjects
where xtype=’F’

–Finding all User-Defined objects (tables, etc)
select * from sysobjects
where xtype=’U’

–Finding all System objects
select * from sysobjects
where xtype=’S’

–Finding all user names
select * from sysusers

–Finding Column Names of Particular Table
–Select Pubs Database
select from sysobjects o, syscolumns c
where = = ‘publishers’

select * from sys.dba_objects
where owner = ‘scott’and object_type=’TABLE’
SELECT owner, object_name, object_type FROM sys.dba_objects
where object_type=’SEQUENCE’ and owner=’scott’;


Implementing a Singleton Class in .NET

using System;

public class Singleton
private static Singleton instance;

private Singleton() {}

public static Singleton Instance
if (instance == null)
instance = new Singleton();
return instance;


Instance control. Singleton prevents other objects from instantiating their own copies of the Singleton object, ensuring that all objects access the single instance.

Flexibility. Because the class controls the instantiation process, the class has the flexibility to change the instantiation process.


Overhead. Although the amount is minuscule, there is some overhead involved in checking whether an instance of the class already exists every time an object requests a reference. This problem can be overcome by using static initialization as described in Implementing Singleton in C#.

Possible development confusion. When using a singleton object (especially one defined in a class library), developers must remember that they cannot use the new keyword to instantiate the object. Because application developers may not have access to the library source code, they may be surprised to find that they cannot instantiate this class directly.

Object lifetime. Singleton does not address the issue of deleting the single object. In languages that provide memory management (for example, languages based on the .NET Framework), only the Singleton class could cause the instance to be deallocated because it holds a private reference to the instance. In languages, such as C++, other classes could delete the object instance, but doing so would lead to a dangling reference inside the Singleton class.

How to implement a Custom Error Mechanism for ASP .NET pages

Adding this code in Global.asax gives ur application the ability to redirect the user to the specified page in case an unhandled exception occurs,

void Application_Error(object sender, EventArgs e)
// Code that runs when an unhandled error occurs
string username;
username = “UserID: TempUser”;

Exception exp = Server.GetLastError();
string to = ConfigurationSettings.AppSettings[“ToAddress”];
string from = ConfigurationSettings.AppSettings[“FromAddress”];
string subject = “Error in application”;

string message = exp.Message + “\r\n” + exp.ToString();
MessageMailSend.SendMessage(to, from, subject, message);



How to send an Email from ASP .NET



<add key=”ToAddress” value=””>
<add key=”FromAddress” value=””>
<add key=”host” value=”HOST”>

<smtp deliveryMethod=”Network” from=””>
<network host=”localhost” port=”25″ defaultCredentials=”true”/>

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;

/// Summary description for MessageMailSend
public class MessageMailSend
public MessageMailSend()
// TODO: Add constructor logic here
public static bool SendMessage(string to,string from,string subject,string message)
MailMessage msg = new MailMessage();
msg.To = to;
msg.Subject = subject;
msg.From = from;
msg.BodyFormat = MailFormat.Text;
msg.Body = message;
return true;
catch (Exception exp)
return false;