" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi

How to relocate database from C#.NET (SQL Server 2000)

Posted on November 24th, 2015 by Kavita Asnani

To Move a database from one location to another we basically need to do three things Detach the Detabase from SQL Server Move the datafile and log file to the new location Attach the database back to SQL Server   I am using three System Store Procedures   sp_helpfile is a System Store Procedure that […]

Screen all incoming query-strings to prevent SQL injection

Posted on November 24th, 2015 by Santosh Bisoyi

Description: Web sites initially started to show static information to the user on plain HTML pages with some graphics and colorful text. But with the growing pace of the IT, web sites not only dispaly dyanamic data but also capable of taking the orders from the customers and process them online. This whole process is […]

SqlBulkCopy In .NET

Posted on November 24th, 2015 by Priyanka Dash

While working in a Data driven application, we generally come across situations where we have to perform bulk data insert operations between Data sources.   Following are some of the common situations Updating a database table, Copy data from source files, store them in a data table, and run insert queries to database table. Read […]

Programmatically fetching all the SQL Server Instances in a Network using C#.net

Posted on November 24th, 2015 by Samarendra Swain

Below is code snippet in C#.net for fetching all the SQL server instances in a network. This will insert all the server names into a ComboBox. The namespace required areSystem.Data.Sql and System.Data. using System.Data.Sql; using System.Data; // Create a instance of the SqlDataSourceEnumerator class SqlDataSourceEnumerator objSqlDS = SqlDataSourceEnumerator.Instance; // Fetch all visible SQL server 2000 or […]

Checking resource leaks in a form

Posted on November 24th, 2015 by Naibedya Kar

In a .net windows application the form might have resource leaks though it is running with managed codes. We can use the below procedure to check if a form is having resource leak. Open  Windows Task Manager Click on Process tab. Select “View” in the menu and then select “Select Columns” menu item. Check the […]

MidPointRounding for Math.Round() method in .Net Application

Posted on November 24th, 2015 by Rashmita Devi

We all know Math.Round() basically rounds a particular decimal value. But if we look into this method closely it rounds the value to the nearest even value. For example if we do Math.Round(2.5,0) it will return 2. But we may expect 3 intead of 2. In that case we can use MidPointRounding parameter of Math.Round() […]

Equality of values in Hashtable

Posted on November 24th, 2015 by Jnana Swain

If you try to store same key twice in HashTable with different values, the second replaces the first one. Example :1 HashTable sports = new HashTable(); sports[“item1”] = “Football”; sports[“item1”] = “Cricket”; Console.WriteLine(sports[“item1”]); Console.WriteLine(“No of Sports: ” + sports.Count); Example 1: will print Cricket No of Sports : 1 Example :2 static void Main(string[] args) { Hashtable […]

Checkbox Column In Datagrid

Posted on November 24th, 2015 by Amrita Dash

When we add a customized checkbox column to a datagrid in .net (windows application) , the default property allows to check or uncheck the column using a double click. On the first click it selects the column and on the second click the column is either checked or unchecked.   To change this default property, […]

Windows service as scheduler

Posted on November 24th, 2015 by Amrita Dash

To make a windows service do the job at particular time of the day (just like a task scheduler) we need to set the timer and calculate the interval to schedule the event.   Following is the code sample to set up the timer. [CODE STARTS C#.NET VS 2003] // Reference added using System.Timers; // when the […]

Set default printer using C#.NET [VS 2008]

Posted on November 24th, 2015 by Amrita Dash

Following is the code sample used to set the default printer. We need to add the reference of “System.Management” to the project.   [C#.NET CODE STARTS] // namespace declaration using System.Management; // code sample for setting default printer ManagementObjectCollection objManagementColl; // class used to invoke the query for specified management collection ManagementObjectSearcher objManagementSearch = new […]

Custom Error Handling at Page Level

Posted on November 24th, 2015 by Rasmita Mohanty

Custom Error Handling at Page Level using C#.NET There are various ways we can track errors in ASP.Net, but here I discuss about how to track page level errors and their source and cause. The page level error tracking process will track all types of error except syntax errors. To use the page level error […]