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 + “”);

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/

OOP Concepts in PHP – Link

Posted: May 5, 2011 in PHP
Tags: ,

Useful link for PHP beginners …

http://www.scribd.com/doc/24094382/OOPS-concepts-in-PHP

Install PHP PEAR Packages/Components

Posted: May 2, 2011 in PHP
Tags: ,

Default installation of PEAR does not install all packages related to it’s reusable componenets. We need to explicitly install each component based on our need. For ex: To install Benchmarking package, go to command prompt and run following command …

pear install Benchmark-1.2.8

Similarly if you want to find about any package that you want to install you can use following command …

pear search Cache

Following are the more commands …

pear list – To see List of all installed packages

pear remote-list – To see all available packages on the channel server

pear list-files Benchmark – To see any Package’s installed files

pear info PEAR – To see any Package information

References – http://pear.php.net/manual/en/guide.users.commandline.packageinfo.php

Note – To run pear samples or components, set the pear installation path to include_path in PHP ini config file under the server that you use to run PHP (ex: Apache).