Caveman's Blog

My commitment to learning.

Posted by cavemansblog on January 2, 2012

I have created this message using GIMP.

Posted in Uncategorized | Leave a Comment »

VS2010 + ASP.Net: Access to path is denied

Posted by cavemansblog on September 23, 2011

 

Problem: Access to path was denied when a dotnet app was writing an excel file to a folder of the website.

Solution: Grant access to the “Network Service” account to the folder that has permissions issue.

 

Posted in IIS, Sudheer Reddy Battula | Leave a Comment »

Sql Server: Insert multiple rows with one insert statement

Posted by cavemansblog on July 11, 2011

Typical style of scripting the insert of multple rows into a table is by writing multiple insert statments as follows:

declare @TempTable table(myData varchar(50))

insert into @TempTable(myData)
values('data 1')
insert into @TempTable(myData)
values('data 2')
insert into @TempTable(myData)
values('data 3')
insert into @TempTable(myData)
values('data 4')

Following are two ways of doing the same with less script code. The first style is supported uses comma seperated values:

declare @TempTable table(myData varchar(50))

insert into @TempTable(myData)
values('data 1'),
('data 2'),
('data 3'),
('data 4')

This style of scrpting uses UNION ALL:

declare @TempTable table(myData varchar(50))
insert into @TempTable(myData)
select 'data 1'
union all
select 'data 2'
union all
select 'data 3'
union all
select 'data 4'

Posted in Sql Server | Tagged: , , | 1 Comment »

Drinking game – Fizz Buzz

Posted by cavemansblog on May 12, 2011

“Fizz Buzz” also called as “Bizz Buzz” is a drinking game. Players generally sit in a circle. The player designated to go first says the number “1″, and each player thenceforth counts one number in turn. However, any number divisible by three is replaced by the word bizz and any divisible by five by the word buzz. Numbers divisible by both become bizz buzz. A player who hesitates or makes a mistake is either eliminated or must pay a forfeit, such as taking a drink. [1]

Fizz Buzz is also used as a fun coding exercise like this: print all numbers from 1 – 100, while:

1. replacing the numbers divisible by 3 with the word “Fizz”.
2. replacing the number divisible by 5 with the word “Buzz”.
3. replacing the number that is divisible by 3 and 5 with the word “FizzBuzz”.

Following are four C# implementations of this problem:

            for (int i = 1; i <= 100; i++)
            {
                Console.WriteLine((i % 3 == 0 && i % 5 == 0) ? "FizzBuzz" :
                    ((i % 3 == 0) ? "Fizz" : (i % 5 == 0) ? "Buzz" : i.ToString()));
            }

            string s = "";
            for (int i = 1; i <= 100; i++)
            {
                if (i % 3 == 0)
                    s = "Fizz";
                if (i % 5 == 0)
                    s += "Buzz";

                if (i % 3 != 0 && i % 5 != 0)
                    Console.WriteLine(i);
                else
                    Console.WriteLine(s);

            for (int i = 1; i <= 100; i++)
            {
                if (i % 15 == 0)
                    Console.WriteLine("FizzBuzz");
                else if (i % 3 == 0)
                    Console.WriteLine("Fizz");
                else if (i % 5 == 0)
                    Console.WriteLine("Buzz");
                else
                    Console.WriteLine(i);
            }

            for (int i = 1; i <= 100; i++)
            {
                if (i % 3 == 0 && i % 5 == 0)
                    Console.WriteLine("FizzBuzz");
                else if (i % 3 == 0)
                    Console.WriteLine("Fizz");
                else if (i % 5 == 0)
                    Console.WriteLine("Buzz");
                else
                    Console.WriteLine(i);
            }

References:
1. Bizz Buzz – Wikipedia

Posted in General Programming, Sudheer Reddy Battula | Tagged: , , | Leave a Comment »

.Net 4.0 Framework poster

Posted by cavemansblog on May 5, 2011

Here are the PDF and Deepzoom versions for download.

Posted in Dotnet | Tagged: | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.