Wednesday, March 16, 2011

Database development considerations

Many of us intentionally or unintentionally do not plan application Background for high availability website or application. This create frustration at both end, I mean it exhausts developers that they are unable to develop a robust application on the same token it frustrates the client who is not getting optimum performance from the application. Purpose of following note is to create a check list that should be complied before delivering any product for quality assurances. I coloring the points, red mean critical, blue means important and green means supportive.

1. Do plan database for its purpose, if it is for online transaction processing it should be normalized and should not violate normalization rules. No matter how much it boosts the database processing. Please consider following notes for OLTP databases.

i. Create multiple file groups for multiple set of tables like a file group for indexes, file group for lookup items and a file group for transaction. It’s better to create multiple groups to optimize disk IO.

ii. Make sure that your transactions are precise and they are short enough to avoid deadlocks. These transactions should be developed in a way that single stored procedure is handling a complete set of insertion or update.

iii. Database backups should be configured at minimum usage hours, although SQL server supports transactions while taking backups however the client responses become slower during backup.

iv. Make sure that you are using table partitioning if there is a large amount of data, because a huge table size has a worse impact on tables’ insertions and updates.

v. When trying to develop OLTP part of any application make sure that you are using minimum number of indexes, it has a negative impact on performance.

vi. Optimum hardware configuration to handle the large numbers of concurrent users and quick response times required by an OLTP system.

vii. Try to configure server to support max degree of parallelism, by default this attribute is disabled and SQL server does not perform parallelism for queries, so server performance can be enhanced by enabling this feature.

viii. increase the 'min memory per query' option to improve the performance of queries that use hashing or sorting operations, if your SQL Server has a lot of memory available and there are many queries running concurrently on the server.

ix. You can increase the 'max async IO' option if your SQL Server works on a high performance server with high-speed intelligent disk subsystem.

x. With usage of table indexes become really slow, it’s better to run dbcc dbreindex with a proper fill factor regularly to optimize performance.

xi. You are using database with full recover option and mirroring is configure then it’s better to increase the recovery interval. This will have a positive impact on database performance.

xii. If database requires a lot number concurrent request try to increase max number of work thread and you can also use the priority boost to 1. Make sure to increase priority only if the server is dedicated for SQL server operations otherwise it will have negative impact on application due to sql server priority.

xiii. Too many table joins for frequent queries. Overuse of joins in an OLTP application results in longer running queries & wasted system resources. Generally, frequent operations requiring 5 or more table joins should be avoided by redesigning the database.

xiv. Too many indexes on frequently updated (inclusive of inserts, updates and deletes) tables incur extra index maintenance overhead. Generally, OLTP database designs should keep the number of indexes to a functional minimum, again due to the high volumes of similar transactions combined with the cost of index maintenance.

xv. Big IOs such as table and range scans due to missing indexes. By definition, OLTP transactions should not require big IOs and should be examined.

xvi. Unused indexes incur the cost of index maintenance for inserts, updates, and deletes without benefiting any users. Unused indexes should be eliminated. Any index that has been used (by select, update or delete operations) will appear in sys.dm_db_index_usage_stats. Thus, any defined index not included in this DMV has not been used since the last re-start of SQL Server.

xvii. Signal waits > 25% of total waits. See sys.dm_os_wait_stats for Signal waits and Total waits. Signal waits measure the time spent in the runnable queue waiting for CPU. High signal waits indicate a CPU bottleneck.

xviii. Plan re-use < 90% . A query plan is used to execute a query. Plan re-use is desirable for OLTP workloads because re-creating the same plan (for similar or identical transactions) is a waste of CPU resources. Compare SQL Server SQL Statistics: batch requests/sec to SQL compilations/sec. Compute plan re-use as follows: Plan re-use = (Batch requests - SQL compilations) / Batch requests. Special exception to the plan re-use rule: Zero cost plans will not be cached (not re-used) in SQL 2005 SP2. Applications that use zero cost plans will have a lower plan re-use but this is not a performance issue.

xix. Parallel wait type cxpacket > 10% of total waits. Parallelism sacrifices CPU resources for speed of execution. Given the high volumes of OLTP, parallel queries usually reduce OLTP throughput and should be avoided. See sys.dm_os_wait_stats for wait statistics.

xx. Consistently low average page life expectancy. See Average Page Life Expectancy Counter which is in the Perfmon object SQL Server Buffer Manager (this represents is the average number of seconds a page stays in cache). For OLTP, an average page life expectancy of 300 is 5 minutes. Anything less could indicate memory pressure, missing indexes, or a cache flush.

xxi. Sudden big drop in page life expectancy. OLTP applications (e.g. small transactions) should have a steady (or slowly increasing) page life expectancy. See Perfmon object SQL Server Buffer Manager. Small OLTP transactions should not require a large memory grant.

xxii. Sudden drops or consistenty low SQL Cache hit ratio. OLTP applications (e.g. small transactions) should have a high cache hit ratio. Since OLTP transactions are small, there should not be, big drops in SQL Cache hit rates or consistently low cache hit rates < 90%. Drops or low cache hit may indicate memory pressure or missing indexes.

xxiii. Normally it takes 4-8ms to complete a read when there is no IO pressure. When the IO subsystem is under pressure due to high IO requests, the average time to complete a read increases, showing the effect of disk queues. Periodic higher values for disk seconds/read may be acceptable for many applications. For high performance OLTP applications, sophisticated SAN subsystems provide greater IO scalability and resiliency in handling spikes of IO activity. Sustained high values for disk seconds/read (>15ms) does indicate a disk bottleneck.

xxiv. High average disk seconds per write. The throughput for high volume OLTP applications is dependent on fast sequential transaction log writes. A transaction log write can be as fast as 1ms (or less) for high performance SAN environments. For many applications, a periodic spike in average disk seconds per write is acceptable considering the high cost of sophisticated SAN subsystems. However, sustained high values for average disk seconds/write is a reliable indicator of a disk bottleneck.

xxv. Big IOs such as table and range scans due to missing indexes.

xxvi. Index contention. Look for lock and latch waits in sys.dm_db_index_operational_stats. Compare with lock and latch requests.

xxvii. High average row lock or latch waits. The average row lock or latch waits are computed by dividing lock and latch wait milliseconds (ms) by lock and latch waits. The average lock wait ms computed from sys.dm_db_index_operational_stats represents the average time for each block.

xxviii. Block process report shows long blocks. See sp_configure “blocked process threshold” and Profiler “Blocked process Report” under the Errors and Warnings event.

xxix. High number of deadlocks. See Profiler “Graphical Deadlock” under Locks event to identify the statements involved in the deadlock.

xxx. High network latency coupled with an application that incurs many round trips to the database.

xxxi. Network bandwidth is used up. See counters packets/sec and current bandwidth counters in the network interface object of Performance Monitor. For TCP/IP frames actual bandwidth is computed as packets/sec * 1500 * 8 /1000000 Mbps.

a. Excessive fragmentation is problematic for big IO operations. The Dynamic Management table valued function sys.dm_db_index_physical_stats returns the fragmentation percentage in the column avg_fragmentation_in_percent. Fragmentation should not exceed 25%. Reducing index fragmentation can benefit big range scans, common in data warehouse and Reporting scenarios

2. If you are developing a database for decision support system or for analytical processing please follow following general rules and guidelines.

a. Better to develop data marts based on database trend analysis requirements.

b. Merge non key attributes with key attribute using views and tables for optimum retrieval.

c. Use of a star or snowflake schema to organize the data within the database.

d. Estimate the sizes of clustered and non-clustered indexes.

3. Now i am trying to list down general guidelines for database optimization.

a. If database size is less than 200mb then it’s better to use file growth in megabytes. However if it increase better to define in percentages.

b. Do not insert heavy object in the database if they are not required in transactions because they increase database size and it really hurts the performance.

c. If you have really a lengthy operation in the stored procedure better to use SQL query short circuiting, this enhance the query performance by avoiding unnecessary joins and where clauses.

d. Must use where clause to otherwise it will slow down the performance. Even if there is an option that say search all do not fetch all rows from database.

e. Try to implement paging in stored procedure level for large amount of data; if this is to be done on front end it will cause timeout operations.

f. Do not use char, varchar fields’ for comparison operations and joins, it better to use integers always. Use isnull function for parameters to avoid unwanted comparisons in the database.

g. Always prefer to mention fields names rather than * operations, because wildcards are negative for performances.

h. Use views and stored procedure instead of heavy queries. Do not use cursors, try to avoid count (*).

i. Since triggers are heavy for operations better to use constraints, this helps to validate data prior to insert.

j. It is preferred to use table variables rather than temp tables but it better to check either you are in a transaction or not and if this transaction is handle by MSDTC. You may face invalid data operations with usage of variables because they not terminated properly.

k. Do not use having or distinct in your queries because require reprocessing of result set.

l. Prefer to use locking hints with queries, as in a previous document I mentioned to use nolock or rowlock or updlock.

m. Use select statements with the TOP keyword or the SET ROWCOUNT statement if you need to return only the first n rows. OR Use the FAST number_rows table hint if you need to quickly return 'number_rows' rows.

n. Prefer to use union all instead of union in queries.

o. Do not guide SQL for query optimization hints if you are now sure about them, better to leave this part with SQL server to decide.

p. Don’t use top 100 percent with in your sql statements this switch guides the sql server to fetch a count of 100 rows based on the data sampling. This clause have really negative effect on the query.

q. Try to use latest feature of SQL server cross apply rather using cursors.

Thursday, March 10, 2011

Web UI Considerations

Following are some Guidelines, Suggestions and recommendation for designing web applications please do consider these for site performance and SEO as they are really helpful. This is the first version of guidelines I will try to draft more in coming days.

· Do your layout with divs

· Please don’t use tables even though they work fine

· Describe the DOCTYPE so the browser can relate

· Check in all browsers

· Title everything including links and images

· Don’t use <b(old)>, please use <strong> ’cause if you use <b(old)> then it’s all then wrong. All other obsolete tags should be avoided and use tags for HTML 4.0.

· Do not use GIF format of images because it does not support enrich graphics

· Use Resolution of 1024X768 as 56~65% internet users has this resolution

· Use common fonts like serif, sans-serif, Arial. because if you use special fonts which are not installed on client machine it will cause the site to be displayed in browser default font.

· do consider Accessibilities option because almost 40% of overall internet user suffer due to some disabilities

· do not use bgcolor

· do mention the width of li Items as they treated differently within each browsers

· use Breadcrumbs in navigation so the user could understand where he/she is

· Navigations should not be in JavaScript because it makes complicated for the crawlers

· for better CSS understanding use ASP.NET control Adapters to apply perfect CSS

· do not Use server side includes as they poses many issues for the UI designs use Master pages instead

· use User Controls only when required because 1. you don’t know who it will look like until you reach the browser,2. state management is really difficult and it cases more server load than normal, 3) reusability causes more control flows which ultimately effects the performance.

· When working master page do use content templates in header to customize meta elements for each content page

· to transfer data between master class and content classes use public properties or user mastertype or property master

· if only 1 master page is enough then mention this in web.config instead of mentioning on each page

· use nested master pages only when requires

· Utilize Master pages for Header and footer.

· Utilize ASP.Net content pages to design inside pages.

· Use server side asp.net controls for everything, instead of html.

· Create XML Sitemaps.

· Create custom error page (404). Showing error to the user not only frustrates but it also cause server vulnerable to oracle attack

· Always use character code when it’s available like for trademark, registered, copyright sign, etc.

· Avoid Inline CSS

· All design tags are supposed to be in external CSS file, no inline style tags.

· Do not use spaces (&nbsp;) for layout purposes; use CSS instead.

· Use of 301 and 302 redirects.

· to make controls consistent use themes instead of native attributes specially with container controls like, panel, gridview and data repeaters

· since themes apply after the CSS you can StyleSheetThems where you want to override the theme with CSS

· make sure that your page size and JavaScript code are not heavy since JavaScript is interpreted so a large page volume will affect the page performance.

· Use Viewstate objects only when they are required because they are heavy and encrypted causing more data flow back and forth wither the server.

· Encrypt information in web.config because an attacker can download the web.config

· Use regular expression instead of loops in JavaScript to Optimize page performance.

· When a page is getting larger enough do consider information splitting options. Never try to make web application as windows form.

For someone who don’t want to read whole guidelines can listen to this

Developers SEO Considerations

Every day we come office to develop applications, however it is really important if these application works better and able to gather more and more customers. following is a list of point that must be considers when develop a web application or a website in order to make sure that it will work perfectly for the search engines.

· Make sure each new page in a web site has it title text and it referenced though likes or site maps. pages without a reference gets lower priority by the search engines

· make sure that you are using headings instead of bulky images. all search engines considers headings for indexing rather images.

· on page content make sure that you have a heading (H1) with exactly same title as of page furthermore located as far to the top and left of page as possible

· Make sure that headings are properly mentioned on page and it they use heading tags like h1,H2, H3 rather font size. moreover each heading should be strong for SEO

· Make sure that title of the page is meaningful for example instead of page1 it should "TRxLink-homepage".

· Public site content should be HTML rather than Flash, Images, Silver Light, JavaScript’s

· Make sure that you not using Frame at any cost. no matter what happens Avoid Frames.

· site should not use scripts for redirection for example we have web site in a folder abc and a script file on root website redirects is to the folder where we have index page. this site will never will indexed by Search engine because of redirection

· make sure each page has a meta tag and it has meaningful phrases like "Online Purchasing system", these meta should be less than 64 words a large is treated as spam by search engines and they usually keep its rating lower

· make sure that meta key words and meta descriptions are meaningful to the page. if a page content has nothing to do with meta descriptions and keywords it ratings ultimately dropped by search engine due because it is treated as scam for SEO

· make sure that meta tags are listed in order of importance not arbitrarily furthermore it should Meta keywords and description include singular, plural and variations in spelling of core keywords. for example Purchase order, Purchase Orders, Online Purchase order, Online Purchase Orders, PO, Online PO

· make sure Meta description tag is present on each page and properly filled with keywords which are relevant to page.

· make sure that image names on pages should be properly defined not just img1, img1, imgheader because some engines confirms page meta with images names

· make sure all the clickable images have alt tags that include appropriate keywords.

· make sure that key phrase appropriately sprinkled throughout the page’s text content.

· each image on content  page should have height and width attribute

· make sure that menus are static and not loading from databases dynamic and exploding menus often skipped by Search engines

· all hyperlinks or <A> are wrapped properly with keywords for long pages

· make sure all pages have header and footers for consistency and SEO

· make sure site map is available in html, xml formats and it includes all pages.

· make sure to use title and Alt for all important tags like images and hyperlinks.

· make sure page body has at least 150 words of description which is static otherwise page will be skipped

· if changing site content place sure that you have configured 301 redirects for all old pages to new pages.

· Make sure your analytics code has been appropriately placed on all pages within the new site.

· Check for any broken navigation, internal or external links.  – I suggest doing this a second time as you launch just be certain everything is working as intended

· make sure each page is having different content otherwise your page rank will be decreased

· below is a list of html tags and their preference in search engines try use important ones.

Tag Name

Essential

Somewhat Important

No Influence

Unfavorable

<h1>...<h6>

     

<title>

     

<b>

 

   

<i>

 

   

<img>

 

   

<meta>

 

   

<u>

 

   

<a>

   

 

<body>

   

 

<br>

   

 

<center>

   

 

<font>

   

 

<head>

   

 

<li>

   

 

<ol>

   

 

<p>

   

 

<table>

   

 

<td>

   

 

<tr>

   

 

<ul>

   

 

<frame>

     

<frameset>

     

Tuesday, March 1, 2011

HOW TO: Enable the build-in Administrator account in Windows Vista

To enable the build-in Administrator account, follow these steps:
1. Click Start, and then type cmd in the Start Search box.
2. In the search results list, right-click Command Prompt, and then click Run as Administrator.
3. When you are prompted by User Account Control, click Continue.
4. At the command prompt, type net user administrator /active:yes, and then pressENTER.
5. Type net user administrator , and then press ENTER.
Note: Please replace the tag with your passwords which you want to set to administrator account.
6. Type exit, and then press ENTER.
7. Log off the current user account.

Thursday, February 10, 2011

Email Enabled document Libraries in share point

Although its simple and you use best document available on internet by www.combined-knowledge.com

there is only 1 catch that was left in the document and every time configure it stuck with the same issue that we need to configure a virtual SMTP server with the same name as of you DNS name like in my I had project.abcdomain.com now SMTP virtual server be with this named instance, default instance will not work I don’t know but this is what happens to me always and I wasted hours and hours in debugging whole exchange and sharepoint.

Document available here

https://sites.google.com/site/ihsanmalikir/HowtoconfigureEmailEnabledListsinMoss2007RTMusingExchange2007.pdf?attredirects=0&d=1

http://www.combined-knowledge.com/Downloads/2007/Beta/How%20to%20configure%20Email%20Enabled%20Lists%20in%20Moss2007%20RTM%20using%20Exchange%202003.pdf

Tuesday, February 8, 2011

Trailing slash at the end of aspx page name

so many days in searching and so many days without a solution a long running problem at my end but finally I found a solution.

the problem is actually when you append a slash at the end of any aspx page it does not generate 404 rather it display same page without any CSS or images because not IIS treat this a folder rather than as a page. however there no clear way resolve this issue. and the SEO people were shouting and make noises as usual that their page rating is going down due to mutiple page with same content means let say

aboutus.aspx

aboutus.aspx/

and

aboutus.aspx/default.aspx

are three wrong pages with same content. so resolve this issue with the help of pageinfo variable, if there is any request which has some pageinfo then redirect it to same url without page info in global.asax see following code snippet.

public void Application_BeginRequest(object sender, EventArgs e)

    {

if (!String.IsNullOrEmpty(Request.PathInfo))

        {

            Response.Redirect(Request.RawUrl.Remove(Request.RawUrl.LastIndexOf("/")));

        }

//throw new HttpException(404,"File not found.");

    }

http://msdn.microsoft.com/en-us/library/system.web.httprequest.pathinfo.aspx#Y280

Friday, January 21, 2011

Flat File pipeline in BizTalk 2010

thing are getting changed day by day and lazy enough to understand these. for example today when I deployed a BizTalk solution I got the error something like missing project resource  Please verify that the pipeline strong name is correct and that the pipeline assembly is in the GAC.

upon investigation I realized that now BTS projects are not deployed to the GAC I don’t know but  now we have this situation so you have to manually add the project to global Assembly Cache using GaCUtil –I “Assemblyname.dll” once you do that then you application will start working fine. I also learn that now there are two separate GACs one for .NET version 4.0 and one for old .net application. so whenever you get an error like this don’t forget to add your project file to GAC.

In .NET Framework 4.0, the GAC went through a few changes. The GAC was split into two, one for each CLR.

The CLR version used for both .NET Framework 2.0 and .NET Framework 3.5 is CLR 2.0. There was no need in the previous two framework releases to split GAC. The problem of breaking older applications in Net Framework 4.0.

To avoid issues between CLR 2.0 and CLR 4.0 , the GAC is now split into private GAC’s for each runtime.The main change is that CLR v2.0 applications now cannot see CLR v4.0 assemblies in the GAC.

It seems to be because there was a CLR change in .NET 4.0 but not in 2.0 to 3.5. The same thing happened with 1.1 to 2.0 CLR. It seems that the GAC has the ability to store different versions of assemblies as long as they are from the same CLR. They do not want to break old applications.

See the following information in MSDN about the GAC changes in 4.0.

For example, if both .NET 1.1 and .NET 2.0 shared the same GAC, then a .NET 1.1 application, loading an assembly from this shared GAC, could get .NET 2.0 assemblies, thereby breaking the .NET 1.1 application

The CLR version used for both .NET Framework 2.0 and .NET Framework 3.5 is CLR 2.0. As a result of this, there was no need in the previous two framework releases to split the GAC. The problem of breaking older (in this case, .NET 2.0) applications resurfaces in Net Framework 4.0 at which point CLR 4.0 released. Hence, to avoid interference issues between CLR 2.0 and CLR 4.0, the GAC is now split into private GACs for each runtime.
As the CLR is updated in future versions you can expect the same thing. If only the language changes then you can use the same GAC.

source and http://www.techbubbles.com/net-framework/gac-in-net-framework/

Tuesday, January 18, 2011

Diagnosing Routing Failures in BizTalk Server 2006

BizTalk Server 2006 offers some tools that can make it easier to diagnose routing failures in your BizTalk deployments, with the help of the new query facilities in the BizTalk Server 2006 Administration Console. Imagine for example that you've got an incoming message through a receive location that failed routing and was suspended.

The first thing you'll want to do is open up the BizTalk Server 2006 Administration Console, go to the Group Hub page and create a new query. To diagnose a routing failure, you can do two different queries.

Querying for Messages
The first possible query is to query for messages. If a routing failure occurred, you will find the message listed in the results pane in the "Suspended (resumable)" state, as the following screenshot shows:

The first record you see in the screenshot above (the one where the MessageType field is empty) is the actual message that failed routing. If you double click on it, you will see a new dialog window open where you can see the message details, as well as the message context and even the content of each part associated with the message. This is one of my favourite windows in the new UI because it is much more usable than the old HAT windows.

The second record you see in the results pane, however, is far more interesting. This one is actually a Routing Failure Report pseudo-message, which has no actual body, but contains the real state (and message context) of the message at the point the routing failure occurred. You can always recognize an RFR because its Service Class field contains the value "Routing Failure Report".

Since the Routing Failure Report contains the real message context, you can use it to check if the expected context properties were promoted, and what the values of them were. So this is the place to look for if you feel that perhaps the routing problem occurred because your pipeline or adapter didn't promote the right values or the right properties.

Querying for services
You can also start by querying for suspended service instances (message receives/sends are also service instances):

The Messaging Service Instance is the actual instance that was suspended. By opening up the Service Details window, you can look at the exact error message that was logged in the Error Information tab:

The published message could not be routed because no subscribers were found. This error occurs if the subscribing orchestration or send port has not been enlisted, or if some of the message properties necessary for subscription evaluation have not been promoted. Please use the Biztalk Administration console to troubleshoot this failure.

You can also see the list of messages associated with this service instance (in this case only one) in the Messages tab of the window.

By analogy, the Routing Failure Report instance is a service instance associated with the routing failure report; from here you can get access to the Routing Failure Report message as well.

Troubleshooting the routing failure
One really interesting option here is that you can right-click on either of the suspended service instances in the Query Results pane and you'll see a new "Troubleshoot Routing Failure" submenu with some options to help you diagnose why the routing failure happened:

  • The Find failed service instance option will run a new query that will find you the specific service instance that failed. It is not as useful in the above example because we already new exactly what service instance it was (it had been already returned in the original query), but in cases where you have hundreds of service instances, this can make it a lot easier to find the relevant instance.
  • The Show all subscriptions option will open a new query window that queries for all subscriptions defined in the message box.
  • The Show all active subscriptions option is the same as above, but it filters the results so that only subscriptions in an Active state are returned.
  • The How to troubleshoot routing failures option will open up the help topic on troubleshooting routing failures in the BizTalk help.

As you can see, BizTalk Server 2006 makes it much easier to see what’s going on in your environment and does offer a few new options integrated into the management console itself; instead of having to go through HAT to view all this stuff. Also, the new UI is great, far more usable than what HAT provided (though you still need to go to HAT for some scenarios including orchestration debugging), and gives you a much more integrated view of how subscriptions, service instances and messages relate to each other.

http://winterdom.com/2006/03/diagnosingroutingfailuresinbiztalkserver2006

Tuesday, January 11, 2011

How to Remove Watermark (Build Info) from Desktop in Windows Vista, 7 and Server 2008 (Both 32-bit and 64-bit) Including All Beta Builds and Service Packs

When we install a Beta or RC build of Windows Vista, 7 or Server 2008, or when we install a Beta or RC version of a Service Pack e.g. SP1, SP2, etc, a watermark is shown on Desktop which looks similar to following screenshot:

alt

"Evaluation Copy", "For testing purpose only", "Test Mode", "Safe Mode" or similar text is shown in the watermark on Desktop.

It looks ugly when you use dark wallpapers and becomes irritating sometimes. If you also don't like this watermark and want to get rid of it, here are 2 great tools to remove this watermark:

  • Universal Watermark Remover
  • Remove Watermark

Universal Watermark Remover

"Universal Watermark Remover" is an excellent small and portable utility created by "Orbit30" which can remove the ugly watermark from Windows Vista, 7 and Server 2008 Desktop. It works for both 32 and 64-bit versions of Windows.

alt

Download Link

Just download it using the above link, run the EXE file and follow the instructions. You'll need to restart your system to take affect.

Remove Watermark

"Remove Watermark" is another awesome portable tool created by "deepxw" which can remove watermark from Windows Vista, 7 and Server 2008 Desktop. It works for both 32-bit and 64-bit versions. Even it works for all languages and service packs.

Remove_Watermark.png

Download Link

Mirror

Download the ZIP file, extract it and run the correct EXE file for your Windows version. It'll ask for confirmation, press Y to confirm and patch the system file to remove watermark.

64-bit version users will also need to rebuild MUI cache. After patching file, run the tool again and press R to rebuild MUI cache.

PS: You can also manually remove the watermark or customize watermark using following tutorial:

Show Your Desired Text on Desktop by Customizing Windows Build Number

Source

Thursday, December 30, 2010

Length of LOB data (96896) to be replicated exceeds configured maximum 65536.

Error:

Length of LOB data (78862) to be replicated exceeds configured maximum 65536

Scenario:

We published some articles that use varchar(max) and a lot of XML data types for the columns. When we enabled replication, we got the error Length of LOB data (78862) to be replicated exceeds configured maximum 65536

Solution:

Increase the size that can be replicated. This is applicable for transactional replication only.

T-SQL: 
EXEC sp_configure ‘max text repl size’, 2147483647

SSMS (excerpt from BOL):

    1. In Object Explorer, right-click a server and select Properties.
    2. Click the Advanced node.
    3. Under Miscellaneous, change the Max Text Replication Size option to the desired value.

Reference:

BOL ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/3056cf64-621d-4996-9162-3913f6bc6d5b.htm

Tuesday, December 28, 2010

Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission.

during Replication i faced this issue reason was simple that user prefix was not working properly in SQL server 2005. here is how to do it.

This problem occurs because SQL Server 2005 cannot obtain the information about the context when you try to impersonate a database user to run a statement or a module.

SQL Server cannot obtain the information about the context that you are trying to impersonate under the conditions that are listed in the "Symptoms" section. If you impersonate a SQL Server authorization login, SQL Server cannot find a login that matches the security identifier (SID) of the impersonated user. If you impersonate a domain user, the domain controller cannot find the information about the specific user who matches the SID of the impersonated user.

To work around this problem, change the database owner to a valid login or domain user. To do this, run the following statements:

USE
GO
sp_changedbowner ''

Note represents the name of the database. represents the name of the login that you want to set.
http://support.microsoft.com/kb/913423
related one
http://awesomesql.wordpress.com/2010/02/08/sql-error-cannot-execute-as-the-database-principal-because-the-principal-sec_user-does-not-exist-this-type-of-principal-cannot-be-impersonated-or-you-do-not-have-permission/
http://dbaspot.com/forums/ms-sqlserver/354286-event-id-28005-error-15517-a.html
http://dbaspot.com/forums/ms-sqlserver/231821-re-cannot-view-database-properties.html
the best way to do it
http://msdn.microsoft.com/en-us/library/ms176060.aspx
http://forums.devx.com/showthread.php?t=150354

the way to do it
USE databsename
GO
--sp_changedbowner sa Run this first to change the owenber of the database to sa because we are processing with sa account
--ALTER AUTHORIZATION ON DATABASE::EmployeeDB TO sa then run this command to change the authorization schema.

Friday, December 24, 2010

CRM 4.0 IIS 7.5 Unable to Display Static Content

many suggestions like
http://romikoderbynew.wordpress.com/2010/10/27/dynamics-crm-4-0-windows-server-2008iis-7-5-install-problems/
and
http://telligent.com/support/telligent_evolution_platform/community/f/533/t/1059142.aspx
but none of these worked for me then found following article on msdn which was good and it resolved the problem
how to resovle see below.l
To resolve this problem, install the Static Content feature of the Common HTTP Features under the Web Server role on the webserver. If the Static Content feature is already installed, then simply edit the StaticFileHandler mappings using the IIS Manager user interface to add StaticFileModule to the module list.



To install the Static Content feature on Windows Server 2008 and Windows Server 2008 R2, follow these steps:

a. Open Server Manager, and then expand Roles.
b. Right-click Web Server (IIS), and then click Add Role Services.
c. Under Web Server, click to select the "Static Content" check box.
d. Click Next to complete the installation.
Then
To edit the StaticFileHandler mappings, follow these steps:

a. Click Start, type Inetmgr in the Start Search box, and then click Inetmgr in the Programs list.

Note If you are prompted for an administrator password or for a confirmation, type the password or click Continue.

b. In IIS Manager, expand server name, expand Web sites, and then click the web site that you want to modify the settings for.

c. In Features view, double-click Handler Mappings.

d. In the Handler Mappings pane, right-click the StaticFile handler mapping, and then click Edit.

e. In the Edit Module Mapping dialog box, add StaticFileModule in Module box by manually typing it, and then click OK.

Note The default entries in the Module box are StaticFileModule,DefaultDocumentModule,DirectoryListingModule
Source

Wednesday, December 15, 2010

Change Windows remote desktop port number

To change the port you will need to start Windows Registry Editor.
Go to : Start -> Run... type 'regedit' and press OK

Expand the registry folders to:
HKEY_LOCAL_MACHINE > System > CurrentControlSet > Control > TerminalServer > WinStations > RDP-Tcp
Then locate the following registry subkey :
PortNumber

Details Available here

Tuesday, December 14, 2010

String Vs StringBuilder

from my Standpoint I would say string builder is better than strings. rest of the stories can be seen here.

In this post, I am going to discuss about using String Concatenation vs String Builder. I have created a very simple page which creates a string using three different methods.

1) Writes directly to the Response Cache
2) Creates a String variable using String concatenation
3) Creates a String variable using String Builder

I have tried to keep it as simple and self explanatory. Basically there is a string variable called strSample which is 64 bytes in size, and I use simple loops to create strings of the required size and discuss about performance accordingly.

Lets begin by creating an aspx file (say, StringPerf.aspx) in your C:\Inetpub\WWWroot folder (or any other virtual folder of your choice). Now, open StringPerf.aspx in Notepad and paste the following code...

<%@ Page Language="vb" trace="true"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
  <title>StringPerf</title>
  <script runat="server">
'At this point I am declraring a string which is 64 bytes
Dim strSample As String = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
Dim intListValue As Integer
Dim i As Integer
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    Response.Write("<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><HR>")
    intListValue = Val(DropDownList1.SelectedValue)
End Sub
Private Sub btnResponseWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Trace.Write("In Response Write before writing")
    For i = 1 To 16 * intListValue
        Response.Write(strSample)
    Next
    Trace.Write("In Response Write after writing")
End Sub
Private Sub btnStringConcat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim strConcat As String
    Trace.Write("In String Concatenation before concatenating")
    For i = 1 To 16 * intListValue
        strConcat += strSample
    Next
    Trace.Write("Length of the string = " & strConcat.Length)
    Trace.Write("In String Concatenation after concatenating")
    Response.Write(strConcat)
End Sub
Private Sub btnStringBuilder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim stbBuilder As New StringBuilder
    Trace.Write("In String builder before building")
    For i = 1 To 16 * intListValue
        stbBuilder.Append(strSample)
    Next
    Trace.Write("Length of the string = " & stbBuilder.Length)
    Trace.Write("In String builder after building")
    Response.Write(stbBuilder.ToString)
End Sub
  </script>
  <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
  <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
   <asp:Button id="btnResponseWrite" onclick=btnResponseWrite_Click style="Z-INDEX: 103; LEFT: 24px; POSITION: absolute; TOP: 104px" runat="server" Text="Response.Write" Width="196px"></asp:Button>
   <asp:Button id="btnStringConcat" onclick=btnStringConcat_Click style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 136px" runat="server" Text="String Concatenation" Width="196"></asp:Button>
   <asp:Button id="btnStringBuilder" onclick=btnStringBuilder_Click style="Z-INDEX: 102; LEFT: 24px; POSITION: absolute; TOP: 168px" runat="server" Text="String Builder" Width="196px"></asp:Button>&nbsp;
   <asp:Label id="Label1" style="Z-INDEX: 104; LEFT: 24px; POSITION: absolute; TOP: 32px" runat="server"
    Font-Bold="True" Font-Names="Arial"> In this sample, we will see the performance difference in using String Concatenation vs String Builder</asp:Label>
   <asp:Label id="Label2" style="Z-INDEX: 105; LEFT: 104px; POSITION: absolute; TOP: 72px" runat="server"
    Width="56px" Font-Bold="True" Height="19">KB</asp:Label>
   <asp:DropDownList id="DropDownList1" style="Z-INDEX: 106; LEFT: 24px; POSITION: absolute; TOP: 69px"
    runat="server" Height="19px" AutoPostBack="True">
    <asp:ListItem Value="1">1</asp:ListItem>
    <asp:ListItem Value="2">2</asp:ListItem>
    <asp:ListItem Value="4">4</asp:ListItem>
    <asp:ListItem Value="8">8</asp:ListItem>
    <asp:ListItem Value="16">16</asp:ListItem>
    <asp:ListItem Value="32">32</asp:ListItem>
    <asp:ListItem Value="64">64</asp:ListItem>
    <asp:ListItem Value="128">128</asp:ListItem>
    <asp:ListItem Value="256">256</asp:ListItem>
    <asp:ListItem Value="512">512</asp:ListItem>
    <asp:ListItem Value="1024">1024</asp:ListItem>
   </asp:DropDownList>
  </form>
</body>
</HTML>

Save the aspx file and browse it. (http://localhost/StringPerf.aspx). You should be able to see a page with a drop down combo box with three buttons called Response.Write, String Concatenation and String Builder. I have turned trace to "true" in the page so that we could see how much time is taken for a similar operation using different methods.

Cool!! Time to start testing :o)

Scenario 1
Combo Box set to 4 KB.

a) Trace With "Response.Write" looks similar to (have a look at the trace generated)

In Response Write before writing 0.00105879378524366 0.000030
In Response Write after writing 0.00112276839654202 0.000064

b) Trace With "String Concatenation" looks similar to

In String Concatenation before concatenating 0.000805130260968922 0.000029
Length of the string = 4096 0.00130072397469511 0.000496
In String Concatenation after concatenating 0.00135128906048115 0.000051
Time taken = 0.00135128906048115 - 0.000805130260968922 = 0.000546158799512228

c) Trace With "String Builder" looks similar to

In String builder before building 0.000985041394925891 0.000030
Length of the string = 4096 0.00104063505277905 0.000056
In String builder after building 0.00106298426196626 0.000022
Time taken = 0.000077942867040369

It looks pretty harmless, isn't it? And in fact for small strings, it doesn't make too much difference anyways. Now look at another scenario. The "Time Taken" what I have calculated above will vary from system to system, but I hope it sohuld give you the idea.

Scenario 2
Combo Box set to 256 KB.

a) Trace With "Response.Write" looks similar to (have a look at the trace generated)

In Response Write before writing 0.000857650902558845 0.000030
In Response Write after writing 0.00188180341356234 0.001024

b) Trace With "String Concatenation" looks similar to

In String Concatenation before concatenating 0.000866590586233725 0.000029
Length of the string = 262144 15.6489126411318 15.648046
In String Concatenation after concatenating 15.6490316506707 0.000119
Time taken = 15.648165060084466275

c) Trace With "String Builder" looks similar to

In String builder before building 0.00103979695743453 0.000029
Length of the string = 262144 0.00564960071740961 0.004610
In String builder after building 0.00575743565173786 0.000108
Time taken = 0.00471763869430333

Now, here comes the difference. And what an amount! String Builder is performing almost ~3317 times faster than String Concatenation (15.648165 / 0.004717)!!!

As you can see the performance dips down drastically. And thankfully, we have an explanation. Visit the following links and enlighten yourself. You may try with different values in the Combo box and see for yourself how badly it can effect your server's performance.

Sources to

http://blogs.msdn.com/b/rahulso/archive/2006/08/29/string-concatenation-vs-string-builder-_2d00_-the-performance-hit_2100_-see-it-to-believe-it-_3a00_o_2900_.aspx

http://support.microsoft.com/?id=893660

http://support.microsoft.com/?id=306821

http://support.microsoft.com/?id=306822

Interesting Discussions

http://channel9.msdn.com/Forums/TechOff/14294-C-string-vs-StringBuilder

http://channel9.msdn.com/Forums/TechOff/211803-Net-String-vs-StringBuilder-metrics

nice and short article

http://blogs.msdn.com/b/msdnstudentflash/archive/2005/01/31/364217.aspx

Detailed explanations

http://www.codeproject.com/KB/string/string.aspx

http://www.codeproject.com/KB/cs/StringBuilder_vs_String.aspx

More blog

http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=site%3Ablogs.msdn.com+string+stringbuilder

A Bit more detail

http://blogs.msdn.com/b/ricom/archive/2003/12/02/40778.aspx

http://blogs.msdn.com/b/ricom/archive/2003/12/15/43628.aspx

Monday, December 13, 2010

Visual Studio Test Professional tutorial

Post Adapted from here

For this tutorial, I’m using Visual Studio Team Suite 2010 (which includes all of the roles and TFS access).  I’ve already added the demo to TFS so I have full source control.  For the sake of demonstration, I’ve commented out the final fix from the walk through so the label does not update:

image

When I run the application, the label is not updated:

image

The Tester

To create my test, I’m going to run the Test and Lab Manager tool from the start menu:

image

The main page has tabs for test plans, tests, and for tracking work items:

image

First I need to connect to my TFS server by click Add.  My server is VLM13267036 (auto generated name by our internal Hyper-V testing tools):

image

I’ve already got a collection with my code stored in the Projects folder:

image

Next I’ll select Projects and choose the Connect option. This prompts me to set a context:

image

I’ll choose “Set context” which brings up the editor for my new context:

image

I’ll select New:

image

I can now edit all of the properties:

image

After all data has been entered, click Save and Close.  The new item is now in our list:

image

Double clicking the item allows me to add a new test case to this test suite:

image

Here you can fill out all details for the test case:

image

Steps can now be added by clicking on the “Click here to add a step”:

image

I’ve added a few steps including launching the application, hitting the buttons, etc:

image

Now hit Save and Close to go back to the test case list.  The Plan is now complete.  We can run it any time a new build is produced, for each flavor of build, for different configurations, etc.  To execute the test, change focus to the Test tab:

image

Our test plan and test case are already in the list.  Right click the test case and select Run:

image

This will launch the test case.  The manual test runner window docks itself to the left side of my desktop so I can see both the steps I want to run and the full Windows desktop:

image

The “Start test and record” option allows me to not only do the testing steps, but it will also allow recording a WMV of all the steps I do as well as recording my steps to help me author coded UI tests (big helper with automation).  This is really handy if you want someone to see exactly what you did to produce a bug and automate testing in the future.

In this case I will select “Start test”.  Notice the Test Runner now shows the steps I created above:

image

The first step is to “Launch the PicViewer application” which I’ll do by running the application.  Since that worked, I’ll press the combo box status item behind the step and select ‘Pass’ from the drop down:

image

The item is now marked as passing:

image

I’ll repeat the process for the next two steps, so far so good:

image

When I get to my last step, I discover the file path isn’t actually set.  That makes this item a failure.  Select the drop down box and choose ‘Fail’ from the list.  I’m automatically asked for comments on the failure:

image

Since I didn’t record a video of my steps, I would like to give the developer a screen shot of what went wrong.  Select the camera tool bar button:

image

This will bring up a capture tool turning the cursor into a cross hair that allows me to select a region of the screen.  I’ll select the top of the application to demonstrate the busted label:

image

Notice that the failed test now has a .png file added with the image:

image

I’ve got enough supporting data now so I’ll create a new bug using the toolbar:

image

I’m now prompted to create my bug with a description, etc:

image

Notice the detailed test steps I’ve taken have already been added to the bug:

image

As has my screen shot (the .png file):

image

I’ll now do a Save and Close which will commit the bug to TFS as a Work Item.  Finally I’ll do End Test then Save and Close the test runner.  This will return us to Test and Lab Manager.

image

as a tester, I could now double click the test case and see all of the same data I just saved for the failure:

image

I can also select My Bugs and see the bug filed for this issue (since I conveniently assigned it to me):

image

And just to show how everything is wired together, I can open Visual Studio, Team Explorer and look for bugs assigned to me there as well:

image

At this point my job as a tester is now done.

The Developer

As a developer, I can now open the bug and read through the issue.  If I select Other Links I’ll find the .png which I can open to see the issue:

image

Sure enough, the label is not updated.  If a WMV had been recorded, I could have actually watched the testing steps in action.  Because the bug is quite simple to find and fix (some idiot commented out the update line!) I can simply make my fix and test it.

Now that things are fixed, I want to check in the bug fix and resolve the work item at the same time.  Click on the Pending Changes tab in VS and select the correct work item:

image

Now we can Check In the fix:

image

I can now verify the bug has been Resolved:

image

In Summary

A key goal for Visual Studio Team System 2010 was to reduce the number of times a tester and developer wind up in a ‘no-repro’ situation.  There are several things I’ve demonstrated in this tutorial which help:

  • Test case steps are documented and set up for repeatable execution
  • Pass/Fail steps are outlined and stored in bugs automatically
  • Video capture is allowed to see all steps taken, and screen snapshots are easy to acquire and file with a bug
  • System information including build number, OS, etc are recorded for you (System Info tab)
  • Although not shown, I could also have collected all of the historical debugging traces from the run as well
  • All data from test cases, results, work items, and source code are kept in TFS and can be shared by test and dev

I hope you’ll pick up Beta 1 and try this set of tutorials for yourself.  Let us know how well it works for you and if you have any suggestions.  I should also point out the work item tracking, auto resolve, etc are all part of VS 2008 so a great way to get prepared for the new version is to get TFS deployed today and get your projects into the system.

Enjoy!

SQL Express 2008 R2 - CREATE DATABASE permission denied in database 'master'

I think I figured it out.  I'm now having a problem importing data (more on that later), but at least I can create a database.  Here's what I did:

1.  shut down SQL Server from services

2.  open cmd window (as admin) and run single-user mode as local admin with this command:

"c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\ sqlservr.exe" -m -s SQLEXPRESS

3.  open another cmd window (as admin)

4.  open sqlcmd:

sqlcmd -S .\SQLEXPRESS

Now add the sysadmin user:

a.  sp_addsrvrolemember 'domain\user', 'sysadmin'

b.  GO

5.  now Ctrl+C the single-user mode from the first cmd window to kill SQL Server.  Now restart it from services the normal way.  Log into Management Studio and the user you created should be listed under logins with the credential of "sysadmin."

Before this, I was getting the error "Only one administrator can connect at this time. (Microsoft SQL Server, Error: 18461)."  What the error utterly fails to tell you is that any connection to single-user mode qualifies as an administrator connection.  In effect, simply opening Management Studio in single-user mode was causing an administrator to connect.  The only way to do anything in single-user mode (it appears) is to do it thru sqlcmd.

Source

http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/76fc84f9-437c-4e71-ba3d-3c9ae794a7c4/

The load test results database could not be opened. Check that the load test results database specified by the connect string for your test controller (or local machine) specifies a database that contains the load test schema and that is currently available. For more information, see the Visual Studio help topic 'About the Load Test Results Store'. The connection error was: An error occurred while attempting to create the load test results repository schema: To create the database 'LoadTest2010' your user account must have the either the SQL Server 'sysadmin' role or both the 'serveradmin' and 'dbcreator' roles

It appears that the load test repository was not created for some reason, so you will need to run the script to create it.  By default, the load test attempts to run against the SQL Server Express database that is installed with VS.  If this database is installed then do the following:

1) Open a cmd prompt
2) Change into the following directory: <VS Install Dir>\Common7\IDE
this will be something like: D:\Program Files\Microsoft Visual Studio 8\Common7\IDE
3) Run the following command: sqlcmd -S .\SQLExpress -i loadtestresultsrepository.sql

Then test the connection the way you originally did with the Administer Test Controller dialog.

If you do not have SQL Express installed on your local machine, you will need to run the installation script on a sql server instance and then configure the run to use the sql server you setup.  The installation script is called loadtestresultsrepository.sql and is located in the <VS Install Dir>\Common7\IDE directory.  After running this script, do the following:

1) Open the Administer Test Controller dialog. 
2) Click the ... next to the connection string
3) Point  the connection to the database you just installed
4) Test connection and hit OK

Source

http://msdn.microsoft.com/en-us/library/ms182600.aspx

Sunday, December 12, 2010

How to uninstall Windows 7.0 SP1 Beta

today  I was about to update my machine with a newer version of Service pack of windows 7.0. I downloaded RC1 and when I clicked on install it said unable to continue a pervious version is installed. so tried a simple way of uninstalling the SP beta but as usual there wasn’t any so this a simple way to do it.

If you've used the Disk Cleanup Wizard since you've installed SP1 RC, the backup files needed to uninstall the service pack might have been removed from your computer. If that's the case, then use System Restore to uninstall the service pack.

  1. Click the Start button .

  2. In the search box, type command prompt.

  3. In the list of results, right-click Command Prompt, and then click Run as administrator.  If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

  4. Type the following: wusa.exe /uninstall /kb:976932

  5. Press Enter.

image

or

The easiest way to uninstall SP1 RC is using Programs and Features.

If you've used the Disk Cleanup Wizard since you've installed SP1 RC, the backup files needed to uninstall the service pack might have been removed from your computer. If that's the case, then use System Restore to uninstall the service pack.

  1. Click the Start button , click Control Panel, click Programs, and then click Programs and Features.

  2. Click View installed updates.

  3. Click Service Pack for Microsoft Windows (KB 976932), and then click Uninstall.

    If you don't see Service Pack for Microsoft Windows (KB 976932) in the list of installed updates, or if the uninstall option is disabled, use System Restore to uninstall the service pack.

Method 2

1. Open Control Panel and click on "Programs -> Uninstall a program" if you are using "Category" view.

If you are using "Icons" view, click on "Programs and Features" icon.

2. Now click on "View installed updates" link given in left sidebar.

3. Select the "Service Pack for Microsoft Windows (KB976932)" item in the given list and click on "Uninstall" button in the toolbar. You can also right-click on the update and select "Uninstall" option.

4. It'll ask for confirmation, click on "Yes" button.

That's it. It'll take some time and will uninstall SP1 Beta from your system.

source for Method 2

Friday, December 10, 2010

How to disable Internet Explorer Enhanced Security Configuration (IE ESC) in Windows Server 2008

To apply Enhanced Security Configuration to specific users by using a computer running Windows Server 2008
  1. Log on to the computer with a user account that is a member of the local Administrators group.

  2. Click Start, point to Administrative Tools, and then click Server Manager.

  3. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.

  4. Under Security Information, click Configure IE ESC.

    Note

    Server Manager opens with the same window that was in use when it was last closed. If you do not see the Security Information section, click Server Managerin the console tree.

  5. Under Administrators, click On (Recommended) or Off, depending on your desired configuration.

  6. Under Users, click On (Recommended) or Off, depending on your desired configuration.

  7. Click OK.

  8. Restart Internet Explorer to apply Enhanced Security Configuration.

IE_ESC

Post contains Martial from These Sources

http://technet.microsoft.com/en-us/library/dd883248(WS.10).aspx

http://4sysops.com/archives/how-to-disable-internet-explorer-enhanced-security-configuration-ie-esc-in-windows-server-2008/