Friday, December 25, 2009

Synchronize Hotmail contacts with your mobile

At last Microsoft came up with a contact synchronizing tool to synchronize contacts from your mobile with Hotmail/Live and vise versa. Currently it is a beta release and supports only few models.

http://specials.msn.co.in/sp09/pdm/index.asp

Check the above url.

Monday, November 2, 2009

Microsoft facts

Fact#1: Nobody can create a FLODER anywhere on the computer with the name 'CON'.

Fact#2: Open Microsoft Word and type =rand(200,99) and the press ENTER.

Fact#3: For those of you using Windows, do the following:

  1. Open an empty notepad file
  2. Type "Bush hid the facts" (without the quotes)
  3. Save it as whatever you want.
  4. Close it, and re-open it.

is it just a really weird bug? :-??

Monday, October 5, 2009

LINQPad

LINQPad is one of the best tools to use for easy building of queries using LINQ, ADO.NET Entity Framework or SQL.

http://www.linqpad.net

Wednesday, September 30, 2009

ADO.NET Entity Framework Essential Resources

The following are some of the essential resources:

Overview and Introduction

http://msdn.microsoft.com/en-us/data/aa937723.aspx
http://msdn.microsoft.com/en-us/library/bb399572.aspx

The ADO.NET Entity Framework and Entity Data Model

http://www.renaissance.co.il/downloads/Entity%20Framework%20and%20EDM.pdf

An Entity Data Model for Relational Data Part I: Defining the Entity Data Model

http://www.code-magazine.com/articleprint.aspx?quickid=0712062

An Entity Data Model for Relational Data Part II: Mapping an Entity Data Model to a Relational Store

http://www.code-magazine.com/Article.aspx?quickid=0712032

Introducing ADO.NET Entity Framework

http://www.code-magazine.com/Article.aspx?quickid=0711051

Achieve Flexible Data Modeling With the Entity Framework

http://msdn.microsoft.com/en-us/magazine/cc700331.aspx

Programming Against the ADO.NET Entity Framework

http://www.code-magazine.com/Article.aspx?quickid=0712042

Data Access Options in Visual Studio 2008

http://www.code-magazine.com/Article.aspx?quickid=0809091

Entity Framework- The Crib Sheet

http://www.simple-talk.com/dotnet/.net-framework/entity-framework-the-cribsheet/

Entity Framework FAQ

http://blogs.msdn.com/dsimmons/pages/entity-framework-faq.aspx

Videos

How Do I? Videos - Entity Framework Series

http://msdn.microsoft.com/en-us/data/cc300162.aspx

Dan Simmons on the Entity Framework Part 1 & 2

http://www.dnrtv.com/default.aspx?showNum=117
http://www.dnrtv.com/default.aspx?showNum=118

Programming LINQ and the ADO.NET Entity Framework Webcast

http://tinyurl.com/6zl78h

Beyond the Basics

http://msdn.microsoft.com/en-us/magazine/cc700340.aspx
http://gupea.ub.gu.se/dspace/bitstream/2077/10462/1/gupea_2077_10462_1.pdf
http://blogs.microsoft.co.il/blogs/idof/archive/2008/08/20/entity-framework-and-lazy-loading.aspx
http://thedatafarm.com/LearnEntityFramework/tutorials/using-stored-procedures-for-insert-update-amp-delete-in-an-entity-data-model/
http://www.objectsharp.com/devlounge/articles/2008/04/27/the-entity-framework-vs-the-data-access-layer-part-0-introduction.aspx
http://www.objectsharp.com/devlounge/articles/2008/05/06/the-entity-framework-vs-the-data-access-layer-part-1-the-ef-as-a-dal.aspx

Samples & Extensions

http://code.msdn.microsoft.com/adonetefx http://www.learnentityframework.com/resources

ADO.NET Entity Framework Query Samples

http://code.msdn.microsoft.com/EFQuerySamples

The Entity Framework forum

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=533&SiteID=1

Blogs

http://blogs.msdn.com/dsimmons
http://blogs.msdn.com/efdesign/default.aspx
http://blogs.msdn.com/jkowalski/default.aspx
http://blogs.msdn.com/elisaj
http://www.thedatafarm.com/blog/
http://msmvps.com/blogs/matthieu/default.aspx
http://blogs.msdn.com/meek/default.aspx
http://blogs.msdn.com/alexj/default.aspx
http://blogs.msdn.com/timmall/
http://blogs.msdn.com/diego/

Source: http://www.renaissance.co.il/downloads/Entity%20Framework%20Essential%20Resources.pdf

Tuesday, September 29, 2009

Thumbnail image from database in ASP.NET

We often need to display images from database like profile photo of the user or something. Displaying images from database to an ASP.NET Image is not a big deal but maintaining the exact aspect ratio and displaying a web friendly image is very important. The following program will help us to do that.



The below code is written in the code behind page. Either the Width or Height of the image is specified. The second dimension is calculated by the program, maintaining the aspect ratio.

ImgPhoto.ImageUrl="ImageDisplay.aspx?Width=300&PhotoID=2";

ImageDisplay.aspx is a webpage which contains the following code. This page is used to retrieve the image from the database and generate a thumbnail of the dimensions given by the user.

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
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.Drawing;
using System.Drawing.Imaging;

public partial class ImageDisplay : System.Web.UI.Page
{
DAL_Users objUser=new DAL_Users();

protected void Page_Load(object sender, EventArgs e)
{
#region Page_Load

if (!IsPostBack)
{
int orgwidth = 0;
int orgheight = 0;
int imgwidth = 0;
int imgheight = 0;

byte[] bytes = null;
if (Request.QueryString["PhotoID"] != null)
bytes = (byte[])objUser.GetPhotoFromDatabase(Convert.ToInt32(Request.QueryString["PhotoID"].Trim()));
System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bytes);
Bitmap objBm = new Bitmap((Bitmap)System.Drawing.Image.FromStream(streamBitmap));

orgwidth = objBm.Width;
orgheight = objBm.Height;

imgwidth = objBm.Width;
imgheight = objBm.Height;

if (Request.QueryString["Width"] != null)
{
imgwidth = Convert.ToInt32(Request.QueryString["Width"].Trim());
imgheight = Convert.ToInt32((imgwidth * orgheight) / orgwidth);
}
else if (Request.QueryString["Height"] != null)
{
imgheight = Convert.ToInt32(Request.QueryString["Height"].Trim());
imgwidth = Convert.ToInt32((imgheight * orgwidth) / orgheight);
}

//Generate the Thumbnails
Bitmap objb2 = new Bitmap(objBm.GetThumbnailImage(imgwidth, imgheight, null, IntPtr.Zero));

//Converting Bitmap to Byte array
System.IO.MemoryStream stream = new System.IO.MemoryStream();
objb2.Save(stream, ImageFormat.Jpeg);
stream.Position = 0;
byte[] data = new byte[stream.Length];
stream.Read(data, 0, Convert.ToInt32(stream.Length));

objb2.Dispose();
objBm.Dispose();
bytes = null;
GC.Collect();

//Write the byte array
Response.BinaryWrite(data);
Response.End();
}

#endregion
}
}

Friday, September 25, 2009

Configuring Hotmail account in your Sony Ericsson Mobile phone

Recently I brought a Sony Ericsson W 705 and I wanted to configure my Hotmail account in it. GPRS is enabled in my phone and tried to configure using the wizard which will automatically configure the server information, but it didn’t so I tried to do it manually. I googled a lot for the configuration details and found one which is very useful. The following are the POP3 and SMTP details.

Incoming POP3:

Server: pop3.live.com
ssl
Port: 995

Outgoing SMTP:

Server: smtp.live.com
same as pop3
ssl
Port: 465

Wednesday, September 16, 2009

Random password generator

It is always a good practice that when ever a new public user registers in your web site, the system must send the credentials and the activation link to the user's email ID. It is beneficial in two ways, one to validate the email ID provided by the user and two, to send the system generated password, which can later be changed.


public string GetRandomPassword()
{
StringBuilder objSB = new StringBuilder();
objSB.Append(RandomString());
//objSB.Append(RandomNumber());
return objSB.ToString();
}

private string RandomString()
{
StringBuilder objSB = new StringBuilder();
Random objRandom = new Random();
char ch;
for (int i = 0; i < 8; i++)
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * objRandom.NextDouble() + 65)));
int x = objRandom.Next(1, 8);
if (x == i)
ch = Convert.ToChar(ch.ToString().ToUpper());
else
ch = Convert.ToChar(ch.ToString().ToLower());
objSB.Append(ch);
}
return objSB.ToString();
}

private int RandomNumber()
{
Random objRandom = new Random();
return objRandom.Next(234, 892);
}