Dotnet Tutorials ,Codings & Examples: January 2011 <h1 class='display-2'> January 2011 ~ Dotnet Tutorials ,Codings & Examples</h1>

Insert single apostrophe in sql server varchar datatype

Single Apostrophe  in Sql server

If you are using SQL strings in your database , chances are you have come across problem with strings in SQL statement. One extra apostrophe screws up the SQL string, causing the SQL statement to fail.

if you  insert the  following query it throws the error like below

insert into emp values('gurucoder's')

Error:

Msg 102, Level 15, State 1, Line 1


Incorrect syntax near 's'.

Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string ')
'.


After some googled i found the solution to solve this .putting the double apostrophe in string value

insert into emp values('gurucoder''s')
 
The above query with double apostrophe will insert the values like gurucoder's in database field

csproj is not installed error

csproj is not installed error Make sure the application for the project type (.csproj) is installed

This error occurs when u attempt to open the old visual studio project in new Version IDE...
there is no need to reset the enviroment settings and unistall the IDE .To solve this error follow the solution







solution:


Go to Run command type the below :

devenv.exe /resetskippkgs

perhaps i'm faced this error and i used the above solution it perfectly works within a minute............... 

Fibonacci Numbers

Fibonacci Series:


Fibonacci examples:

The Fibonacci sequence is named after Leonardo of Pisa, who was known as Fibonacci (a contraction of filius Bonacci, "son of Bonaccio").
Fibonacci's 1202 book Liber Abaci introduced the sequence to Western European mathematics, although the sequence was independently
described in Indian mathematics and it is disputed which came first.



The sequence of number 1, 1, 2, 3, 5, 8, 13, 21, 34 . . . . each of which sum is the sum of the two previous numbers.
These numbers are also called Fibonacci numbers. The ratio of one Fibonacci to the preceding one is a Convergent of the
 continued fraction.The sum of the Fibonacci Sequence can be directly obtained from Pascal's triangle.Fibonacci numbers are
 named after Leonardo of Pisa, known as Fibonacci. The Fibonacci numbers are also a Lucas sequence.Fibonacci numbers can be given by,

Fn = Fn-1 + Fn-2

where, F1 = F2 = 1
F0= 0 F1= 1 F2= 1 F3= 2 F4= 3
F5= 5 F6= 8 F7= 13 F8= 21 F9= 34
F10= 55 F11= 89 F12= 144 F13= 233 F14= 377

source : wikipedia


csharp / c# program for Fibonacci series recursive example :


class Program
    {
        static void Main(string[] args)
        {
          Program p=new Program();
          
            Console.Write(p.Fib(14));
            Console.ReadLine();
        }

        public int Fib(int num)
        {
            int res;
            if (num == 1 || num == 0)
                return num;
            res = Fib(num - 1) + Fib(num - 2);
            return res;
        }
    }


Output : 377