Set Port and Firewall to enable remote connect to SQL Server 2005 or 2008 Express Database

After 2 articles Remote connect to SQL Server 2005 Express or SQL Server 2005 and Change SQL Server or SQL Server Express Authentication Mode, the SQL Server remote connection still have more stuff to talk about.

Yes, we need to set Port and Firewall stuff to let remote computer can access.

Doug Kennard have given a nice instruction in his site and the article name is “How to Enable Remote Connection to SQL Server 2008 Express Database”.

We can follow his guide to finish all left things that we have to finish for the database remote connection.

Some day I will give my own experience if I have free time to record all my setting steps.

Change SQL Server or SQL Server Express Authentication Mode

When I installed SQL Server Express on my local PC, I used to select Windows Authentication mode only, but later I might have to change the Authentication mode for some reasons such as connect this SQL Server database from another computer and I don’t want to set a new windows user account for another computer to access current computer, So I have to select SQL Server Authentication mode then.

Actually in SQL Server Express, there are only 2 type of Authentication Modes:  Windows Authentication mode and SQL Server and Windows Authentication mode, there is no SQL Server Authentication mode only. So if you want to change from Windows Authentication mode to  SQL Server Authentication mode, it will be changed to SQL Server and Windows Authentication mode.


1: In SQL Server Management Studio Express, right click on the DB Server name, then click Properties:

2: On the Security page, under Server authentication, select the new server authentication mode which you want, and then click OK :

3: In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.

To restart SQL Server from SQL Server Management Studio:    In Object Explorer, right-click your server, and then click Restart. If SQL Server Agent is running, it must also be restarted.

To enable the sa login by using Transact-SQL (from Microsoft website)

If Windows Authentication mode is selected during installation, the sa
login is disabled and a password is assigned by setup. If you later
change authentication mode to SQL Server and Windows Authentication
mode, the sa login remains disabled. To use the sa login, use the ALTER
LOGIN statement to enable the sa login and assign a new password.
Execute the following statements to enable the sa password and assign a password.


To enable the sa login by using Management Studio
(from Microsoft website)

   1.      In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties.
   2.      On the General page, you might have to create and confirm a password for the sa login.
   3.      On the Status page, in the Login section, click Enabled, and then click OK.

Connection String:

Now you can get Connection string:

1: Windows Authentication (Trust Connection):

connectionString="Data Source=MyDBServerAddress\SQLEXPRESS2005;Initial Catalog=S800_DB_2010;Integrated Security=True"

2: SQL Server Authentication:

connectionString="Data Source=MyDBServerAddress\SQLEXPRESS2005;Initial Catalog=testDB;User ID=terminalDBA;Password=myPassword;

Page Not Found Multiple Language Text

When we build Web Applications, we need to give a 404 page when the url link dead or not work. So “Page Not Found” content should be put in the 404 page. It is so easy because you just put the text on that page.

However, how about multiple cultural web applications ? You have to give different languages. So do you know other languages for “Page Not Found ” ?

It is interesting that Microsoft site has just this kind of page which you might need, there are multiple languages “Page Not Found” on a single page:

All the content is just “Page Not Found” and a small section detail message. So you can find your languages which you want.

Page Not Found

We're sorry, but the page you requested could not be found. Please check your typing and try again, or use the search options on this page.

Page non trouvée

Désolé, la page demandée est introuvable. Vérifiez l'orthographe de l'URL ou utilisez les options de recherche de la page.

No se encontró la página

Lo sentimos, no se pudo encontrar la página solicitada. Revise el texto e inténtelo de nuevo, o use las opciones de búsqueda de esta página.

Seite nicht gefunden

Die von Ihnen angeforderte Seite wurde nicht gefunden. Überprüfen Sie Ihre Eingabe und versuchen Sie es erneut, oder verwenden Sie die Suchoptionen auf dieser Seite.

Pagina non trovata

Impossibile trovare la pagina richiesta. Controllare che il testo digitato sia corretto e riprovare oppure utilizzare le opzioni di ricerca disponibili in questa pagina.



페이지를 찾을 수 없습니다.

죄송합니다만, 요청하신 페이지를 찾을 수 없습니다. 입력하신 문구를 확인하시고 다시 시도하시거나, 본 페이지의 검색 옵션을 사용하여 주십시오.

Página não encontrada

Infelizmente, a página solicitada não pôde ser encontrada. Verifique se você digitou o endereço da página corretamente e tente novamente ou use as opções de pesquisa nesta página.

Страница не найдена

Не удается найти запрошенную страницу. Проверьте правильность введенного адреса и повторите попытку или воспользуйтесь поиском на этой странице.

Stránka nebyla nalezena

Omlouváme se, ale požadovaná stránka nebyla nalezena. Ověřte, zda v zadané adrese stránky není chyba, a akci opakujte, nebo použijte možnosti vyhledávání na této stránce.





System.AccessViolationException: Attempted to read or write protected memory ?

A common error always pop up when you run your .NET Application just like the following :

Error Details:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

The reasons and resolutions:

These are different solutions due to different case, Here I collect some of them which I have found:

0: First of all, telerik company has a solution for their products, maybe it is fit for your case:

so far we have found the following reasons for the exception:

    * configuration/installation problems of the framework, VS.NET and/or SourceSafe/SourceGear (usually the SourceSafe/SourceGear installation is corrupted). Restarting of VS, IIS or the machine does not help;
    * running 32-bit code which tries to call 64-bit one and vice versa (this appears on 64bit machines, i.e. 64-bit CPU, Windows or .NET 2.0 version).

This error message is still being investigated and other solutions may exist. In case you are able to fix the problem in some other way than the described below, please let us know, so that we can update the article.

   1. Try creating a new project – you should be able to use the Telerik controls in that project.
   2. If you are still using the beta version of VS2005, update to the latest official version and try again.
   3. A webserver with multiple worker processes may cause this inconsistency. The problem should disappear once the number of worker processes is set to 1.
   4. Ensure that the VS.NET addin works in SourceSafe/SourceGear works. You can do that by checking files in and out of your repository (try checking out a page before dropping a control and see if it works). Try uninstalling all copies of VSS that you may have on your machine and install the latest version only.
   5. If you use the 64bit version of .Net2, then review this Microsoft support article on switching from .NET1.x 32bit to .NET2 64bit:;en-us;894435, more importantly the ASP.NET 2.0, 32-bit version section and setting the 64bit Web Service to Prohibited.
   6. Simply copy and paste the controls’ DLLs and XML files into the bin directory.
   7. If none of the above works, you may consider reinstalling the machine.

1: (for Oracle Exception) This happens sometime due to corrupt data in memory. To resolve it Please restart the application or restart the system.

2:  I found the reason: I had installed a program called “Netlimiter” on the test server (used for testing the app with limmited bandwidth). It was en error in a nsl dll from that program that caused my problem. After uninstalling the program it worked fine.

However, I do not know why I only got the error with .Net 2.0 and not with 1.1.


Issue Description:
— Getting following pop-up error when trying to drag and drop Microsoft Controls in Visual Studio 2005 design view


— There was something wrong with the registration of VS packages. We reset those and it resolved the issue.
— We ran the following command from the
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE>devenv.exe /ResetSkipPkgs

— We opened the existing project in Visual Studio 2005 and now we did not get the above error while dragging and dropping Microsoft and non-Microsoft Controls.

— Tried closing and opening up the project again and still no issues.

(will continue to find more if possible)

C# lock Statement

The lock keyword ensures that one thread does not enter a critical section of code while another thread is in the critical section. If another thread tries to enter a locked code, it will wait, block, until the object is released.

The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock. This statement takes the following form:

  // using System.Threading;

    class Account
        private Object thisLock = new Object();
        int balance;

        Random r = new Random();

        public Account(int initial)
            balance = initial;

        int Withdraw(int amount)

            // This condition will never be true unless the lock statement
            // is commented out:
            if (balance < 0)
                throw new Exception("Negative Balance");

            // Comment out the next line to see the effect of leaving out
            // the lock keyword:
            lock (thisLock)
                if (balance >= amount)
                    Console.WriteLine("Balance before Withdrawal :  " + balance);
                    Console.WriteLine("Amount to Withdraw        : -" + amount);
                    balance = balance - amount;
                    Console.WriteLine("Balance after Withdrawal  :  " + balance);
                    return amount;
                    return 0; // transaction rejected

        public void DoTransactions()
            for (int i = 0; i < 100; i++)
                Withdraw(r.Next(1, 100));

    class Test
        static void Main()
            Thread[] threads = new Thread[10];
            Account acc = new Account(1000);
            for (int i = 0; i < 10; i++)
                Thread t = new Thread(new ThreadStart(acc.DoTransactions));
                threads[i] = t;
            for (int i = 0; i < 10; i++)

( From Microsoft site )

Great svn client software for Visual Studio

Let me recommend a plugin for Visual Studio, its name is AnkhSVN.

I think many programmer might be using TortoiseSVN as a svn client tool. Yes, TortoiseSVN is a great SVN client (it has server function also) too. But if you write code using visual studio, you might think about a svn client which is more fit for Visual Studio IDE.

For example, you might know it is painful if you need to add or delete files, when you use TortoiseSVN, most of time you have to click “Add” to add your new generated files, if you forget to “Add” files, TortoiseSVN will not add your new files by default.

Fortunately there is a perfect svn tool is just for Visual Studio, After you used this svn client, you will not want to leave away from it.

Actually, it is a plugin for Visual Studio, its name is AnkhSVN, you can download from its official site

AnkhSVN is a Subversion Source Control Provider for Microsoft Visual Studio 2005, 2008 and 2010.

AnkhSVN provides source code management support to all project types supported by Visual Studio and allows you to perform the most common version control operations directly from inside the Microsoft Visual Studio IDE.

The Pending Changes dashboard gives you a unique insight in your development process and provides easy access to the source code and issue management features. The deep source code control (SCC) integration allows you to focus on developing, while AnkhSVN keeps track of all your changes and provides you the tools to effectively handle your specific needs.

Remote connect to SQL Server 2005 Express or SQL Server 2005

Microsoft SQL Server 2005 or Microsoft SQL Server 2005 Express do not allow remote access by default. If you want to remote connect or use another computer in your LAN, you have to configure on your SQL Server 2005 or SQL Server 2005 Express.

In this article, we will use SQL Server 2005 Express as the sample database.

If you don’t set something for remote connection, you may receive an error message. The following error message is a sampe:

Sqlcmd: Error: Microsoft SQL Native Client: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.

Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition

First, I suggest that you use SQL SQL Server Authentication connection but not Windows Authentication connection (you still can) for your SQL Server Database connection. If you use Windows authentication, you should have identical accounts on both server PC and remote PC (username and password are the same), This is not good for remote database connection. Don’t you think so ?

To enable remote connections on the instance of SQL Server 2005 Express, please read the following steps:

   1. Find your Microsoft SQL Server 2005 program on the Start menu in your Windows XP or related OS, point to Configuration Tools, and then you will see the menu item SQL Server Surface Area Configuration (please see below):

   2. Click SQL Server Surface Area Configuration, then click Surface Area Configuration for Services and Connections.

   3. On the new page: Surface Area Configuration for Services and Connections page,select the database which you want to set for remote connection, in our case, we have installed 2 SQL Server Express databases, we select SQLEXPRESS2005 database, then expand Database Engine, click Remote Connections, check on the Local and remote connections radio button, then select the appropriate protocol to enable for your environment, and then click Apply.

   4. Please Click OK if you receive the following message:

   5. Return to the Surface Area Configuration for Services and Connections page, expand Database Engine, select Service, On the right side, click Stop button, then wait until the MSSQLSERVER (MSSQL$SQLEXPRESS2005) service stops, and then click Start button to restart the MSSQLSERVER (MSSQL$SQLEXPRESS2005) service.

(part of above text were from Microsoft website)

Other instruction info:


The first thing that can block a connection to SQL Server is a firewall. If you have any firewalls, make sure they are configured to allow connections to SQL Server. The default TCP port that SQL Server uses is 1433. Firewalls include McAfee, Norton, Windows Firewall which ships with Windows XP SP2, and Internet Connection Firewall (ICF) which ships with Windows 2000.

(Above text copied from here Teratrax site, more info please click to visit )

Intel Dual Core vs Intel Core 2 Duo

When you buy a computer with the label “Intel Inside” which means the computer’s CPU is Intel CPU, Then maybe you were confused by “Pentium Dual Core” and “Core 2 Duo” .

Actually, when we say “Dual Core”, it should cover all processors that has 2 cores. That means: Pentium Dual Core is a Dual Core CPU, and also Core 2 Duo is a Dual Core CPU. Pentium Dual Core and Core 2 Duo are two types of Dual Core CPU.

People always simply ask Which one is better between Pentium Dual Core and Core 2 Duo ?  If you can get correct answer you should give these two CPU’s feature and data, for example, we might have to say Pentium Dual Core 935 at 3.4Ghz and the Core 2 Duo at 1.86Ghz, Then the answer should be clear is that Core 2 Duo is better.

Why lower frequency Core 2 Duo 1.8Ghz is better than Pentium Dual Core 3.4Ghz ? because the former is faster.

Frequency is not the only one factor which effect the CPU speed, The main factor might should be IPC (instruction per clock cycle), Core 2 Duo has much higher IPC which means it can process much more data each clock cycle. Just like there are two persons move stones, Both of them have 1 hour limited, person A might move slower (lower frequency) than person B (faster frequency), but each time Person A can move 10 stones while person B only move 5 stones,   So finally after 1 hour, Person A will move higher amount of stones, which means in the computer field, person A can handle more data, so person A (Core 2 Duo) is faster.

So we can not simply say Core 2 Duo is better or Pentium Dual Core is better, but normally, most of computer which you see in comupter store with Core 2 Duo is more expensive than computer with Pentium Dual Core, The first reason is that people always think Core 2 Duo is newer or better than Pentium Dual Core, the second reason is that the CPUs in those computer should be really different. The more expensive computers really has faster and better CPU such as Core 2 Duo, as long as the computer store is not a cheating store.

Actually, I wanted to write this article 2 years ago, but I done it until today. When I wrote this, the CPU technology and market has changed very much, there are more new generation CPU has been in market, such as Intel i3, i5, i7..etc. I will write another short article for them some day later.

How to change all tab pages’s title for a TabControl using C# ?

In some cases such as Multiple languages dynamically switching and if you have a main TabControl with some sub tab pages will be dynamically added into it, you might find it is not easy if you want to change all these dynamic tab pages.

Actually, if you have done Multiple languages dynamically switching mechanism in your code, for these dynamic tab pages, you can use the following code to “re-write” their title so that this title can get a chance to retrieve resource file and get text due to current cultural setting:

                for (int i = 0; i < tabControl.TabPages.Count; i++)
                    TabPage page = tabControl.TabPages[i];
                    string pTitle = "";
                    foreach (Control ctl in page.Controls)
                        if (ctl is Form)  //Asume tab page include the sub control which is Form
                            pTitle = ((Form)ctl).Text;  //The Text has already been set by cultural resource somewhere (before this block of code)
                    page.Title = pTitle;

Open Visual Studio 2008 project file in Visual Studio 2005 ?

We know the Microsoft Visual Studio IDE Higher version can open the project which created in lower version by convert wizard steps. For example, whey you try to open a VS 2005 project in VS 2008, you will see a convert wizard windows firstly, it helps you convert old project to new project which can be opened in VS 2008.

But, Is it possible to open a Visual Studio 2008 project in Visual Studio 2005 ?

The answer is : Yes.

Of course we can not do it in the Visual Studio IDE directly. We need to do some works by manual.

Firstly, we need to know the higher version project doesn’t use higher version of VS studio’s features. Then it is possible to open the higher version of project in lower version of VS studio.

The solution is that we just need to change some information related Visual Studio Version such as version number.

For example:

1: .sln

    Microsoft Visual Studio Solution File, Format Version 10.00
    # Visual Studio 2008
    Project(”{F184B08F-C81C-45F6-A57F-5ABD9991F28F}”) = “ProjectConverter”,
    “ProjectConverter.vbproj”, “{B637ACFD-0AFC-4FBB-A8C0-602B5ABA62F0}”
    Project(”{54435603-DBB4-11D2-8724-00A0C9A8B90C}”) = “Setup”, “Setup\Setup.vdproj”,



2: .vbproj, .csproj, .vcproj

ToolsVersion="3.5" DefaultTargets="Build" xmlns="">
9.0.21022    2.0
{B637ACFD-0AFC-4FBB-A8C0-602B5ABA62F0}    WinExe

    ProjectConverter.My.MyApplication    ProjectConverter    ProjectConverter    512

    WindowsForms    v2.0    On    Binary


The above examples copied from This Article in Chinese.

Also, there is another More Professional Article and there are much more detail information (Visual Studio 2005/2008 Interoperability).