Thursday, December 31, 2015

ERROR - "the 'microsoft.ace.oledb.12.0' provider is not registered on the local machine" - RESOLUTION

Scenario:

ERROR - "the 'microsoft.ace.oledb.12.0' provider is not registered on the local machine"

RESOLUTION :

There are lot of scenarios for which we might get "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine" error when attempting to connect to either an accdb or an xlsx file. 

I have spent a couple of hours searching Google for a resolution of this issue but somehow I was not getting the correct solution. Ultimately, the below solution worked best for me 100%.

Step 2. in VS, add references (say Microsoft.Office.Interop.Excel)  and write necessary business logic. 
Hope this helps.. Cheers... :)



Wednesday, December 30, 2015

Check-box 'Prefer 32-bit' disabled in Visual Studio 2012. Why?

Question: 

Check-box 'Prefer 32-bit' disabled in Visual Studio 2012. Why?

Answer: 


In Visual Studio, Switch the project to .NET 4.5 (on the Build tab of the project properties). This would re-enable the check-box "Prefer 32 bit" for AnyCPU.

Monday, July 6, 2015

Import Microsoft Access .accdb File to MS SQL Server

Steps to Import Microsoft Access .accdb File to MS SQL Server

  1. Open MS SQL Server Import and Export Wizard.
  2. For “Data Source” choose “Microsoft Office 12.0 Access Database Engine OLE DB Provider”.
  3. Click “Properties” enter the location of the .accdb file in the “Data Source” field.
  4. Under login information, choose a blank username and be sure to check “Blank Password”.
  5. Test the connection. If it works, click OK.
  6. For the “Data Destination” choose “Microsoft OLE DB Provider for SQL Server”.
  7. Enter the MS SQL server name or choose from the dropdown menu.
  8. Enter your SQL credentials and select the database you wish to import the data to, the database should show up in the dropdown menu if your MS SQL info is correct.
  9. Select “Copy data from one or more tables or views”.
  10. Select the tables you want copied and edit the mappings if needed.
  11. Continue through the wizard and hit finish to begin the import.

Ref : http://serversideguy.com/2014/02/05/import-microsoft-access-accdb-file-to-ms-sql-server/ 


Friday, July 3, 2015

The page you are requesting cannot be served because of the extension configuration

Scenario:

I was getting the below error message when trying to run my application having .svc file. 

HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

Screenshot of the error page: 

alt text

Solution 1:

Please follow the below two steps on IIS 8.0.
Step 1. Add new MIME type 
  1. Extension: .svc, MIME type: application/octet-stream
Step 2: Add new HttpHandler

  1. Request path: *.svc, Type: System.ServiceModel.Activation.HttpHandler, Name: svc-Integrated
Step 3: Restart IIS

Solution 2:

In Windows 7 and earlier, run aspnet_regiis -i 
Note: but this command seems to have been deprecated in Windows 8 yielding response This option is not supported on this version of the operating system. (...).



Friday, June 26, 2015

SQL server - Intellisense not showing the DB Objects (say, Table names) in Query Analyzer Window

Problem Scenario 1:

I was attempting to create a Stored Procedure in my database. However, the SSMS intellisense does not recognize lot of the tables which exists in the database.
Problem Scenario 2:

While writing the select queries, the Intellisense does not work as expected and is not showing the DB Objects (say, Table names) in Query Analyzer Window

Solution:

Try:
Edit -> IntelliSense -> Refresh Local Cache
This should refresh the data cached by Intellisense to provide typeahead support and pre-execution error detection.

Note: Pressing Ctrl + Shift + R refreshes intellisense in management studio 2008 as well.

Once we create a new SQL Server object, the newly created object does not get updated in the IntelliSence Local Cache and due to this, it shows red line underneath that object. So we need to refresh SSMS IntelliSence Local Cache and once we refresh it, IntelliSence will automatically add newly created object in the cache and the red line will disappear. 
Try this
Edit -> IntelliSense -> Refresh Local Cache 
or
Ctrl + Shift + R 


enter image description here

Ref URL: http://stackoverflow.com/questions/1362531/sql-server-invalid-object-name-but-tables-are-listed-in-ssms-tables-list 


Monday, May 18, 2015

ASP.NET MVC View Model / Model not binding on HTTP Post

Problem Scenario:

I am having an issue that when I post to a controller, I loose model binding and everything in my model is NULL. Here is the code that I am using:
View:

@model Models.StateDTO
@using (Html.BeginForm("AddState", "Home",new {area="Admin" }, FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)


State Name



@Html.TextBoxFor(m => m.State)
@Html.ValidationMessageFor(m => m.State)





}

Model:

public class StateDTO
    {        
        public int Id { get; set; }
  
        [Required]
        public string State { get; set; }      
    }

Controller:

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult AddState(StateDTO state)
        {
            if (state != null && ModelState.IsValid)
            {
                //.....
            }
            return View();
        }

Why is everything in my model (i.e. StateDTO state) NULL?

Solution:

One possible reason for view model is NULL :
·         The name of model in action parameter be the same as one of view model's properties

Ex: Here, same name means case insensitive (State is same as state)

Hence, the correct controller action method should be like below:

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult AddState(StateDTO vwState)
        {
            if (vwState != null && ModelState.IsValid)
            {
                //.....
            }
            return View();
        }

Here, "State" property name in model is different then action parameter i.e."vwState"

Hope this helps... Cheers :)


Saturday, May 16, 2015

XBAP Application : How to Configure Visual Studio 2013 to Debug a XAML Browser Application

Scenario:

XBAP Applications does not open in browser when run using Visual studio 2013. Instead, this gives download option..


Solution:


XAML browser applications (XBAPs) run within a partial-trust security sandbox that is restricted to the Internet zone set of permissions.

So, we need to configure Visual Studio to run the XBAP applications in browser..


Steps to configure:



To configure Microsoft Visual Studio to debug an XBAP :
  1. With a project selected in Solution Explorer, on the Project menu, click Properties.
  2. In the Project Designer, click the Debug tab.
  3. In the Start Action section, select Start external program and enter the following:
    C:\WINDOWS\System32\PresentationHost.exe
  4. In the Start Options section, enter the following into the Command line arguments text box:
    -debug filename
    The filename value for the -debug parameter is the .xbap filename; for example:
    -debug c:\example.xbap
Reference: https://msdn.microsoft.com/en-us/library/bb613597(v=vs.110).aspx 

Tuesday, April 28, 2015

IIS - Unable to start debugging on the web server. The address is not valid for this context

Issue:

I was unable to start debugging of web server or attach to process due of error:

Unable to start debugging on the web server. The address is not valid for this context.

Resolution:

I figure out that I need to Enable 32-Bit Applications in Application Pool settings:


Sunday, April 26, 2015

IIS 7.5 : HTTP Error 500.21 - Internal Server Error - Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

Solution:


This is is because ASP.Net was not completely installed with IIS. 
To fix this, simply run the following command at the command prompt
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
If I had been on a 32 bit system, it would have looked like the following:
%windir%\Microsoft.NET\Framework\v4.0.21006\aspnet_regiis.exe -i
Once this has been done, Restart IIS and run the web application. 




Friday, April 3, 2015

WCF REST Service Hosting Error : HTTP Error 500.21 - Internal Server Error


HTTP Error 500.21 - Internal Server Error
Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list in IIS 7.5



Solution:

If you see this error you haven't installed the prerequisites for ASP.NET 4.

Try this:

Step 1. Open Visual Studio Command Prompt
Step 2. Type the following: aspnet_regiis.exe -i
Step 3. Run the command
Try your service again... it should be working :-)

This command basically installs the necessary ASP pieces to get your service up and working!

VS Code # Warning - npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead

Error : VS Code - NPM Warning - npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead Solution:  Foll...