Wednesday, 15 July 2015

Working with MVC + Entity Framework + Oracle Database



Hey, Have started working with MVC, entity framework and Oracle database???

That's worth to learn. You might fall in a situation that you don't find Oracle Connection when choosing new datasource from entity framework new connection option.

If oracle connection option is missing (I hope you've installed Oracle DB 10g or 11g) then what to do??



you need to setup Oracle Data Access Components.

Software Link:
http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html

Documentation:
http://www.oracle.com/technetwork/topics/dotnet/install112012-164342.html


Note:

VS 2013 you need 
ODAC 12c (12.1.0.2.1) or later. you cannot work with 11.1 version series if you have 2013.

Now what?? While installation you need to show where your Oracle base path is. base path is something directory like this... 
X:\oracle11g\product . X is your drive letter :P 
[I know you are smart enough to understand this]

What you had to do if don't setup like this... ??? Nothing complex...

You had to copy two (2) file inside e.g. E:\oracle11g\product\11.2.0\dbhome_1\NETWORK\ADMIN.


to ODAC location e.g. x:\whatever\product\12.1.0\client_1.

What are those two file?

tnsnames.ora 
and
sqlnet.ora

What these two files do? They just show the path where oracle_home is...

now I hope all is set...

now open you MVC project. add new item > entity framework> wizard will show Oracle Connection as intended.


You may try EZConnection.




see the screenshot. one screenshot can tell more than me withing less time... :) 






If you feel problem you can contact me...

This video tutorial may help you.




Saturday, 11 October 2014

HTTP Error 500.21 - Internal Server Error



solution


Try to re-register ASP.NET with aspnet_regiis -i. It worked for me.
A likely path for .NET 4 (from elevated command prompt):
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

Monday, 11 August 2014

How to hit method in MVC area

Hello,
Let's see how to hit/invoke a method in area.

If you are trying to invoke a method in another area with "RedirectToAction" you can write:

return RedirectToAction("Login", "Account", new { Area = ""}); //this will hit you default area. No need to write anything inside inverted comma.

If you have area name then you must have to mention that name inside inverted comma.

return RedirectToAction("Login", "Account", new { Area = "AreaName"}); 

If you want to trigger it from navigation menu item:

item.Add().Text("Area").Url("~/AreaName/ControllerName/MethodName");


Use of TempData in MVC

Hey,
I found it very useful. TempData do just as its name said. Temporary storage for any information.
Suppose you are redirecting one controller to another controller and while redirecting you think you will pass some message or data to that controller. How will you do that? Yes, at first you will think that pass it through parameter. You are right. But if you just want to pass a simple message and for that reason you don't want to create a parameter you may use this TempData.

Let's see how we may implement it:

Public ActionResult INDEX()
{
       TempData["Message"] = "Hello, Improve your skill";
       return RedirecToAction("AnotherMethod");
}

Public ActionResult AnotherMethod()
{
       ViewBag.Information = TempData["Message"] as string;
        var model = context.getEmployeeList();
        return view("ViewName");
}


Now, In your ViewName.cshtml you can access ViewBag.Information like this-


<label>@ViewBag.Information</label>

Hope this will help...

Saturday, 28 June 2014

HTTP Error 500.19 - Internal Server Error

ha ha ha...
it took me a long time to solve... just published my MVC app to local file directory and planning to browse this under IIS 8.5 and stuck with this error...
I enabled IIS from CP Add windows features on/off BUT I didn't know I would have some more stuff to do...

  • Click "Start button"
  • in the search box, enter "Turn windows features on or off"
  • in the features window, Click: "Internet Information Services"
  • Click: "World Wide Web Services"
  • Click: "Application Development Features"
  • Check (enable) the features. I checked all but CGI.

that's all... 

Sunday, 15 June 2014

JQuery AutoCompleteUI with custom parameter...

When we work with JQuery AutoCompleteUI sometimes we need to pass additional parameter to the server to filter the Resul/AutoComplete data. To send additional data we need to work a little bit more. here I'm showing how we can achieve our goal:


 $("#TextBox").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/Accounting/Group/GetGroupNameJson/",  <===== your URL (I's working on MVC)
                datatype: "json",
                data: {
                    filter: $("#dropdown").val(), <========= the value of dropdown list need for filtering
                    term: request.term               <=========this term will be automatic found from #TextBox
                },
                success: function (data) {
                    response(data); <this data contains not only 'label' but also 'value'
                }
            });
        },
        minLength: 1, <==============min length to start search
        select: function (event, ui) {
            event.preventDefault(); <=== this line required
            $('input[name="ThisField"]').val(ui.item.label);
            $('input[name="AnotherField"]').val(ui.item.value);
            return false;
        },
        focus: function (event, ui) {
            event.preventDefault();
            $("#ThisField").val(ui.item.label);
        },
        //position: { my: "right bottom", at: "left top", collision: "flip" },
    });

Sunday, 25 May 2014

Simple Math Problem

Problem Statement:

IN a shop, the cost of 4 shirts, 4 pairs of trousers and 2 hats is TK 560. The cost of 9 shirts, 9 pairs of trousers and 6 hats is tk 1290. what is the total cost of 1 shirt, 1 pair of trousers and 1 hat?

Answer: 

Statement1: 4 shirts, 4 pairs of trousers and 2 hats is TK 560.
                    let, 4s + 4p + 2h = 560.....(1)

statement2: 9s + 9p+6h = 1290 .....(2)

                  statement (1) divided by 2 and get
                   2s+2P+1h = 280....(3)                   statement (2) divided by 3 and get
                   3s+3p+2h = 430.....(4)
                   statement (4) divided by statement (3)
                   1s+1P+1h = 150.....(ANS)