Wednesday, July 25, 2012

CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced.

When  using  Entity frame work . passing  the  data  with control i got  one error 

"Compiler Error Message: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'."

After  R & D  i  found  solution. so  i  am  posting  this  solutions because i don't  want  to  waste  your lot  of  time like as  i  did.

here  is  solution type following code  in  your web config  file  


" "

Thanks  Happy Coding

Tuesday, July 17, 2012

Hide/Show Div With Smooth Effect.

Hi  i am  giving you  one example to show  and hide  div with smooth effect .

My html Code:

<div id="done" style="display:none;">
write content here
</div>
My Java Script Code
<script>

 $('#done').fadeIn('slow');

                setTimeout(function () {
                    $('#done').fadeOut('slow');
                }, 2000);
</script>








Happy  Coding

Wednesday, July 11, 2012

How to Define action Link Using Areas In MVC

Hi..

I  am  giving  one example to  define Action Link Url Using Multiple Areas..

I am  using two areas with Name
a) Control
b) System
.

 
  • @Html.ActionLink("Main Home", "Index", "Home", new { Area = "" }, null)

  •  
  • @Html.ActionLink(" Control Home", "Index", "ControlHome", new { Area = "Control" }, null)

  •  
  • @Html.ActionLink(" System Home", "Index", "SystemHome", new { Area = "System" }, null)





  • Happy  Coding

    Monday, July 9, 2012

    Import Excell,csv file into Linq

    I  have csv file with name infocontext,  having two fileds

    1.Alies
    2. ShortDesc

    Now i  am  importing My Excel data from csv file to database using Linq  (Entity Framework in MVC3)

    I  have table Infocontext

    1. Create properties of class for Table

    --->
     public class InfoContext
        {
                         public string Tag { get; set; }
                         public string Alias { get; set; }
         }

    2.  Now Write this Method

     public ActionResult ImportCSV()
            {
              // Object of My Class
     InfoContext Dtinfo = new InfoContext();


               // Import  data  from csv file
     var dataImport = System.IO.File.ReadAllLines(Server.MapPath("~/Areas/Cataloging/infocontext.csv"));
                
                for(int i=0;i<=dataImport.Length;i++)
                {

                 // Split data from Excel by  column
                    string[] word = dataImport[i].Split(',');
                    for(int k=0;k<=word.Length-1;i++)
                    {


                        Dtinfo.Alias = word[0];
                        Dtinfo.ShortDesc = word[1];
                         db.InfoContext.Add(Dtinfo);  // Saving data  by  code  first tech. you can write your own method to save data

                        db.SaveChanges();
                    }
                }

                return View();


            }


    Data  is   Saved..

    Happy Programing

    Saturday, June 9, 2012

    Google Map in 3d

    Now  explore   your  Maps View  in 3d  with  New  Google 3d Map 6.0.

    Features
    • Tilt
    • Rotate
    • Compass Mode
    • Smooth Zooming
    • Offline Reliability 
    • Offline Building  and Rerouting
    Source :  Google.com

    Friday, June 8, 2012

    Write a program to list files in the current working directory depending upon a given pattern.?


    ♣♣♣ WRITE A PROGRAM TO LIST FILES IN THE CURRENT WORKING DIRECTORY DEPENDING UPON A GIVEN PATTERN. ♣♣♣


      import java.lang.*;
      import java.io.*;

      class pro15
    {
      public static void main(String ar[]) throws IOException
            {
                                        InputStreamReader a=new InputStreamReader(System.in);
                                        BufferedReader b=new BufferedReader(a);
                                        System.out.print("\n\tEnter the Directory Name : ");
                String s=b.readLine();
                File f=new File(s);
                if(f.exists())
                {
                            if(f.isDirectory())
                            {
                            String []f1=f.list();
                            int i;
                                        for(i=0;i
                                        {
                                        String tp=f1[i];
                                        if(tp.endsWith("java"))
                                        System.out.println("\n\t\t"+tp);
                                        if(tp.endsWith("class"))
                                        System.out.println("\n\t\t"+tp);
                                        }
                            }
                 }
            }
    }


    OUTPUT :-
                                       
                            Enter The Directory Name : d:\

                                        Test.java
                                        Test.class
                                        Abc.java
                                        Abc.class
                                        Applet2.java

    Write a program to get a file name at run time and display number of lines and words in that file.?


    ♣♣♣ WRITE A PROGRAM TO GET A FILE NAME AT RUN TIME AND DISPLAY NUMBER OF LINES AND WORDS IN THAT FILE. ♣♣♣


    import java.lang.*;
    import java.io.*;

    class pro14
    {
            public static void main(String ar[]) throws IOException
            {
            InputStreamReader a=new InputStreamReader(System.in);
            BufferedReader b=new BufferedReader(a);
            int lines=0,words=0;
            System.out.print("\n\tEnter The File Name : ");
            String s=b.readLine();
            File f=new File(s);
            InputStreamReader in=new InputStreamReader(new FileInputStream(f));
                            StreamTokenizer st=new StreamTokenizer(in);
                                                                            st.wordChars(0,255);
                                            st.whitespaceChars(0,' ');
                                            st.eolIsSignificant(true);
                                            while(st.nextToken()!= st.TT_EOF)
                                            {
                                                    if(st.ttype==st.TT_EOL)
                                                                lines++;
                                                    if(st.ttype==st.TT_WORD)
                                                        words++;
                                            }
                 System.out.println("\n\tNumber of Lines : "+lines+"\n\t Number of words : "+words);

            }
    }


    OUTPUT :-
                                       
                            Enter The File Name : c:\test.txt
                           
                            Number of Lines : 0
                            Number of Words : 2

                            Enter The File Name : c:\hook.log
                           
                            Number of Lines : 238
                            Number of Words : 357

    Write a program to copy a file to another file using java.io package classes. Get the file names at run time and if the target file existed then ask confirmation to overwrite and take necessary actions.?


    ♣♣♣ WRITE A PROGRAM TO COPY A FILE TO ANOTHER FILE USING JAVA.IO PACKAGE CLASSES. GET THE FILE NAMES AT RUN TIME AND IF THE TARGET FILE EXISTED THEN ASK CONFIRMATION TO OVERWRITE AND TAKE NECESSARY ACTIONS. ♣♣♣

    import java.lang.*;
    import java.io.*;

    class pro13
    {
            public static void main(String ar[]) throws IOException
            {
                   InputStreamReader a =new InputStreamReader(System.in);
                   BufferedReader b=new BufferedReader(a);
                    int i;
                    FileInputStream fin=null;
                    FileOutputStream fout=null;
                    String filename=null;
                    try
                    {
                            System.out.print("\n\tEnter the file name to copy to another file : ");
                            filename=b.readLine();
                            try
                            {
                                    fin=new FileInputStream(filename);
                            }
                            catch(Exception e)
                            {
                                    System.out.println("\n\tFile Not Found");
                                    return;
                            }
                            try
                            {
                                    System.out.print("\n\tEnter the file name to copy : ");
                                    filename=b.readLine();
                                    fout=new FileOutputStream(filename);
                            }
                            catch(Exception e)
                            {}
                    }
                    catch(Exception e)
                    {}
                    try
                    {
                            do
                            {
                                    i=fin.read();
                                    if(i!=-1)
                                    fout.write(i);
                            }while(i!=-1);
                           
    System.out.println("\n\tFile copied to "+filename+" Sucessfully");
                    }
                    catch(IOException e)
                    {
                            System.out.println("\n\tFile Error");
                    }
                    fin.close();
                    fout.close();
            }
    }


    OUTPUT :-
                                       
                            Enter the file name to copy to another file : c:\test.txt
                           
                            Enter the file name to copy : c:\hello.txt

                            File copied to c:\hello.txt successfully

                           
                            Enter the file name to copy to another file : c:\tests.txt
                            File Not Found

    Write a program to find the total memory, free memory and free memory after executing garbage collection gc(()).?


    ♣♣♣ WRITE A PROGRAM TO FIND THE TOTAL MEMORY, FREE MEMORY AND FREE MEMORY AFTER EXECUTING GARBAGE COLLECTION gc(()).♣♣♣

    import java.io.*;

    class pro12
            {
                    public static void main(String ar[]) throws IOException
                    {
                    InputStreamReader a =new InputStreamReader(System.in);
                    BufferedReader b=new BufferedReader(a);
                   Runtime rn=Runtime.getRuntime();
                   long mem1=0,mem2=0;
                               Integer arr[]=new Integer[1000];
                               System.out.println("\n\t\tTotal Memory is "+rn.totalMemory());
                               mem1=rn.freeMemory();
                               System.out.println("\n\tInital Free Memory is "+mem1);
                               rn.gc();
                               mem1=rn.freeMemory();
                               System.out.println("\n\tFree Memory after Garbage Collector "+mem1);
                               for(int i=0;i<1000;i++)
                               arr[i]=new Integer(i);
                               mem2=rn.freeMemory();
                               System.out.println("\n\tFree Memory after allocation "+mem2);
                               System.out.println("\n\tMemory used by alloction "+ (mem1-mem2));
                               for(int i=0;i<1000;i++)
                               arr[i]=null;
                               rn.gc();
                               mem2=rn.freeMemory();
                System.out.println("\n\tFree Memory after collecting discarded integers  "+mem2);
                    }
            }

    OUTPUT :-
                            Total Memory is 5177344
                            Initial Free Memory is 4949960
                            Free Memory after Garbage Collector 5039128
                            Free Memory after allocation 5020712
                            Memory used by allocation 18416
                            Free Memory after collecting discarded integer 5039128

    Write a program to check all the math class functions.?


    ♣♣♣ WRITE A PROGRAM TO CHECK ALL THE MATH CLASS FUNCTIONS. ♣♣♣


    import java.io.*;
    class pro10
            {
                    public static void main(String ar[]) throws IOException
                    {
                           InputStreamReader a =new InputStreamReader(System.in);
                           BufferedReader b=new BufferedReader(a);
                           System.out.println("\n\n\t\t  ****** Mathematical Functions ***** \n");
                           System.out.println("\n\t\t-----------------------------------------\n");
                           System.out.println("\n\n\t\t\t<== Exponential Functions ==>\n");
                           System.out.println("\n\t\t\t-----------------------------\n");
                           System.out.println("\n\tExponential Value = "+Math.exp(3));
                           System.out.println("\n\tpower Value = "+Math.pow(2,2));
                           System.out.println("\n\n\t\t\t<== Trignometrical Functions ==>\n");
                           System.out.println("\n\t\t\t--------------------------------\n");
                           System.out.println("\n\t sin Value = "+Math.sin(30));
                           System.out.println("\n\t cos Value = "+Math.cos(30));
                           System.out.println("\n\t tan Value = "+Math.tan(30));
                           System.out.println("\n\t cot Value = "+Math.atan(30));
                           System.out.println("\n\t <== Ordinary Mathematical Functions ==>\n");
                           System.out.println("\n\t\t\t---------------------------------------\n");
                           System.out.println("\n\tAbsolute Value = "+Math.abs(-30));
                           System.out.println("\n\tRound Value = "+Math.abs(10.456));
                           System.out.println("\n\tCeil Value = "+Math.ceil(10.4));
                           System.out.println("\n\tFloor Value = "+Math.floor(10.456));
                           System.out.println("\n\tSquare Root Value = "+Math.sqrt(9));

                    }
            }
    OUTPUT :-
                            ****** Mathematical Functions *****
                       -------------------------------------------------------
    <== Exponential Functions ==>
                            ---------------------------------------
                Exponential Value = 20.085536923187668
                Power Value  = 4.0
                            <== Trignometrical Functions ==>
                            ------------------------------------------
                Sin Value = -0.9880316240928618
                Cos Value = 0.15425144988758405
                Tan Value =  -6.405331196646276
                Cot Value = 1.5374753309166493
                            <== Ordinary Mathematical Functions ==>
                            ----------------------------------------------------
                Absolute Value = 30
    Round Value = 10.456
    Floor Value    = 10.0
    Square Root Value = 3.0

    Write a program to check all the math class functions.?


                               ♣♣♣ Write a program to check all the math class functions. ♣♣♣

    import java.io.*;
    import java.util.*;
    import java.lang.*;
    class pro9
    {
                public static void main(String args[]) throws IOException
                {
                            InputStreamReader a =new InputStreamReader(System.in);
                            BufferedReader b =new BufferedReader(a);
                            Stack st=new Stack();
                            char ans='y';
                            while(ans=='y' || ans=='Y')
                            {
                            System.out.println("\n\tMENU FOR STACK OPERATION");
                            System.out.println("\n\t1.\t PUSH");
                            System.out.println("\n\t2.\t POP");
                            System.out.println("\n\t3.\t PEEK");
                            System.out.println("\n\t4.\t SEARCH");
                            System.out.println("\n\t5.\t DISPLAY");
                            System.out.println("\n\t6.\t EXIT");
                            System.out.print("\n\nEnter your choice : ");
                            int ch=Integer.parseInt(b.readLine());
                            switch(ch)
                            {
                                        case 1:
                                                    System.out.print("Enter the total number of element to be push : ");
                                                    int n=Integer.parseInt(b.readLine());
                                                    for(int i=1;i<=n;i++)
                                                    {
                                                                System.out.print("\n\tEnter the "+i+" Element : ");
                                                                int val=Integer.parseInt(b.readLine());
                                                                st.push(new Integer(val));
                                                    }
                                                    break;
                                        case 2:
                                                    try
                                                    {
                                                    System.out.print("\n\tElement poped is  "+st.pop());
                                                    }
                                                    catch(Exception e)
                                                    {
                                                    System.out.println("\n\tStack is underflow........");
                                                    }
                                                    break;
                            case 3:
                                        try
                                        {
                                System.out.println("\n\tElement on the top of the Stack is "+(Integer)st.peek());
                                        }
                                        catch(Exception e)
                                        {
                                        System.out.print("\n\tStack is Empty");
                                        }
                                        break;
                            case 4:
                                        System.out.print("\n\tEnter the element to be searched : ");
                                        int num=Integer.parseInt(b.readLine());
                                        int sr=st.search(new Integer(num));
                                        if(sr==-1)
                                        System.out.println("\nElemet does not found in the stack");
                                        else
                                        System.out.println("\nElement found in the Stack at "+sr+"position");
                                        break;
                            case 5:
                                        System.out.println("Elemets of the stack are ");
                                        System.out.println(st);
                                        break;
                            case 6:
                                        System.exit(0);
                            default:
                                        System.out.print("Invalid Choice.......Please enter the correct choice");
                            }
                            System.out.print("Do you want to continue (Y/N) : ");
                            String s=b.readLine();
                            ans=s.charAt(0);
                            }
                }
    }

    OUTPUT :-

                MENU FOR STACK OPERATION
    1.                                          PUSH
    2.                                          POP
    3.                                          PEEK
    4.                                          SEARCH
    5.                                          DISPLAY
    6.                                          EXIT

    Enter your choice : 1
    Enter the total number of element to be push : 2
                Enter the 1 Element : 23
                Enter the 2 Element : 45
    Do you want to continue(Y/N) : y

    MENU FOR STACK OPERATION
    1.                                          PUSH
    2.                                          POP
    3.                                          PEEK
    4.                                          SEARCH
    5.                                          DISPLAY
    6.                                          EXIT

    Enter your choice : 4
    Enter the total element to be searched : 55
    Element does not found in the stack
    Do you want to continue(Y/N) : y



    MENU FOR STACK OPERATION
    1.                                          PUSH
    2.                                          POP
    3.                                          PEEK
    4.                                          SEARCH
    5.                                          DISPLAY
    6.                                          EXIT

    Enter your choice :5
                Elements of the stack are
                [23, 45]
    Do you want to continue(Y/N) : n


    Write a program to create object for TreeSet and Stack and use all methods.


    ♣♣♣ WRITE A PROGRAM TO CREATE OBJECT FOR TREESET AND STACK AND USE ALL METHODS. ♣♣♣


    import java.io.*;
    import java.util.*;
    class pro8
    {
                public static void main(String args[]) throws IOException
                {
                            InputStreamReader a =new InputStreamReader(System.in);
                            BufferedReader b =new BufferedReader(a);
                            TreeSet ts=new TreeSet();
                            System.out.print("\nEnter the total no. of Items : ");
                            int n=Integer.parseInt(b.readLine());
                            String str=null;
                            for(int cnt=1;cnt<=n;cnt++)
                            {
                                        System.out.print("\nEnter the "+cnt+" character : ");
                                        str=b.readLine();
                                        ts.add(str);
                            }
                            System.out.println("\n\tThe Item on the tree are : \t"+ts);
                            System.out.println("\n\tThe first item on the tree is : \t"+ts.first());
                            System.out.println("\n\tThe last item on the tree is : \t"+ts.last());
                            System.out.println("\n\tTotal no. of item on the tree are : \t"+ts.size());
                            System.out.print("\nEnter the element you want to delete : ");
                            String del=b.readLine();
                            ts.remove(del);
                            System.out.println("\n\tThe Item on the tree are : \t"+ts);
                }
    }

    OUTPUT :-

                Enter the total no. of Items :4
    Enter the 1 character : we
    Enter the 2 character : are
    Enter the 3 character : LogicCafe 
    Enter the 4 character : Team

    The Item on the tree are :                             [are,  LogicCafe , Team, we]
    The first item on the tree is :            are
    The last item on the tree is : we
    Total no. of item on the tree are :    4
    Enter the element you want to delete :  we
    The Item on the tree are : [are,  LogicCafe , Team]

    Write a program to sort existing array?


    ♣♣♣ WRITE A PROGRAM TO SORT EXISTING ARRAY. ♣♣♣


    import java.io.*;
    class pro7
    {
                public static void main(String args[]) throws IOException
                {
                int cnt,last,i,j,temp;
                int arr[]=new int[10];
                InputStreamReader a=new InputStreamReader(System.in);
                BufferedReader b=new BufferedReader(a);
                System.out.print("Enter the total number of array : ");
                last=Integer.parseInt(b.readLine());
                            for(cnt=0;cnt
                            {         
                            System.out.print("Enter element"+(cnt+1)+" : ");
                            arr[cnt]=Integer.parseInt(b.readLine());        
                            }
                            for(i=1;i<=last;i++)
                            {
                                        for(j=1;j<=last;j++)
                                        {
                                                    if(arr[j-1]
                                                    {
                                                    temp=arr[j-1];
                                                    arr[j-1]=arr[j];
                                                    arr[j]=temp;
                                                    }
                                        }
                            }
                            System.out.println("Array after sorting is :");
                            for(cnt=0;cnt
                            {
                            System.out.print(arr[cnt]+"   ");         
                            }         
                }
    }

    OUTPUT :-

                Enter the total number of array : 5
    Enter Element1 :23
    Enter Element2 :12
    Enter Element3 :45
    Enter Element4 :33
    Enter Element5 :21

    Array after sorting is :
                45        33        23        21        12