Wednesday, April 25, 2007

Workaround for 'Divide by zero error encountered'

Today I just want to write a sample explaining the workaround for 'Divide by zero error encountered.' error in SQL Server.

Sample Table Structure for demo purpose

Create Table dbo.TestDivideByZero
(
WebSite varchar(50),
NumOfHits int,
Income int
)
Go


Insert dummy records

Insert into dbo.TestDivideByZero values ('a.com', 100, 20)
Insert into dbo.TestDivideByZero values ('b.com', 10, 0)
Insert into dbo.TestDivideByZero values ('c.com', 300, 25)

Insert into dbo.TestDivideByZero values ('d.com', 1300, 225)
Go


Query to produce 'Divide by zero error encountered.' error

Select WebSite, NumOfHits / Income from dbo.TestDivideByZero
Go

This would throw the below error:

Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.

Workaround

Make use of NULLIF function. Like, if the value is 0 then return NULL. For better understanding execute the below query and see it for yourself.

Select WebSite, NumOfHits / NullIf(Income,0) as ColumnName from dbo.TestDivideByZero
Go


Hope this helps!

Tuesday, April 24, 2007

Arithmetic overflow error converting expression to data type int.

Today I was trying to join two table each having approximately 5 Lakhs records in one of my SQL Server 2005 database. I was trying to find the count of some field when this arithmetic overflow error was thrown.
Arithmetic overflow error converting expression to data type int.

I understood that the calculation has exceeded the maximum INT range. For better understand on this error check out this SQL Books online article and/or this KB article.

The work around which did the trick for me is, instead of "Count" I changed it as "Count_big".

Monday, April 23, 2007

Top 20 things programmers say to testers!

I was going through the "Top 20 things Programmers says to Testers!". Its really funny and brought back lot of memories.

Out of the 20, i need to admit I use these excuses very often :)

18. "It worked yesterday!"
12. "You must have a wrong version"
1. "It works on my machine"

The other excuses which I use or heard people using it are:

1. The issue isn't reproducable.
2. It's designed to work that way!
3. You know we have done it as a value add ourself! there is no spec for this.
4. It's been fixed long time back. May be you are looking into a wrong version!
5. You know its not because of our layer! It's an error in the "Service Layer" which another team needs to look at.
6. I don't think its a show stopper. How about fixing it in the next release?

Do you have a say on this?

Sunday, April 22, 2007

A Saturday with Zoho Writer!

Today I thought of trying my luck with Zoho Writer and write my feedback about that. So is this post :)

Just a thought: Actually I am surprised that almost all of zoho's product have different UI's. Won't it look good if they create a uniform look and feel across their products?

Most of the Products have Single Sign On facility:

It's really nice to see that they have done SSO (single sign on) authentication for their products. It means, previously I have registered with Zoho Sheets and now to work with Zoho Writer I can make use of the same login.

How to enable SSO for a zoho product?

1. First login to any of their product (zoho sheet, zoho writer, zoho show, zoho project, zoho creator, zoho planner, zoho wiki and zoho chat). Yes you need to register once in any of their product.

2. In the header of the application you can see "My Account" link. Click on it to see a screenshot as shown below for your account information.




3. Now lets assume that you need to enable SSO for "Zoho Planner". All you need to do is click on "Add New" link besides it. Easy isn't it?

Just a thought: I feel that the text "Add new" is confusing. I initially thought that it would create a new account when its clicked.


Template Library

Refer below the screenshot of the initial screen after login. In the header you can find the link "Template Library".



As of now when this blog post is made there are 51 pre-build templates available which one can use to create their document. There are template like "Resume covering letter", "Different resume template" etc.,

Extract from their site:


This is a place where you can find readymade templates for your use. Whoever you are - job seeker, businessman, accountant, designer, salesman, marketer, home user - you can find a template which you can use to build your document on. And what's more, you can upload your templates here too - if you are an expert in your area of interest and have useful templates to share with others, please feel free to do so.

This feature is really cool and people who have used MS Word templates would appreciate this as well.

Search within Template Library:

I tried searching for keywords "Resume", "sheet" etc., but it didn't work for any of them. It always shows up a screen as shown in the below screenshot. May be a minor glitch which they might already be working on as well which I am not sure.


Mailing Options:


  • Any document, you worked on, can be sent to an Email ID of your choice using the "Email Out" option. We could make use of this option to take a backup of our work :)

  • There is an 'Email In' option which would be really useful. For each user they give an Email Id to which they can send in any documents which would be upload to their zoho writer account.

Most of 'MS Word' shortcut keys work here too:

I tried 'Ctrl+B', 'Ctrl+I', 'Ctrl+U', 'Ctrl+N', 'Ctrl+S' and all of them worked. Wow its really cool. I can create documents online with the same speed I used to do with my MS Word :) Out of all those, 'Ctrl+S' and 'Ctrl+N' only surprised me. The first one is for saving a document while the second one creates a new tab/document.

Source control!!

The best feature which I liked within "Zoho Writer" is maintaining document "History". I assume that each time when we edit the content and save they internally create a version of the document. Anytime we can compare between two versions and if need be we can revert back to an older version as well. This is a real cool feature and I guess "Zoho Writer" team have done their homework really well.



Just a thought: I guess "Show Diff" has some issues. Most of the time nothing happened when I clicked on it. May be the team wants to go through the code base of that functionality once again!

It also has an option to export the document into various format like, "PDF", "RTF", "Text file", "HTML" file etc., Over all the product looks really impressive. The interface is cool and I felt like working in a client based software rather than an online word processor.

That said, I also want to convey that I faced quite a few alignment issues and in few places it threw Javascript errors as well. But those aren't show stoppers and more over it is still in Beta. Hopefully all these minor issues would be fixed before they remove the Beta tag. Btw, if you run into any issues you can file it here.

Don't forget to check out my Awards / Recognition / Achievements document which I created using Zoho Writer :) I plan to update this document when ever I achieve something(!). I would also put it up on the right navigation for easier access.

Related Posts:

1. Interview with Product Manager of Zoho Sheet
2. [Product Review] SwisSQL SQLOne Console 3.0

Technorati tags: , ,
kick it on DotNetKicks.com

Thursday, April 19, 2007

AutoEventWireup




<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="true" Inherits="Sample2003Application.WebForm1" %>



AutoEventWireup -- It's a boolean field. By default in VS.NET 2003 it would be "false". More over this attribute is applicable only for applications which are created via VS.NET 2003.

If it's set to "True", the ASP.NET runtime does not require events to specify event handlers like Page_Load etc.,

Once you create a new webform in VS.NET the 'AutoEventWireup' attribute of that page would be false. Open the code behind file and check out the 'InitializeComponent' it would be something like this:

private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}


Within Page_Load even print a message into the screen.

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("We are in Page Load event.");
}

This message "We are in Page Load event." would be printed on this screen.

Now set the autoeventwireup attribute to "True" and then comment the below line:
this.Load += new System.EventHandler(this.Page_Load);

When the application is run we can still find the message getting printed on the screen. i.e., when it is true VS.NET automatically wires up the event for you.

It would be good to have a look at this article on Event Handling in ASP.NET

Saturday, April 14, 2007

Export data from SQL Server to Excel without using SSIS or DTS

Normally for exporting data from SQL Server to Excel one would use DTS (SQL 2k) or SSIS (SQL Server 2005). For some reason if at all you want to do it via query read on:

Step 1: Execute the code snippet

Exec sp_configure 'show advanced options', 1;
Go
Reconfigure;
Go

Exec sp_configure 'Ad Hoc Distributed Queries', 1;
Go
Reconfigure;
Go

Step 2: Create the excel file and then add the headings in the .xls file. [Important] The heading should be the same as that of the table columns.

Insert into Openrowset ('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=c:\VadivelTesting.xls;' , 'Select * from [ProductInfo$]') Select ProductID, ProductName from dbo.tblProducts

Points which might interest you:

1. As long as the file is within your C: drive this sample would work. If at all your database is in a different machine from that .xls file you need to change Database=c:\VadivelTesting.xls; to UNC path. For example, Database=\\Servername\shareName (And need to provide appropriate permission).

2. Instead of "ProductInfo" replace it with your excel worksheet name.

Sunday, April 01, 2007

ToonDoo from Jambav ... 2

I came to know about ToonDoo from D. Rajendran (who is a Product Manager in Jambav) and I am glad he introduced this to me. I created couple of toons and have blogged about it here. I really liked this toonDoo concept and i am playing with it for past 2 days like a kid :)

Actually I wanted to write about "Jambav" in June '06 itself. But as I was bit busy couldn't do that (believe me i was busy only lol). Now somebody has beaten me and has interviewed "Rajendran Dandapani" about him and Jambav. He has spoken about "What is Jambav and why that name?", "about the motivation to start Jambav", "About him and his responsibilities", "Key technologies used", "their business model" etc., I strongly recommend everybody to go through it without fail.

That said, there are few things which I am not sure about this tool ...

1. How much load can their server take? Because very often I find that the server is down (more than thrice last night). {My internet connection had no issues :) as other sites were working fine}.

2. I don't see a FAQ section? I actually wanted to know "how a toon is choosen to be listed under Editor's Pick", "How to change my password?", "What is the Dooers section in the home page?", "How to delete a toon?" etc.,

3. After publishing one of my toon, I edited it twice and when I republished the alignment of the pictures and text went for a toss. All I did was to republish it few more times to solve it :)

4. I tried pasting "Flash based scroller" into my blogger account but it throwed an error saying "Error Loading... Sorry! www.toondoon.com". May be it doesn't work with Blogger?

5. From their "About Us" section I understand that "Jambav is devoted to creating a unique array of free and customizable online games of educational value for children of all abilities". They say its for kids but they allow "Adult" category to be created! {I saw toons tagged to adult, blowjob!!!, sex etc.,}. Am I missing something?

Technorati tags: , ,

ToonDoo from Jambav ...

Jambav (backed by Adventnet) has launched another cool tool few days back by name "ToonDoo" (Cartoon Strip Creator).

You can check my really exciting works below :)

Sivaji
[Updated the copy: As usual there were lots of typo in my Indian Cricket toon which I have changed it now].
Indian Cricket

BTW, at present there is a contest at ToonDoo. Create any number of toon and show the world what you are thinkinng abt it. What are you waiting for? Go get registered and start playing with it.

Techcrunch has a good write up on ToonDoo here

Technorati tags: , , ,