Wednesday, February 15, 2017

How to Update SQL SERVER 2012 Collation

If you have installed the SQL SERVER 2012 but had setup a different collation, here are the steps to change it:

1. Locate the install folder in the Program files. Usually it is in this folder:

C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\SQLServer2012

2.Open the Command Prompt

3. Change Directory to the one above (or where the setup is stored).

4. Run the Script below in the command prompt:

Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLCOLLATION=Latin1_General_CI_AS /SQLSYSADMINACCOUNTS=[username] /SAPWD=[Password]

5. Ensure that the [username] and [Password] are your system administrator account credentials.

6. After running the command, the SQL Server's collation is changed.

Monday, January 2, 2017

How to break when exception is thrown in C#

Sometimes during debugging an application, an unhandled exception is encountered in which we need to investigate. To find the details of this exception, we need to stop at the point of occurrence and check out the whole exception object or line of code that has a fault.
If your Visual Studio is not configured to stop on the occurrence of the exception, here is the way to turn it on:

1. Go to menu's Debug > Exceptions



2. Tick the Thrown of the CLR Exceptions

Find Control in .NET using Control ID

Here is a snippet that I have used to find a control in ASP.NET recursively:


private static Control FindControlRecursive(Control Root, string Id)
{
            if (Root.ID == Id)
            {
                return Root;
            }
            foreach (Control Ctl in Root.Controls)
            {
                Control FoundCtl = FindControlRecursive(Ctl, Id);
                if (FoundCtl != null)
                {
                    return FoundCtl;
                }
            }
            return null;
        }

Saturday, June 20, 2015

error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file.

Have you encountered this error?

error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.


Is this error keep on destroying your life and blowing your mind?

Don't worry, you are not alone!

It turns out that you just need to configure your cs project because you have relied too much with the Nuget Package Manager.

The Entity Framework 6 is a cool tool that all of us wanted to use. Through the Nuget, the EF will be added to your project. However, it turns out, the Copy Local property of the reference to these files:

EntityFramework.dll
EntityFramework.SqlServer.dll

are not set to true.



The tricky part is that even though the Visual Studio (2013 in my case) shows in the Property Window that the Copy Local is equal to True, the project file does not.

To fix this, set the Copy Local to False, save the project,  and then set back to True.

I found from the Stackoverflow, that you may also need to put this line inside your DBContext's initialize method of your Data Entities project.

var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;





Saturday, June 13, 2015

How To Turn off Start up Applications in Windows

This procedure helps you turn off unwanted applications during Windows Start up.

The steps below demonstrates how to do it in Windows 7.

1. Go to Start .
2. Type MSCONFIG.

3. The System Configuration tool will be launched. In that tool, go to Startup tab, and uncheck the applications that you don't want to load during start up.


4. Click ok once you are done.
5. Click the restart button to apply the changes.