December 20, 2011

Expand WPF TreeView


Questions
- How to expand all WPF TreeView nodes?
- Expand all nodes when a WPF TreeView is loaded
- Where is the default ExpandAll solution for WPF TreeView
- Expand all a WPF HierarchicalDataTemplate TreeView

Solution
Add below codes in XAML in TreeView tag.

  <TreeView.ItemContainerStyle>
      <Style>
          <Setter Property="TreeViewItem.IsExpanded" Value="True"/>
      </Style>
  </TreeView.ItemContainerStyle>

December 05, 2011

4.00 GB (2.99 GB usable)


Problem
- I am using Windows 7 with 4GB of RAM but system properties says 4GB RAM(2.99GB Usable) ...
- Installed 4GB RAM but the windows 7 says Usable 2.99GB RAM
- Windows 7 shows 4.096 GB(2.96 GB Usable) memory
- Why the Windows 7 memory (RAM) 4 GB (3.25 GB usable) ...


Clean Solution
You need to install Windows 7 - 64 bit

Technical Answer
A 32bit desktop windows 7 can just address 4GB of memory addresses.
This memory is include RAM + other hardware memory like Graphic Card,
Then if you have
4GB RAM + 1GB Graphic Card Memory = ~3.0 GB RAM available
4GB RAM + 512MB Graphic Card Memory = ~3.5 GB RAM available
and etc...

Physical Memory Limits: Windows 7
The following table specifies the limits on physical memory for Windows 7 [link]
VersionLimit on X86Limit on X64
Windows 7 Ultimate
4 GB
192 GB
Windows 7 Enterprise
4 GB
192 GB
Windows 7 Professional
4 GB
192 GB
Windows 7 Home Premium
4 GB
16 GB
Windows 7 Home Basic
4 GB
8 GB
Windows 7 Starter
2 GB


December 01, 2011

Fix wrong character keyboard typing

Problem
How to fix wrong character display on notebook keyboard ...
Your keyboard wrong character typing in windows vista ...
How to fix wrong character display on U, I, O, J, K, L ...
How to fix numeral character instead of  normal character

Solution
Press NumLk (ScrLk) + PrtSc (SysRq) and enjoy

September 27, 2011

Windows Mobile - Change Caller ID Matching


Error:
- How can i change my phone number matching caller id ...
- Where can i find a setting for change matching algorithm for find contact of each called number
- Where's WINMO 6.x Setting for change caller id default setting for matching number and find contact

Solution:
In first step you need to have a registry editor software and install it on your windows mobile like below
1- Download and Install Windows Mobile Registry Editor v0.9 [here] and then go to 
HKEY_CURRENT_USER/ControlPanel/Phone/CallIDMatch
This value is number of last character from incoming call or SMS for matching process and finding in contact list. You can change it from 8 or 9 to your favor and reboot it and enjoy ;-)

References:
http://forum.xda-developers.com

September 17, 2011

WPF Application is not closed after shutdown

Problem:
- WPF application is not closing correctly ...
- The users close application but the application is not closing.
- My application staying in background processes after closing.
- How to exit a WPF app correctly or programmatically?
- WPF (Avalon) application not closing correctly!
- The application not shuts down correctly!

Solution: 
Add Closed Event to main window like below:
    private void DXRibbonWindow_Closed(object sender, EventArgs e)
    {
        //Environment.Exit(0);
        Application.Current.Shutdown();
    }

References:
LINK1: http://stackoverflow.com/questions/810531/wpf-application-is-not-closing-correctly
LINK2: http://stackoverflow.com/questions/3543704/wpf-application-still-runs-in-background-after-closing

September 13, 2011

This system does not support fullscreen mode

Errors:
- Full screen mode for DOS programs in Windows 7
- No full screen mode for DOS programs?
- This system does not support fullscreen mode. Error in windows 7.
- I am supposed to run an old DOS program on my Windows 7 OS But ...
- There is no FullScreen DOS in Windows 7
- Full-screen problem in CMD.EXE and COMMAND.EXE




Solution 1:
You can use of DOSBOX which is an open source DOS emulator.

Solution 2:
You can disable your Display Adapter from Device Manager.

Solution 3:
You can disable your Display Adapter with DEVCON command-line utility in batch file or likes.
DEVCON help: link
DEVCON download: link
DEVCON sample: link

August 25, 2011

Windows Explorer has stopped working


Problems:
- Windows Explorer has stopped working in windows 7
- Windows Explorer has stopped working in windows 7 starter
- Windows Explorer has stopped working in windows 7 64 bit
- Windows Explorer has stopped working fix
- When I try to open my personal folders and other WINDOWS related folders ...
- When copying files in Explorer, I started getting a "Windows Explorer has ...

Solution:
This ERROR comes from a specific problem. Your problem could be from your computer hardware, software or etc... BTW, simplest and original solution is
- Press CTRL+SHIFT+ESC keys for open Windows Task Manager
- Go to File &gt; New Task (Run...) and Type "C:\" and press OK and then wait a little for open a windows explorer
- Go to Control Panel (from little arrow in left of title bar and select Control Panel or like)
- Go to Administrative Tools &gt; View event logs (or Event Viewer)
- Go to Administrative Events and find the last and top error.
- Read the last error message. Your problem is there. If your problem is not solved you can copy & paste the last message in Google and find a solution.

Example:
- I had a problem with divxmfsource.dll and i fix it after install K-Lite Codec
- I had a problem with SnagIt Printer and i remove it and problem goes to hell ;-))

August 20, 2011

Edit a bundle in Google Reader


Problem:
- How to edit a Bundle in Google Reader
- I can't find a EDIT link for a bundle in google reader
- Where's edit link for created bundles

Solution:
A carzy developer put it in behind ;-)
1- Go to Google Reader
2- Go to Browse for stuff
3- Find the blue link with "View your bundles »" text and click on it
4- You can find the "Edit" link in here :-D

August 14, 2011

CSR Bluetooth Problem

Error:
- How to fix BlueSoleil USB Bluetooth® Dongle on Windows 7 ...
- I have a bluetooth device and it's not activated ...
- I can't turn on my CSR Bluetooth Device
- I am using Window 7 with CSR Bluetooth Device Dongle, guide me on how to connect

Solution:
- Check the USER and you must be a administrator. (this command helps you on this &gt;whoami)
- Disable Anti-Virus software
- Disable Anti-Spyware software
- Disable Firewall software
- Uninstall Any Soleil software
- Uninstall Sony Bluespace software
- Uninstall XTNDConnect Blue Manager software
- Uninstall Microsoft Patch Q323183 (on WINDOWS XP)
- Uninstall Any drivers that were supplied with your existing Bluetooth device.
- Uninstall Microsoft IntelliType and IntelliPoint software for Bluetooth Mouse and Keyboards
- Plug-Out the bluetooth device now.
- Check the Control Panel\System and Security\Administrative Tools\Services\Bluetooth Support Service and start it
- Check the nxj.cache file and delete it (this command helps you on this &gt;dir /a/s nxj.cache)
- Restart Windows
- Install Latest WIDCOMM Bluetooth Drivers or (http://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles/7zbv19ww.exe)
- Goto Safe Mode
- Install Widcomm_patcher_v2 for overwrite on these files (wbtapi.dll, BTNeighborhood.dll, BTStackServer.exe, BTTray.exe)
- Restart Windows
- Plug the bluetooth device now and enjoy

Instructions for using the patch:
1) Uninstall ALL your previous Widcomm Bluetooth drivers
2) Switch off your PC
3) Remove your Bluetooth dongle from PC
4) Start your PC
5) Install the new drivers
6) Restart your PC in safe mode
7) Run the patch
8) Restart your PC
9) Plug in your Bluetooth dongle
10) Now everything should work properly

August 10, 2011

DevExpress ASPxHttpHandlerModule and DXR.axd problem

Error
- when i deploy then the report tool bar icons just show "missing image" and log shows 404 for a bunch of calls to DXR.axd ...
- DevExpress and Image not Loading ...
- i have recently added Devexpress Charts to my reports. and i get the following errror message
- after upgrade version from v9 to v10 or v11 the some images can't loaded from DXR.axd ...

Solution
This problem is usually comes from the missing
- DevExpress.Web.ASPxThemes.v10.1.dll
- DevExpress.Web.ASPxThemes.v11.1.dll
or any in your application's Bin folder.

June 30, 2011

Cannot apply indexing with [] to an expression of type System.Collections.Generic.IEnumerable

Error:
Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<ANY_TYPE>

Solution:
If used of IEnumerable SampleArray then you can access to elements like:
- SampleArray[index] WRONG
- SampleArray.ElementAt(index) RIGHT
Because the IEnumerable interface dose not support of [] for indexing :-))

June 15, 2011

Server-generated keys and server-generated values are not supported by SQL Server Compact

Errors:
{"Server-generated keys and server-generated values are not supported by SQL Server Compact."}
{"An error occurred while updating the entries. See the inner exception for details."}

Problem:
The current version of Entity Framework does not support identity keys using SQL Compact ;-(

Solution:
1- Add the Guid.NewGuid() after new row like below here (for uniqueidentifier ID)

BindingListCollectionView CurrentView = categoriesViewSource.View as BindingListCollectionView;
Table tb1 = CurrentView.AddNew() as Table1;
tb1.ID = Guid.NewGuid();
this.CurrentView.CommitNew();

2- Another solution can be find the last and greatest ID and make a new one with ++ to that like here (for int ID)

3- Another solution can be used of  DateTime.UtcNow.Ticks (for bigint ID)

PS: There's a little problem with True value for Identity property in SQL CE Table and must be set to False.

June 11, 2011

Make invisible layer in Flash CS5

Hide layer (with click on eye icon) for invisible in design time and then right-click on layer and checked the Guide item for invisible in run-time.

June 06, 2011

Primary side of the relationship error on Entity Framework

Error:
The relationship 'RELATIONSHIP NAME' has columns that are not part of the key of the table on the primary side of the relationship. The relationship was excluded.

Solution:
Attention to the RELATIONSHIP NAME in your database. The Relationship Name must have a unique name and this error comes from a duplicate relationship name in database. Entity Framework (EF 4.0) generator have problem with duplicate relationship names from databases.

June 01, 2011

WPF SelectedValue for TreeView

Questions:
- How to programmatically select an Item in a WPF TreeView
- How to programmatically selecting an Item in a WPF TreeView
- How to SelectedItem in a WPF TreeView
- How to set SelectedItem or SelectedValue in C#/WPF TreeView
- WPF TreeView SelectedItem should have set accessor …
- How to programmatically change the SelectedItem in a WPF TreeView

Solution:
The Solution is simple and quick with just a little method
TreeViewItem matchItam = SelectTreeViewItem(this.treeView1.Items, "sample value");

The code is here
private TreeViewItem SelectTreeViewItem(ItemCollection Collection, String Value)
{
    if (Collection == null) return null;
    foreach(TreeViewItem Item in Collection)
    {
        /// Find in current
        if (Item.Header.Equals(Value))
        {
            Item.IsSelected = true;
            return Item;
        }

        /// Find in Childs
        if (Item.Items != null)
        {
            TreeViewItem childItem = this.SelectTreeViewItem(Item.Items, Value);
            if (childItem != null)
            {
                Item.IsExpanded = true;
                return childItem;
            }
        }
    }
    return null;
}

May 31, 2011

C# HTML Minification

Questions:
- Is there any code which input the html source of a page and it will minify the code?
- A solution for Text Compress without used of GZip for...
- Minifies given HTML or XML source by removing extra whitespaces, comments and other unneeded Characters without breaking the content structure
- Minify HTML (or XHTML), and any CSS or JS included in your markup
- Compressing and Minifying HTML Markups

Solution:
I hope this helps.
/// Solution A
html = Regex.Replace(html, @"\n|\t", " ");
html = Regex.Replace(html, @">\s+<", "><").Trim();
html = Regex.Replace(html, @"\s{2,}", " ");

/// Solution B
html = Regex.Replace(html, @"(?<=[^])\t{2,}|(?<=[>])\s{2,}(?=[<])|(?<=[>])\s{2,11}(?=[<])|(?=[\n])\s{2,}", "");
html = Regex.Replace(html, @"[ \f\r\t\v]?([\n\xFE\xFF/{}[\];,<>*%&|^!~?:=])[\f\r\t\v]?", "$1");
html = html.Replace(";\n", ";");

/// Solution C
html = Regex.Replace(html, @"[a-zA-Z]+#", "#");
html = Regex.Replace(html, @"[\n\r]+\s*", string.Empty);
html = Regex.Replace(html, @"\s+", " ");
html = Regex.Replace(html, @"\s?([:,;{}])\s?", "$1");
html = html.Replace(";}", "}");
html = Regex.Replace(html, @"([\s:]0)(px|pt|%|em)", "$1");

/// Remove comments
html = Regex.Replace(html, @"/\*[\d\D]*?\*/", string.Empty);

References:
- Is there a better approach to minify html generated from aspx page
- Efficient stylesheet minification in C# 
- Follow up to Additional CSS minifying regex patterns
- Improve ASP.NET Performance - CSSmin

May 29, 2011

Nullable String

Error:
The type 'string' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.Nullable'

Problem:
- I have a function that I want to pass data that gets data from ...
- What's C# problme with nullable string ...
- Why no support for nullable string in C#
- C# have a problem with passing nullable string ...
- public void test(string? x){} has ERROR
- public void test(Nullable x){} has ERROR

Solution:
:-D System.String is a reference type and it is nullable. :-)

May 26, 2011

History of Adobe Media Player

Problem:
- How do i delete all my personal videos in Adobe Media player?
- Where is file history in Adobe Media Player?
- How to clear history of Adobe Flash Player?

Solution:
It's so simple. Go to below folder and delete or rename it ... ;-)
C:\Users\{YOUR USER}\AppData\Roaming\Adobe\Adobe Media Player
like
C:\Users\Administrator\AppData\Roaming\Adobe\Adobe Media Player

May 24, 2011

Modifying a 'method' which contains a query expression will prevent

Error:
Modifying a 'method' which contains a query expression will prevent the debug session from continuing while Edit and Continue is enabled.

Solution:
If did you add a LINQ code then you have no solution.
I'm serious and you can find the answer of microsoft out here

May 10, 2011

String was not recognized as a valid DateTime

Error:
The message of exception is "String was not recognized as a valid DateTime."

Problem:
- I am trying to convert my string formated value to date type with DateTime.ParseExact but ...
- I get the error saying "String was not recognized as a valid DateTime" when I used of ParseExact ...
- ... in some value as "9/7/2008 13:00:00" when im going to set startdate it throw was not recognized as a valid DateTime and ...

Solution:
The DateTime.ParseExact have not any problem and the orginal problem comes from us thus you attention to String of Formatx
EXAMPLE: the string format for "02/Dec/2007:14:15:40 -08:00" is
WRONG: dd/MMM/yyyy:hh:mm:ss zzz
RIGHT: dd/MMM/yyyy:HH:mm:ss zzz

Did you got the problem source! It comes from (hh) and because the hour is greater than 12 need the (HH). Ok, look at again to the StringFormat and debug it again ;-)

April 29, 2011

Chaneg Googlemail to Gmail

Questions
- How to migrate from Googlemail to Gmail?
- How to Convert Your @GoogleMail to @Gmail?

Solution
If did you have a google mail account like user@googlemail.com and you wanna change it to @gmail.com , it' easy if you follow me ;-)

1- Go to you Google Mail with user@googlemail.com
2- Go to Mail Setting (If you can't find the Mail Setting you can choose Google Account Setting and after that select the setting link in front of Google Mail)

3- Select Account and Important tab
4- Find the Switch to @gmail.com and click on it


5- Follow links and enjoy :-D

April 25, 2011

Hang and Freeze on Open/Save dialog in Windows 7

Problem:
- When i clicked the button which will execute the Open Dialog or Save Dialog then hangs ...
- Whenever I request a "File|Open" or "File|Save" from any application, the Open or Save dialog box that opens freezes and hangs the ...
- IE8 will also hang on open and ...
- Whenever I try to use "Save as" dialog box and select an option, the window simply stops responding and ...
- "Save As" or "Open" dialog box hangs on windows 7
- "File Open" or "Save As" windows dialog boxes take too long to open

Solution:
At this moment I do NOT think that comes from Antivirus or software development companies bug. It's a Aero Problem i think so, but how cares ..., Please follow of following instruction for pass this problem till the Microsoft wake-up for this ;-)

0) Delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32
- Open REGEDIT (WinKey + R and type regedit and then press enter)
- Go to Path and delete folder ComDlg32

1) You can change the compatibility of each application that you need to solve.
- Right-Click on Application Icon (or EXE file which related to that)
- Select Properties
- Select Compatibility Tab and Change the Compatibility Mode to Widows XP or another one

2) or Disable Aero Theme
- Open Appearance Setting and select a classic or standard theme.

3) or Scan
- Go to RUN (WinKey + R) and type run the sfc /scannow

April 24, 2011

ActionScript3.0 problem with TLF text

Error:
- All method which are related to string not at working after first object convert from Classic Text to TLF Text
- dispatchEvent not working with TLF text
- all movies not load after convert Text to TLF

Solution:
The solution is really simple and worked
- Sleect FLA file from Project (or load it)
- Select File > Publish Settings... from top menu of press Ctrl + Shift + F12
- Select Flash Tab


- Press on Settings... botton in front of Script section
- Select Library path Tab from new opened dialoge
- Find Default Linkage combo box
- Change the value to Merge into code


- Press OK
- Press Publish and OK
- Enjoy :D

April 13, 2011

Run JSP pages on windows

Problem:
- How to run a web server for jsp pages on windows
- How to make a windows to a web host for JSP pages.

Solution:
1- JVM: You must have a JVM. You can check default folder C:\Program Files\Java\ for find a jdk1.5.0_06 or jdk1.6.0_10 or any version of SUN’s JDK
2- Tomcat: You need to have Tomcat and you can check the default folder C:\Program Files\Apache Software Foundation\ for find a Tomcat 5.5 or Tomcat 7.0. Choose exe instead of zip file from core section in Tomcat download page. (I choose 32-bit/64-bit Windows Service Installer from core section and select FULL installation option in install process). After install you can see the something in http://localhost:8080/ ;-)
3- RUN: Goto C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps and make a folder and put your JSP files here ;-)

References:
JVM: http://java.sun.com/javase/downloads/index.jsp
TOMCAT: http://tomcat.apache.org/download-70.cgi

April 08, 2011

Authorization: Cannot verify access to path

Error:
Authorization Cannot verify access to path

Error Description:
The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that \$ has Read access to the physical path. Then test these settings again.

Solution:
1- Open IIS 7.0
2- Select Default Web Site and Right-Click on it
3- Select Add Application... or Add Virtual Directory...
4- Select Contact as..
5- Change Path credentials: from Application user (pass-through authentication) to Specific user:
6- Add a Admin User with password like COMPUETRNAME\Administrator User

April 02, 2011

New Line Problem in JSON

Problem
- I have problem when retrieving JSON formatted text from multiline textbox.
- I have HANG UP problem when call a method with a JSON text with new line.
- I've generated some JSON from a textbox and i have error when the user press enter between text

Solution
OK, the solution is so simple, you must just replace the newline characters with a another valid character, yes, it's works.
str = str.replace("\n", "\\n");
or
str = str.replace("\n", "");
but it's works just for change first newline and for change all new line must be follow of /TEXT/g regular expression and enjoy ;-)
str = str.replace(/\n/g, "\\n");
or
str = str.replace(/\n/g, "");

References
[1] RegExp Object

March 29, 2011

How to add a custom NS record to a domain/subdomain in dns-diy.net

- How to add a custom NS to DNSDIY
- How to add a custom NS to dns-diy.net
- Adding Custom NS at dns-diy.net
- Adding Custom NS at OnlineNIC domain

DNS Records:
We have many different type of DNS records and most of these record types are not commonly used. By the way you need to know a little about these
- NS: is name server which specifies a name server for the domain.
- CNAME: Sets an alias for a host name. Like "docs >> CNAME >> ghs.google.com. >> 0 >> 3600" in here means: forward docs.domain.com to custom google document server in behind scene.
- A: Maps a host name to an IP address
- MX: is Mail eXchanger.
- TXT: it's strictly informational.

Solution:
- Login to dns-diy.net in here or any domain control panel
- Find a custom DNS Records Zone (its first page which comes after login)
- Add a new record with
host: 
type: NS
data: ns.yourhost.com
priority: 0
ttl: 3600
- Click update and wait for minutes for works ;-)
DNS-DIY Zone Edit

Test:
If you'd like to check the status of your DNS records for web publishing, you can perform a free nslookup. Here's how:
- Google NS lookup [link].
- Select a search result from top of list.
- Type your domain address in to the field.
- Click Submit, or Lookup.

March 20, 2011

How to fix a row in Excel

How do you fix a row in Excel?
How do you freeze a row in Excel?
How do you fix a column in Excel?
How to fix a row in Excel when you move that one stays fixed?
How fixed column/row in Microsoft Office Excel?

Solution
1- Select Row/Column
2- Select View in ribbon

3- Select Freeze Panes from Window Section
4- Enjoy :-D

March 18, 2011

database does not have a valid owner

Error:
TITLE: Microsoft SQL Server Management Studio
------------------------------
Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects.
------------------------------
BUTTONS:
OK
------------------------------

Solution:
1. Right Click on your database, choose properties
2. Goto the Files
3. Change the owner textbox to "sa"
4. Press OK
5. Enjoy

March 16, 2011

Unmanaged C++ in C#

Questions
- Using Unmanaged C++ Dynamic Library (DLL) in .NET Applications
- Using DllImport for read a unmanaged dll
- How to Create DLL in Visual Studio 2008 in Visual C++ for Using in C#
- Call an Unmanaged DLL from .Net Windows Application
- Call an Unmanaged Visual C++ code from Managed Code like C# or other .NET

Solution
I have received a request from my friend, He wanted to have a solution with an unmanaged library (DLL) as core and a windows form application in C# as an interface. You can find a very simple solution with 2 languages, here.

- Microsoft Visual C++ 2010 (Unmanaged, Dll)
- Microsoft Visual C# 2010 (Managed, Windows Form)

ClassLibrary.h
// ClassLibrary.h
#define DllExport _declspec(dllexport)
extern "C" DllExport int Sum(int, int);
extern "C" DllExport wchar_t getChar(void);
extern "C" DllExport wchar_t* getString(void);

#pragma once
int Sum(int, int);
wchar_t getChar(void);
wchar_t* getString(void);

ClassLibrary.cpp
#include "stdafx.h"
#include "ClassLibrary.h"

int Sum(int a, int b){return a + b;}
wchar_t getChar(){return L'Ù†';}
wchar_t* getString(){return L"امیرمهدی خادم آستانه";}

part of Form1.cs
[DllImport("c:\\ClassLibrary.dll", CharSet = CharSet.Unicode)]
[return : MarshalAs(UnmanagedType.I4)]
public static extern Int32 Sum(Int32 a, Int32 b);

[DllImport("c:\\ClassLibrary.dll", CharSet = CharSet.Unicode)]
public static extern char getChar();

[DllImport("c:\\ClassLibrary.dll", CharSet = CharSet.Unicode)]
public static extern String getString();

Download
[1] Unmanaged C++ in C# Solution (both of VC and C# projects) download

Add OCX to C#

Questions
- Adding an OCX to a .Net Project
- How to add a OCX in C# Project?
- How to add a OCX in Windows Form Application?
- Adding a VB6 OCX in C# projects

Solution
1- Create a new Windows Form Application
2- goto Menu > Tools > Choose Toolbox Items
3- goto to COM Components tab and find Browse button
4- Add the OCX (you could install the OCX with regsvr32 command)
5- Drag it from toolbox and drop on form and enjoy

March 15, 2011

Speedup SQL

- Normalize Tables
- Avoid using cursors
- Index Columns
- Increase timeouts
- Avoid using un-necessary indexes
- Avoid using GOTO
- Avoid NULLABLE columns
- Avoid TEXT datatype
- Avoid IMAGE datatype
- Avoid SELECT * instead of select columns
- Avoid SELECT max(ID) instead of SCOPE_IDENTITY or IDENT_CURRENT
- Avoid bulk INSERT instead of DTS
- Don't start SP with "sp_"
- Use Analyze Query Plans
- Use of @@ERROR for trap errors
- Use of Count(*) for find number of rows
- Use SET NOCOUNT ON in stored procedures
- Avoid of more DISTINCT, LIKE ORDER BY, OUTER JOIN, UNION
- Avoid of more MATH
- Set Index - Fill Factor (increase percent for static data table with minimum INSERT and DELETE)

References
[1] http://forums.codecharge.com/posts.php?post_id=75008
[2] http://www.techrepublic.com/blog/datacenter/speed-up-sql-server-database-queries-with-these-tips/173

March 12, 2011

Enter Key in Textbox

Problem:
This is a simple and cruise my friend problem in ASP.NET. She want to transfer hit a Enter key event from text-box in html to fire a selective button. It is frequently required to hit enter after user insert a search terms instead of mouse click in Search box.

Solution:
This javascript can solve the problem



  
  
  

Download:
[link] 20110312-Enter Key in Textbox.rar

March 11, 2011

Status: 0xc0000001

Error:
Windows failed to start. A recent hardware or software change might be the cause. To fix the problem:
1. Insert your Windows installation disc and restart your computer.
2. Choose your language settings, and then click "next."
3. Click "Repair your computer."
If you do not have this disk, contact your system administrator or computer manufacture for assistance.
File: \Windows\system32\config\system
Status: 0xc0000001
Info: Windows failed to load because the system registry file is missing, or corrupt.


Solution:
If you got this error in installation processes of Windows Vista or Windows 7 then you must check your memory. I changed the RAM modules and the problems went :-D

March 05, 2011

Microsoft Ajax Minifier and Manual Batch File

You can used of the Microsoft Ajax Minifier into your Visual Studio 2010 without change your project files or follow of strange roadmap (link). With simple batch file you can minified all JS and CSS files and move the new minified files in minified folder. With this simple trick you can Route the CSS and JS files to minified path.
Yes, It's so simple and a tricky solution for easy going people. The hardest part of this solution is the Batch file for minified all JS and CSS files with AjaxMin.exe as Microsoft Ajax Minifier and automatic move and replace in minified folder.
@echo off
md minified
for %%J in (*.js *.css) do @AjaxMin.exe -clobber:true "%%J" -o "minified\%%J"
pause

March 01, 2011

Performance Options after every startup

Errors
- My Performance Options box opens up after every startup system.
- I have tried numerous ways to set the page file size and after reboot everything went.
- I can't set to System managed size because it back to No paging file

Solution
This is a simple, just run this line in RUN or in START MENU search box, just do it and enjoy.
sc config afs start= disabled

Reference
[1] Link

February 25, 2011

ROBOTS tag

What's ROBOTS tag?
How to use of ROBOTS meta tag?
What's ROBOTS meta tag?

Introduction
We know that search engines handle meta tags and the ROBOTS is a part of META tags[1]. The HTML META ROBOTS Tag help and talk to search engines crawlers. The standard and valid values for the CONTENT attribute are just "INDEX", "NOINDEX", "FOLLOW" and "NOFOLLOW but the valid meta robots content values fo G-BOT are:
NOINDEX: prevents the page from being included in the index.
NOFOLLOW: prevents Googlebot from following any links on the page.
NOARCHIVE: prevents a cached copy of this page from being available in the search results.
NOSNIPPET: prevents a description from appearing below the page in the search results, as well as prevents caching of the page.
NOODP: blocks the Open Directory Project description of the page from being used in the description that appears below the page in the search results.
NONE: equivalent to "NOINDEX, NOFOLLOW".
FOLLOW: a command for crawler to follow the links in that webpage.
INDEX: a command for crawler to index that webpage.
INDEX, FOLLOW: Follow The search engine robots will start crawling your website from the main/index page and then will continue to the rest of the pages.
<meta name="robots" content="index, follow">
I know that "INDEX, FOLLOW" is unecessary content values and by default, Google-BOT will index a page and follow links to it and there's no need to have a tag with content values of INDEX or FOLLOW but i want to sure about G-BOT and other BOTs. You can find list of all BOTs from here.

References
[1] http://googlewebmastercentral.blogspot.com/2007/03/using-robots-meta-tag.html
[2] http://www.robotstxt.org
[3] http://www.siteground.com/metatag_optimization.htm
[4] http://en.wikipedia.org/wiki/Meta_element

February 24, 2011

jQuery and Visual Studio 2010

- How to use of jQuery in Visual Studio?
- How to enable jQuery intellisense in and Visual Studio 2010?
- How to active jQuery intellisense in visual studio?
- How to start develop jQuery code in visual studio like C# !!!

Solution
Come on and follow these steps for active and enjoy jQuery in Microsoft Visual Studio ;-)

1- Download jQuery VSDoc from Visual Studio links in jQuery.com > Download Center
    Download Center: http://docs.jquery.com/Downloading_jQuery
    jQuery for Visual Studio v1.4.1: http://code.jquery.com/jquery-1.4.1-vsdoc.js
    jQuery for Visual Studio v1.7: http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7-vsdoc.js

2- Add this JavaScript to your solution

3- Add this script tag in your page


4- Enjoy!

February 17, 2011

Entity Framework with ASP .NET Web Application and Microsoft SQL Server

This is a fastest tutorial for learning about Entity Framework with ASP .NET Web Application and Microsoft SQL Server. I promise to you that is a simplest and overall.

VIDEO


STEP by STEP
1- Open Microsoft Visual Studio 2010
2- Add New Project from menu with select File > New > Project > ASP .NET Empty Web Application from New Project window

3- Go to Solution Explorer and right-click on WebApplication1 and select Add > New Item > SQL Server Database from Add New Item window
4- Go to Solution Explorer and double-click on Database1.mdf
5- Go to Server Explorer and right-click on Tables (from Database1.sdf) and select Create Table from context menu
6- Save this table as Table1 like below screen shot.

7- Go to Server Explorer and open Tables and right-click on Table1 table and select Show Table Data from context menu and add some data in rows.


8- Go to Solution Explorer and right-click on WebApplication1 and select Add > New Item > ADO.NET Entity Data Model > Generate from database > Next > select Table1 from Tables > Finish
9- Press F6 for Build Solution and TAKE A BREATH :-D
10- Right-click on WebApplication1 from Solution Explorer and go to Add > New Item... > Web > WebForm > Design and select a GridView from Toolbox and drag and drop it to WebForm1
11- Select GridView Tasks from top-right corner of GridView and select Choose Data Source and select Entity > Database1Entities > Table1 and Finish.

12- Compile, Run and ENJOY :-D
PS: Hey folks, if did you have any problem please don't be hesitate to contact me or write comment here ;-)

Entity Framework Tutorials
Entity Framework with Windows Form Application and Microsoft SQL CE
Entity Framework with ASP .NET Web Application and Microsoft SQL Server

Download
Source Codes: link

February 14, 2011

Print Anywhere With Google Cloud Print

With Google Cloud Print you can connect your local printers to Google and go any where and connect to internet and send a print tasks to your printers from Google. It's not magic and it's so simple.
You can go to Google Chrome options and connect your home printer(s) to Google Chrome (with Google Cloud Print Service) and then if you go to any where, and send a print task from Google Applications on PC, Mobile. Google Application Website or anywhere, Google find your Google Chrome in home and send the print tasks to your home printers.

Setup
1- You can see my printers

2- Open your Google Chrome and Select Options


3- Find out Google Cloud Print in Under the Hood and select Sign-In button

4- Add you Google account (or gmail account ...) and give a success message. (i love Print a Test Page and if you love it, test it and enjoy it :-D)


5- By the way you can find Manage Print Settings... button in Google Cloud Print in Chrome Options... and go to Google Cloud Print Management and surprise.
PS: It's a first try of big G about Chrome OS and Internet Base OS and i think that Net-OS will be available and popular before 2020 if the world don't stop after 2012-21-DEC :-))

References
[1] Google Blog: http://googleappsupdates.blogspot.com/2011/01/print-from-your-phone-with-gmail-for.html
[2] Google Cloud Print Help Support: http://www.google.com/support/cloudprint/?hl=en

Entity Framework with Windows Form Application and Microsoft SQL CE

This is a fastest tutorial for learning about working Entity Framework with SQL Server Compact Edition and Windows Form Application. I promise to you that is a simplest and overall :-D

VIDEO


STEP by STEP
1- Open Microsoft Visual Studio 2010
2- Add New Project from menu with select File > New > Project > Windows Form Application from New Project window

3- Go to Solution Explorer and right-click on solution and select Add > New Project > Class Library from New Project window

4- Go to Solution Explorer and right-click on ClassLibrary1 and select Add > New Item > Local Database from Add New Item window (Cancel the Data Source Configuration Wizard window which opend after that)
5- Go to Solution Explorer and double-click on Database1.sdf
6- Go to Server Explorer and right-click on Tables (from Database1.sdf) and select Create Table from context menu
7- Add a table and set TEST for name it like below screen shot.
8- Go to Server Explorer and open Tables and right-click on TEST table and select Show Table Data from context menu and add some data in rows.

9- Go to Solution Explorer and right-click on ClassLibrary1 and select Add > New Item > ADO.NET Entity Data Model > Generate from database > Next > select TEST from Tables > Finish
10- Go to Solution Explorer and right-click on References form WindowsFormApplication1 > Add Reference > Projects > ClassLibrary1


11- Press F6 for Build Solution and TAKE A BREATH :-D
12- Select WindowsFormApplication1 from Solution Explorer and go to menu and Data > Add New Data Sources > Object > ClassLibrary1 > ClassLibarary1 > TEST
13- Double click on Form1.cs from WindowsFormApplication1 in Solution Explorer
14- Go to menu and select Data > Show Data Source and select TEST and drag and drop it to Form1


14.1- If did you have an error about with below title just go to Solution Explorer > WindowsFormApplication1References > Add References > .NET > System.Data.Entity 4.0.0.0 and double-click on it.

Error 1 The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


15- Double click on a empty space of form and go to Form1.cs > Form1_Load method and add below line for fetch data from database
this.tESTsBindingSource.DataSource = new ClassLibrary1.Database1Entities().TESTs;

16- ENJOY :-D

PS: Hey folks, if did you have any problem please don't be hesitate to contact me or write comment here ;-)

Entity Framework Tutorials
Entity Framework with Windows Form Application and SQL CE

Download
Source Codes: link

February 08, 2011

C# Index Search

Csharp Index Search
C# index searching instead of SQL SELECT

Summery
Sometimes, i heard something about slowest searching on some databases.
For example last night, i heard about a famous company have an oracle database with one billion records in one table and their software have a HUGE LATENCY for a simple compare search (WHERE Cluse) and they wait more than 15 minutes for results.
Everybody's know that's ridiculous for a DBMS like Microsoft SQL or Oracle about 15 minutes on a simple query on tiny database and it's absolutely comes from bad configuration and they need to have a DBA (Database Administrator) instead of another DBMS or Software ...

Solution
Anyway, i developed a simple and simple indexing for demonstrate power of indexing in search processes. I was shocked after coming results

Test Machine:
CPU: Intel Core i5 750 @ 2.67GHz 2.73Ghz
RAM: 4.00GB (3GB useable)
OS: Windows 7 32-bit
Database: Microsoft SQL Server Compact 3.5
Application: developed from 11PM till 6AM just for fun :-)

Search Times:
on 100,000 records = 0.24s (SQL) vs <0.01s (Index)
on 200,000 records = 0.49s (SQL) vs <0.01s (Index)
on 500,000 records = 1.92s (SQL) vs <0.01s (Index)
on 1,000,000 records = 2.46s (SQL) vs 0.02s (Index)
on 1,500,000 records = 5.91s (SQL) vs 0.04s (Index)


Conclusion
From results was shown, search on index files, with the simplest algorithm, are more than 100 times faster than simple SQL QUERY, in normal situation, with any normalization and indexing, on Microsoft SQL CE database.

Appendix I: Screen Shots



Appendix II: Source Codes
You can see the process of make a hundered index file base on two charater of start 10 digits phone numbers. for example if the phone number is 3473380789 then it's store in array[34] and then store in index34.inx file as one of index files.
/// loop all data
ArrayList[] Array = new ArrayList[100];
SqlCeConnection cn = new SqlCeConnection(_ConnectionString);
if (cn.State == ConnectionState.Closed) cn.Open();
string query = "SELECT Phone FROM People";
SqlCeCommand command = new SqlCeCommand(query, cn);
command.CommandType = CommandType.Text;
SqlCeResultSet record = command.ExecuteResultSet(ResultSetOptions.Scrollable);
int RowCount = 0;
if (record.HasRows)
{
    record.ReadFirst();
    do{
        string Data = record.GetString(0);
        int Index = Convert.ToInt32(Data.Substring(0, 2));
        if (Array[Index] == null) Array[Index] = new ArrayList();
        Array[Index].Add(Data);
        RowCount++;
    } while (record.Read());
}

/// Create all index files from arrays
XmlSerializer Serializer = new XmlSerializer(typeof(ArrayList));
for (int i = 0; i <= 9; i++)
{
    for (int j = 0; j <= 9; j++)
    {
        int Index = i * 10 + j;
        Serializer.Serialize(new StreamWriter(_IndexFileName + Index + ".inx"), Array[Index]);
    }
}
and the find result is so simple than making index files
/// Read all index files
XmlSerializer Serializer = new XmlSerializer(typeof(ArrayList));
int Index = Convert.ToInt32(SearchItem.Substring(0, 2));
ArrayList array = Serializer.Deserialize(new StreamReader(_IndexFileName + Index + ".inx")) as ArrayList;
String Message = "NOT FOUND !!!";
if (array.BinarySearch(SearchItem) == 0) Message = "*** FOUND ON INDEX ***";
I think that it's clear about SQL WHERE CLUSE search but i put coeds here for compare
/// Read all index files
SqlCeConnection cn = new SqlCeConnection(_ConnectionString);
if (cn.State == ConnectionState.Closed) cn.Open();
string query = String.Format("SELECT * FROM People WHERE Phone = '{0}'", editPhone.Text);
SqlCeCommand command = new SqlCeCommand(query, cn);
command.CommandType = CommandType.Text;
SqlCeResultSet record = command.ExecuteResultSet(ResultSetOptions.Scrollable);
if (record.HasRows) Message = "*** FIND ***";
else Message = "No record found!";


Appendix III: Downloads
SourceCode: Here
Binary: Here