Sunday, June 12, 2011

Developers guide: Overriding vs Overloading

...many developers may confusing between these two type of changes on Methods :
So lets say that Overriding is whrere that the signature is not going to change and only
we change the super class implementation of a method, such as a subclass,
but in Overloading we have two methods with different signature.

Monday, October 18, 2010

Pass external values with GridView HyperLinkField which are not part of the Gridview

As long as you only could use data sources members in NavigateUrl of GridView, I use this way to pass external values with GridView HyperLinkField which are not part of the Gridview :
For example I've an
_ID1 (a member of GridView) , _ID2(External data with sample value 100 as string), which should pass to my NavigateUrl, simply :

1. Define "protected string _ID = "100";" at top of class.
2. NavigateUrl=''
3. You are done.

Monday, January 18, 2010

BDC Import error: Could not create profile page for Entity

In SharePoint While you import the BDC (XML) file you may get this error:
"Could not create profile page for Entity 'xxx'.The error is: Cannot create a new connection to closed Web Part 'x-y-z' "
After 2 days searching with no practical solution I decide to solve it by myself by monitoring SQL and Web Parts underground, finally I've found and solved the solution.It worked to me 100%.
What is the error exactly?
While you create a specific finder for the BDC to profile it, (so "could not create profile..." warning solve by the way) then you may get the above error because one of the following reasons which I've found (you should do step by step in my order to get faster response):
Problem 1: You might close "Profile Page Template Web Part", when a BDC want to associate a profile to a template page it returns and error that : "Cannot create a new connection to closed Web Part".
Solution 1:
1. Go to the "Shared Services" admin page.
2. Under "Business Data Catalog" click on "Edit profile page template".
3. If you don't see the "Business Data Item" Web Part in the page go to Step 4 , otherwise go to Problem 2 .
4. Navigate to Site Actions->Edit Page then click on "Add a Web Part", this will open a page.
5. On the opened "Add Web Part to Top Zone" page, click on "Advanced Web Part gallery and options".
6. On the "Add Web Parts", click on "Closed Web Part" and select "Business Data Item" and drag to the page to restore it.
7. click "Exit Edit Mode" (on top right).
8. You done.So back to the BDC import page and import the BDC.
Problem 2: Check Problem 1 first.Do not waste your time. If did so, your problem is you closed a web part in which may did not remove from SQL correctly.
Solution 2:
1. I've coded a TSQL to solve faster and safe, so copy the uniqueidentifier for the close web part from the error message, for example mark and copy the bold section:
"The error is: Cannot create a new connection to closed Web Part g_38004421_f6ad_4880_807a_8c90bcf42f4a "
note that I do not mark and copy "g_".
2. open SQL management studio and query this script. Replace the bold parameters with yours:
USE WSS_Content
DECLARE @Id nvarchar(50)
DECLARE @WId nvarchar(50)
SELECT @WId = 'UNIQUEIDENTIFIER '
SELECT @Id =(
SELECT id FROM AllDocs
WHERE id =(
SELECT tp_PageUrlID FROM WebParts
WHERE tp_id like '%' + @WId + '%' ))
DELETE FROM WebParts
WHERE tp_PageUrlID like '%' + @Id + '%'
DELETE FROM AllDocs
WHERE id like '%' + @Id + '%'
The code above find the UID that cause the error in the WebParts table and AllDocs related object, then delete them.
All works to me. Hope you too.

Sunday, January 17, 2010

SharePoint WebPart Tips and Tricks

To view and manage all Web Parts within a page or see the status of them, simply append "?contents=1" to a given URL page. for example:
http://vsmoss/sites/intranet/some_reports.aspx
would be:
http://vsmoss/sites/intranet/some_reports.aspx?contents=1
brings you to the Web Part Page Maintenance Some_Reports

Tuesday, November 10, 2009

SharePoint 2007 Infopath Web Service Data Connection obscured problem

The issue is very obscured, and as I knew so many admins and developers have the same problem.You could search google if I was not right....
The problem: When you want to create a Web Service Data Connection for Infopath form, after entering the WSDL (web service) URL get the obscured error that says: "Invalid XML document or access denied or so on".
Causes: In fact the problem is not access permission nor invalid XML, so invalid URL for WSDL causes the issue.
Solution: in the web browser open the URL of the web service, if it opened, Click on Service Description link at the line 1 of the page, if you got blank page the URL for web service is not correct, otherwise you will get the coded XML page(right place).
For example you may type the incorect URL for WSDL but the URL exist: http://SERVERNAME/_vti_bin/SERVICE.asmx -> Exist
http://SERVERNAME/_vti_bin/SERVICE.asmx?WSDL ->(After Click) NOT Exist = blank page
even if the URL was incorrect you could open it on your browser but if you click on the Service Desciption link you will get the blank page.In fact the correct path is (to me was):
http://SERVERNAME/Sites/Intranet/_vti_bin/SERVICE.asmx -> Exist
http://SERVERNAME/Sites/Intranet/_vti_bin/SERVICE.asmx -> (After Click) Exist = XML coded page

Wednesday, September 09, 2009

Mapping Sql Data Type to System Type

//C#
private Type DeriveCLSType(SqlDataType _SqlDataType)
{
Type typ = GetType();
switch (_SqlDataType)
{
case SqlDataType.BigInt:
typ = Type.GetType("System.Int64");
break;

case SqlDataType.Bit:
typ = Type.GetType("System.Boolean");
break;

case SqlDataType.Char:
case SqlDataType.VarChar:
case SqlDataType.VarCharMax:
typ = Type.GetType("System.String");
break;

case SqlDataType.DateTime:
case SqlDataType.SmallDateTime:
typ = Type.GetType("System.DateTime");
break;

case SqlDataType.Decimal:
case SqlDataType.Money:
case SqlDataType.SmallMoney:
typ = Type.GetType("System.Decimal");
break;

case SqlDataType.Int:
typ = Type.GetType("System.Int32");
break;

case SqlDataType.NChar:
case SqlDataType.NText:
case SqlDataType.NVarChar:
case SqlDataType.NVarCharMax:
case SqlDataType.Text:
typ = Type.GetType("System.String");
break;

case SqlDataType.Real:
case SqlDataType.Numeric:
case SqlDataType.Float:
typ = Type.GetType("System.Double");
break;

case SqlDataType.Timestamp:
case SqlDataType.Binary:
typ = Type.GetType("System.Byte");
break;

case SqlDataType.TinyInt:
case SqlDataType.SmallInt:
typ = Type.GetType("System.Int16");
break;

case SqlDataType.UniqueIdentifier:
typ = Type.GetType("System.Guid");
break;

case SqlDataType.UserDefinedDataType:
case SqlDataType.UserDefinedType:
case SqlDataType.Variant:
case SqlDataType.Image:
typ = Type.GetType("System.Object");
break;

default:
typ = Type.GetType("System.String");
break;
}
return typ;
}

Thursday, August 10, 2006

Homeland Security: Fix your Windows

In a rare alert, the U.S. Department of Homeland Security has urged Windows users to plug a potential worm hole in the Microsoft operating system...

The agency, which also runs the United States Computer Emergency Readiness Team (US-CERT), sent out a news release on Wednesday recommending that people apply Microsoft's MS06-040 patch as quickly as possible. The software maker released the "critical" fix Tuesday as part of its monthly patch cycle.
"Users are encouraged to avoid delay in applying this security patch," the Department of Homeland Security said in the statement. The patch fixes a serious flaw that, if exploited, could enable an attacker to remotely take complete control of an affected system, the agency said.
Microsoft on Tuesday issued a dozen security bulletins, nine of which were tagged "critical," the company's highest severity rating. However, the flaw addressed in MS06-040 is the only one among the updates that could let an anonymous attacker remotely commandeer a Windows PC without any user interaction.
The flaw has some similarities to the Windows bug that enabled the notorious MSBlast worm to spread in 2003. Both security vulnerabilities are related to a Windows component called "remote procedure call," which provides support for networking features such as file sharing and printer sharing.
"Blaster took advantage of a vulnerability in the same service. We recognize that this is something that is easily exploitable," said Amol Sarwate, the manager of vulnerability research lab at Qualys. "It is excellent that DHS sent out this alert, because I think a lot of people are vulnerable."
Microsoft has seen a "very limited attack" that already used the newly disclosed flaw, the software maker said Tuesday.
Overnight, some hacker toolkits were updated with code that allows researchers to check for the flaw and exploit it, said Neel Mehta, a security expert at Internet Security Systems in Atlanta.
"This is a very serious vulnerability," Mehta said. "At the moment, this exploit is being used in targeted attacks to compromise specific systems. However, there is nothing about the nature of the vulnerability that prevents it from being used in a much more widespread fashion as part of a worm."
Microsoft worked with the Department of Homeland Security on the alert, a company representative said. "Microsoft...encourages customers to deploy this update on their systems as soon as possible, given that we are aware of targeted exploitation of the vulnerability," the representative said.
Microsoft deems the vulnerability critical for all versions of Windows. However, users of Windows XP with Service Pack 2 and Windows Server 2003 with Service Pack 1 should be protected by the Windows Firewall if they do not use file sharing and printer sharing, Christopher Budd, a security program manager at Microsoft, said in an interview Tuesday.
The Microsoft updates are available via the Windows Update and Automatic Updates tools as well as from Microsoft's Web site. Temporary workarounds are outlined in the security bulletins for those who can't immediately apply the patches.

By Joris Evers, CNET News.com
Published on ZDNet News: August 9, 2006, 10:37 AM PT