Friday, July 11, 2014

Error : The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

Here i found another error generated over working with importing excel file. So, my idea behind importing an excel file is simple shown below.

Code to import excel file is shown below.
excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties='Excel 12.0;HDR=YES';";
DataTable dt = new DataTable();
OleDbConnection excelConnection1 = new OleDbConnection(excelConnectionString);
string query = string.Format("Select * from [{0}]", excelSheets[0]);
using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, excelConnection1))
{
        dataAdapter.Fill(ds);
}

but, doing this stuff i found error "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine."


Googling around this error help me out by two cases. For the solution, i found following two links useful.
(1) 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

(2) 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine error


So, that's it for this error.

Tuesday, June 24, 2014

Error : 405 Method Not Allowed for PUT

Recently i came across with a problem where PUT is not working for me and throwing error of "405 Method Not Allowed for PUT".

Following line of code i found working for me.
- Open your web.config file
- Go To "system.webServer" Tag
- Add runAllManagedModulesForAllRequests="true" in modules clause
- Put remove name="WebDAVModule" between modules tag
- After adding this lines, your config will look like following..
This change works for me. Also, There are some useful links for this as well shown below.
(1) 405 method not allowed web api

(2) Web API on IIS 8.0 – 405 Method Not Allowed for PUT

(3) Web API Put Request generates an Http 405 Method Not Allowed error
                      

Thursday, March 13, 2014

TFS Options in VS2012

Here is some tips regarding known TFS options while you are working with VS2012.
(1) Go Online : for VS2010 if you are working offline you will find an icon of Go Online on Solution Explorer, but for VS2012 you will find this option under:
File --> Source Control --> Go Online

(2) Source Control Explorer: for Source Control Explorer in VS2010 you found this option under Team Explorer --> Source Control. For VS2012, this option found under Team Explorer --> Home --> Source Control Explorer

(3) Following menu items are independent items in VS2010 context menu
- Get Specific Version

- View Pending Changes
- Shelve Pending Changes
- Undo Pending Changes
- View History
- Annotate
But, in case of VS2012 you will find all this options under

Context Menu of Solution Explorer on Any Item --> Source Control

(4) Disconnect TFS

VS2010: In this case, you will find this option under Team Explorer to disconnect from TFS as well as from Top Menu --> Team --> Disconnect To Team Foundation Server

VS2012: To disconnect from TFS server you need to navigate to Top Menu --> Team --> Disconnect From Team Foundation Server and there is no such option available on Team Explorer to disconnect.

Download Microsoft Visual Studio Team Foundation Server 2012 Power Tools
   
        

Tuesday, March 11, 2014

Working with Conditional Comments

Here are some links about Conditional Statements.

Conditional comments are statements interpreted by Microsoft Internet Explorer in HTML source code. Conditional comments can be used to provide and hide code to and from Internet Explorer.

(1) About conditional comments

(2) Conditional comments

(3) Conditional comment

(4) Conditional comments of IE
     
      

Thursday, February 20, 2014

Error : CSS, Images not loading when Debub="false" in web.config for MVC Application

For MVC application, i came across problem while i set Debut="false" in web.config file and ultimately css and images not loading from BundleConfig file but when i set it to "true" will load all files.

While googling i got some Web.Config settings shown below, modify your web.config in the system.webServer section to run these requests through the BundleModule


But, this line of code for Web.Config not solved my problem. Finally, i got to know about bundle name in BundleConfig file, i chnaged it shown below.

- Before Change Path :
"~/Content/css" : My all CSS were reside under "Content/css"
- After Change:
"~/Content/css/css"

So, to get rid of the problem you need to give path exactly as per project and put extra "css" after it will resolve your problem for CSS not loading.

Friday, January 31, 2014

Error - A potentially dangerous Request.Path value was detected from the client

During calling REST service from client end i came across the below error..

"A potentially dangerous Request.Path value was detected from the client"

For this, i found following solution in web.config file of REST end and it works for me



- For httpruntime put requestpathinvalidcharacters="" & requestvalidationmode="2.0"
- For pages put validaterequest="false" 
- Both of these tags are located under configuration --> system.web

Also, there are some useful links too for this error
(1) Getting “A potentially dangerous Request.Path value was detected from the client (&)”

(2) A potentially dangerous Request.Path value was detected from the client (*)

Tuesday, January 28, 2014

Working with filtering JSON objects

Following are some way by which we can filter out objects in JSON format using jQuery.

(1) filter : using this method we can filter out JSON data by following way..
var filterData = (JSONDATA.filter(function (item) {
            return item["ColumnName"] != "Your Data To Compare";
        }));
- In above situation, filter will loop through each data and finds the specific data by comparing it.
- filter is only available in new version of jQuery. Also, it is not working in IE-8 and not compatible with IE-8 or lower.

(2) grep : using this method we can filter out JSON data by following way..
var filterData = ($.grep(JSONDATA,function (item,l) {
            return item["ColumnName"] != "Your Data To Compare";
        }));
In above situation, grep will loop through each data and finds the specific data by comparing it.


(3) slice : using this method we can removes and returns a given number of elements starting from a given index from JSON object by following way..
var filterData = $.each(JSONDATA.slice(1,3), function(item) {
                    return item;

                }),
- In above example, removes three elements starting from index position 1 (i.e., the 2nd, 3rd, and 4th elements) and returns them as an array.

- Find following link for the Grep vs Filter in jQuery.
    

Friday, August 23, 2013

Working with Code Snippet

If you are working with Visual Studio IDE for c#/vb then you came across a situation where you need to write down a same line of code at many place.

Here is the way how you can save your time from writing same line of code again and again.


(1) Write it down on "General" Tab of your Toolbox
- if you are aware of toolbox then you probably knowing tabs under this toolbox. In Toolbox, for HTML view you will find different controls available in tree view style and tabs are like "Standard", "Data", etc.. are available (below screenshot).

- You will find one more tab that is "General". In general tab you can save your frequent line of code so that whenever you require them you can easily search from this Toolbox and get those line of code you require (Keyboard shortcut for Toolbox is Ctrl + Alt + X).To do this, just copy line of code you require frequently and paste that under "General" Tab of "Toolbox" and Once you paste, it will appear under your "General" Tab (below screenshot).



You can rename its title so that it will be easily searchable code for your reference. Once you paste this line of code, you will be able to see this at both "HTML" and "Code Behind" Toolbox view and use this line of code at both places.

(2) Use Code Snippet
Visual Studio provides code snippets in built so that you can use some code samples and you are not need to write that line of code.

To use Code Snippet just write down short name used for that snippet. So, let say you are about to create new property then write "prop" and hit "Tab" key and it will automatically insert line of code for property.


You will find some links from my previous post for Code Snippet in Visual Studio.

Monday, August 5, 2013

Working with Macro Parameter In Umbraco CMS

In your Partial View, if we are passing parameters then to fetch/pass value to parameters we can use following way.

code
:var data = Model.MacroParameters;

description: This will fetch the Macro Parameter associated with our partial view. This line of code are placed in your partial view.

Now, to fetch value of your paremeter value use following line of code
string Name = data.FirstOrDefault(c => c.Key == "ParameterName").Value.ToString(); 

"ParameterName" is the name of your parameter/property which is defined in partial view.

This will fetch value passed to parameter in your partial view and you can use this value to your internal function.