Archive for May, 2011

Use JavaScriptSerializer to convert JSON object to C# object and backwards. It is very useful to build AJAX based web pages for thinner network traffic and for better client side html computation …

using System.Web.Script.Serialization;

public class Employee
{
 public string Name { get; set; }
        public string Age { get; set; }
        public string ID { get; set; }
}

Employee oEmployee1 = new Employee { Name = “name1”, ID = “1”, Age = “5” };
Employee oEmployee2 = new Employee { Name = “name2”, ID = “2”, Age = “7” };
Employee oEmployee3 = new Employee { Name = “name3”, ID = “3”, Age = “8” };
List<Employee> oList = new List<Employee>() { oEmployee1, oEmployee2, oEmployee3 };

JavaScriptSerializer oSerializer = new JavaScriptSerializer();
string sJSON = oSerializer.Serialize(oList);
Response.Write(sJSON);
List<Employee> oNewList = (List<Employee>)oSerializer.Deserialize(sJSON, typeof(List<Employee>));
Response.Write(oNewList.Count + “”);

string sJSON2 = oSerializer.Serialize(oEmployee1);
Response.Write(sJSON2);
Employee emp = (Employee)oSerializer.Deserialize(sJSON2, typeof(Employee));
Response.Write(emp.Name + “”);

Advertisements

Do you need to connect to multiple servers in your day to day work then use remote desktop connection manager to organize your server environment connection details.

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=4603c621-6de7-4ccb-9f51-d53dc7e48047

Are you worried with query performance due to huge data in tables, use Table partitioning of SQL Server 2008. It’s easy and very useful.

You can partition data to different db data files stored in different hard disks on the server to increase parallelism with I/O. It’s been simplified in SQL Server 2008 compared to SQL Server 2005/2000. We can use wizard based or script based approach to create partitions on new or existing tables. Refer following links for more info.

log4net – logging info/warning/errors in your aplication to a log file or to the database (sql server, oracle, DB2, MS Access  ) or to send it in a email or to show it as a message on your machine or to write to a event log …

  • Set environment variable from command prompt –
    set ssdir=\\yourserver\VSS\VSProjects
  • Check environment variable whether set or not from command prompt –
    dir %ssdir%
  • Save directory file list to a file – dir /b > c:\files.txt
  • User-defined function calls inside a four-part linked server query in case if it is not supported
    • Ex: Select * from Linked_Server.northwind.dbo.square_value(10)
  • Use Openquery function …
    • Ex: Select * from Openquery(Linked_Server,’select northwind.dbo.square_ value(10)’)
  • If the user-defined function takes variable or scalar parameters, you can use the sp_executesql stored procedure
    • exec Linked_Server.northwind.dbo.sp_executesql N’SELECT northwind.dbo.square_value(@input)’,N’@input int’,@input=10

References

http://www.mcpressonline.com/database/db2/db2-integration-with-sql-server-2005-part-i-linked-server-enhancements.html

Track your page/website’s traffic …

http://chartbeat.com/

http://getclicky.com/

http://www.google.com/analytics/