Sunday, May 23, 2010

DataColumn.MaxLength not working in C#

DataColumn.MaxLength

Visual Studio Intellisense: Gets or Sets the maximum length of a text column.
MSDN: The maximum length of the column in characters. If the column has no maximum length, the value is –1 (default).

But most of the developers didn't able to get the desired result. It always returns -1. Microsoft has confirmed that this is a bug in the Microsoft products.

To resolve this, you need to set the "MissingSchemaAction" of "SqlDataAdapter" object. If you did not have it set, the ColumnLength property always returns -1.

Reference: http://support.microsoft.com/kb/317175

Example:

string strQuery = "SELECT * FROM tbl_MyTable";
objConn = new SqlConnection(strConnString);
objConn.Open();
objCmd = new SqlCommand(strQuery, objConn);
objDA = new SqlDataAdapter(objCmd);
objDA.MissingSchemaAction = MissingSchemaAction.AddWithKey;
objDS = new DataSet();
int iCount = objDA.Fill(objDS);

Monday, May 17, 2010

When the heart is more beautiful than the face!!!

"One of my friend forwarded me an email with this beautiful story. It's awesome and so decided to share this through my blog."

The rain pouring out heavily invited me for a rendezvous but then I had a session. Just as I checked the time on my cell, the knock at the door announced the arrival.

The assistant informed me of the client and I asked her to send them in.. The couple in their late twenties. A second later the door opened again and I beckoned them to come in..

This man came in … straight out of Bollywood or rather Hollywood.

Accompanying this 6+ft guy was this lady… Very thin , and looking unwell.
I wondered what brought them here. They didn’t look like your usual battlefield couples that come for counseling. Generally when couples came in the first noticeable thing they did was pulling chairs apart. Here he pulled it closer. Asked her if she was fine. The body language suggested care and concern. I sat back amused and let them speak.

This couple was married about 10 years back. A love marriage.. Intercaste marriage they braved many storms to be together .Then a couple of years back destiny struck.

She was diagnosed with ovarian cancer..The disease took a toll on her, drained her physically and psychologically. Her husband stood like the rock of Gibralter.. A pillar of strength.

Yet….

She now feels inadequate for various reasons. One her inability now to conceive, Two her looks that she thought was her identity and description She could not come to terms with the way she looked now. Her health was bad enough and her depression she thought was contagious spreading all around wherever she went.
She thought him too young to be saddled with problems and wished him a better life. She wanted a separation. She wanted him to move on with life..
She didn’t want to be responsible for ruining his youth, his future. She said she loved him and wanted to let him go… to live better.

The moment she said that I looked at her husband. He looked hurt. Deeply hurt.
This is what he had to say and this is what prompted me to write this blog:

“ I love her for what she is. Yes I liked her looks when I first met her but that was because that was the first noticeable thing, As I got to know her I realized how much more beautiful she is on the inside. I can never love anyone after I have experienced this beauty. Everyone else fails in comparison. What I see her as is her real self and to see her for her beauty you need to look through my eyes and not the mirror. The mirror has its set of lies and one of that is about her looks. To know her, look through me. I do not want any other happiness, I promised to be with her through thick and thin and I will be there no matter what. I will never leave her. She can throw me out , but I will continue living on the doorstep. I need her to know that these suggestions by her are an insult to my love. Is love only about looks?. Is beauty just about skin? If I were to go through the same would she leave me? I would never be able to do that. For me she is highly fecund , producing a higher degree love everytime I look at her. I love her truly and deeply and this is why I’m here to take your help and let her know the value of a relationship that goes beyond all these fallacies of appearances.”

What a magnanimous man!

I wasn’t the only one with tears, there was this beauty in front of me crying yet unaware of it. I excused myself and walked out.. I was glad they came to me though honestly all I did was listen to them but I saw a lovely example of true love. Their coming here was important for them and for me. To witness such love is a blessing.

These days when relations are so fragile and break at the slightest of excuses like:
She/ He is too fat
She can’t cook
She doesn’t work
He is hardly earning enough
We need space
He/She smokes/drinks
She isn’t glamourous enough
He/She can’t satisfy me
She/He doesn’t get along with inlaws , friends etc.

And many such excuses so inane , obfuscating the whole concept of marriages,just desperately searching a way out. This person purely defined something so perfect. Perfect love that transcends all these fallacies of looks.

This especially is so important when people marry only on the basis of looks. Yes the matrimonial columns are all about how slim and beautiful your bride needs to be. But then one must realize that EXTERNAL BEAUTY IS SO TEMPORARY. Beauty is just skin depth.. The true beauty lies within. Appreciate that and see love blossom.

Sunday, May 16, 2010

How to rename SharePoint Server?

Sometimes you may need to rename your Computer Name where SharePoint is installed. This also applies to Virtual Machines. I recently tried to do this, but after doing that, I found that SharePoint is not working. So I need to do few activities to bring it back, which I have been listed below:

Step 1: Rename my Computer/Server from My Computer -> Properties -> Computer Name - Change... -> Restart

Step 2: stsadm –o renameserver

Step 3: stsadm –o updatefarmcredentials

Step 4: Restart IIS

Step 5: Update all identity accounts(basically machine names) in IIS

Step 6: stsadm.exe -o setconfigdb

Step 7: All Programs -> Microsoft Office Server -> SharePoint Product and Technologies Configuration Wizard

Step 8 Open Central Admin and change Alternate Access Mappings, wherever applicable.

You are done. I found few other steps also while goggling. But the above steps work for me. The following references may help in case there are some issues:

http://blogs.sharepointlabs.com/Lists/Posts/Post.aspx?List=9312760c%2Dc235%2D4cc0%2Da25f%2D481a34785c3d&ID=6

http://moss-exchange.blogspot.com/2007/12/renaming-sharepoint-server.html

http://vspug.com/nrdev/2008/07/15/tip-how-to-rename-a-sharepoint-server-machine-name/http://vspug.com/nrdev/2008/07/15/tip-how-to-rename-a-sharepoint-server-machine-name/