April 22, 2005

Images from SQL Server database in ASP.NET DataGrid

Here it goes...

Create a Table in SQL DB as follows
Images ( imgid int IDENTITY (1, 1) NOT NULL , imgdata image NULL)

Create a asp.net web page with DataGrid and databound with this table results
(make image as template column) add a img tag with this url "imagedatapipe.aspx?id=" Binder... (ID) in page load of this imagedatapipe page..

con.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
dr.Read()
Dim bindata() As Byte = dr.GetValue(1)
Response.BinaryWrite(bindata)

(MAKE SURE imagedatapipe PAGE IS BLANK AND DOES NOT CONTAIN ANY DATA -
optionaly u can clear response stream and Dont forget to add few data in table :)

SqlWhereBuilder ASP.NET Server Control

A user interface web control for building conditions suitable for use in a SQL statement.

Spell CHecker

SpellCheckers?? i guess everybody have used this handy tool in Word but what if if you can use such a tool in web development, and even using Web Services?? Just check it out this link and enjoy SpellCheck.

April 21, 2005

Top 10 Ranks Google C SHARP

Below are 2 functions in C# to get top 10 ranks from google


------------------------------­-


public static StringCollection SearchGoogleForKeyWord(string sKeyWord)
{
int nCount = 0;
bool bBreak = false;
string sURL ="";


StringCollection strCollection = new StringCollection();


while(true)
{
if(bBreak)
{
break;
}
string url = "http://www.google.com/search?q­=";
url += System.Web.HttpUtility.UrlEnco­de(sKeyWord);
url+= "&hl=en&lr=&ie=UTF-8&start=";


url += (nCount*10).ToString();


url += "&sa=N";
string sPage = GetPage(url);
nCount++;
if(sPage == null)
{
continue;
}
sURL ="";
bBreak = ExtractHrefFromSearchPages(sPa­ge , strCollection,ref sURL);
}
return strCollection;
}


public static bool ExtractHrefFromSearchPages(str­ing str,
StringCollection strCollection, ref string sURL )
{
Regex r;
Match m;
r = new Regex("href\\s*=\\s*(?:\"(?<1>­[^\"]*)\"|(?<1>\\S+))",
RegexOptions.IgnoreCase|RegexO­ptions.Compiled);
for (m = r.Match(str); m.Success; m = m.NextMatch())
{
if(!strCollection.Contains(m.G­roups[1].Value))
{
string sFound = m.Groups[1].Value;


if(sFound.IndexOf("&filter=0") >= 0)
{
break;
}


if(sFound.IndexOf("oi=news") >= 0)
{
continue;
}


if(sFound.IndexOf("google.com"­) >= 0)
{
continue;
}
if(sFound.IndexOf("&spell=1") >= 0)
{
continue;
}
if(sFound.IndexOf("&q=+site") >= 0)
{
continue;
}
if(sFound.IndexOf("/search") >= 0)
{
continue;
}
if(sFound.IndexOf("www.googleadservices.com") >= 0)
{
continue;
}
if(sFound.IndexOf("dictionary.­reference.com")>= 0)
{
continue;
}
if(sFound.IndexOf("language_to­ols") >= 0)
{
continue;
}
if(sFound.IndexOf("/swr?q=") >= 0)
{
continue;
}
if(sFound.IndexOf("/help/") >= 0)
{
continue;
}
if(sFound.IndexOf("search?q=ca­che") >= 0)
{
continue;
}
if(sFound.IndexOf("q=related:"­) >= 0)
{
continue;
}
if(sFound.IndexOf("/advanced_s­earch?q=") >= 0)
{
continue;
}
if(sFound.IndexOf("/preference­s?q=") >= 0)
{
continue;
}
if(sFound.IndexOf("/quality_fo­rm?q=") >= 0)
{
continue;
}
if(sFound.IndexOf("/ads/") >= 0)
{
continue;
}
if(sFound.IndexOf("/services/"­) >= 0)
{
continue;
}
if(sFound.IndexOf("/about.html­") >= 0)
{
continue;
}
if(sFound == "/options/")
{
continue;
}
if(sFound.IndexOf("/url?q=") >= 0)
{
continue;
}
if(sFound.IndexOf("http://") != 0)
{
continue;
}
int nPos = -1;
nPos = sFound.IndexOf(">");
if(nPos != -1)
{
sFound = sFound.Substring(0,nPos).ToLow­er();
}
strCollection.Add(sFound);
}
}
return true;
}

Calling ASP.net Web Service from Javascript

As everybody know JavaScript is best thing that we can have at client side, but what if if we can have access to Web Services throught JavaScript... it's like cracking the world through a small tool. Just check it out...

How to Share Session State Between Classic ASP and ASP.NET

URL

http://www.msdn.microsoft.com/­library/default.asp?url=/libra­ry/en-us/...


CODE URL
http://download.microsoft.com/­download/9/8/0/980e634a-f4ba-4­3a0-9d6d-...

.NET Language Sites

This link displays list of langauages supported by .Net. Just have look over the link

What Happens When U Search Google

I guess google is not a new word for you, but do you know what all happens when you google(search) something at google.com

I found a pic which describes best. Just check it out bellow.

The Year 2038 Problem- Y2K problem again? ...Interesting one

What is it?

Starting at GMT 03:14:07, Tuesday, January 19, 2038, It is expected to see lots of systems around the world breaking magnificently: satellites falling out of orbit, massive power outages (like the 2003 North American blackout), hospital life support system failures, phone system interruptions, banking errors, etc. One second after this critical second, many of these systems will have wildly inaccurate date settings, producing all kinds of unpredictable consequences. In short, many of the dire predictions for the year 2000 are much more likely to actually occur in the year 2038! Consider the year 2000 just a dry run. In case you think we can sit on this issue for another 30 years before addressing it, consider that reports of temporal echoes of the 2038 problem are already starting to appear in future date calculations for mortgages and vital statistics!

In the first month of the year 2038 C.E. many computers will encounter a date-related bug in their operating systems and/or in the applications they run. This can result in incorrect and wildly inaccurate dates being reported by the operating system and/or applications. The effect of this bug is hard to predict, because many applications are not prepared for the resulting "skip" in reported time - anywhere from 1901 to a "broken record" repeat of the reported time at the second the bug occurs. Also, may make some small adjustment to the actual time the bug expresses itself. This bug to cause serious problems on many platforms, especially Unix and Unix-like platforms, because these systems will "run out of time".

What causes it?

Time_t is a data type used by C and C++ programs to represent dates and times internally. (Windows programmers out there might also recognize it as the basis for the CTime and CTimeSpan classes in MFC.) time_t is actually just an integer, a whole number, that counts the number of seconds since January 1, 1970 at 12:00 AM Greenwich Mean Time. A time_t value of 0 would be 12:00:00 AM (exactly midnight) 1-Jan-1970, a time_t value of 1 would be 12:00:01 AM (one second after midnight) 1-Jan-1970, etc..

some example times and their exact time_t representations:

Date & time
time_t representation

1-Jan-1970, 12:00:00 AM GMT
0

1-Jan-1970, 12:01:00 AM GMT
60

1-Jan-1970, 01:00:00 AM GMT
3 600

2-Jan-1970, 12:00:00 AM GMT
86 400

1-Jan-1971, 12:00:00 AM GMT
31 536 000

1-Jan-1972, 12:00:00 AM GMT
63 072 000

1-Jan-2038, 12:00:00 AM GMT
2 145 916 800

19-Jan-2038, 03:14:07 AM GMT
2 147 483 647


By the year 2038, the time_t representation for the current time will be over 2 140 000 000. And that's the problem. A modern 32-bit computer stores a "signed integer" data type, such as time_t, in 32 bits. The first of these bits is used for the positive/negative sign of the integer, while the remaining 31 bits are used to store the number itself. The highest number these 31 data bits can store works out to exactly 2 147 483 647. A time_t value of this exact number, 2 147 483 647, represents January 19, 2038, at 7 seconds past 3:14 AM Greenwich Mean Time. So, at 3:14:07 AM GMT on that fateful day, every time_t used in a 32-bit C or C++ program will reach its upper limit.

One second later, on 19-January-2038 at 3:14:08 AM GMT, disaster strikes.

When a signed integer reaches its maximum value and then gets incremented, it wraps around to its lowest possible negative value. This means a 32-bit signed integer, such as a time_t, set to its maximum value of 2 147 483 647 and then incremented by 1, will become -2 147 483 648. Note that "-" sign at the beginning of this large number. A time_t value of -2 147 483 648 would represent December 13, 1901 at 8:45:52 PM GMT.

So, if all goes normally, 19-January-2038 will suddenly become 13-December-1901 in every time_t across the globe, and every date calculation based on this figure will go haywire. And it gets worse. Most of the support functions that use the time_t data type cannot handle negative time_t values at all. They simply fail and return an error code.

A quick check with the following Perl script may help determine if your computers will have problems (this requires Perl to be installed on your system, of course):

#!/usr/bin/perl
# Use POSIX (Portable Operating System Interface)
use POSIX;
# Set the Time Zone to GMT (Greenwich Mean Time) for date calculations.
$ENV{'TZ'} = "GMT";
# Count up in seconds of Epoch time just before and after the critical event.

for ($clock = 2147483641; $clock < 2147483651; $clock++)
{
print ctime($clock);
}

For example, the output of this script on Debian GNU/Linux (kernel 2.4.22) (An affected system) will be

# ./2038.pl
Tue Jan 19 03:14:01 2038
Tue Jan 19 03:14:02 2038
Tue Jan 19 03:14:03 2038
Tue Jan 19 03:14:04 2038
Tue Jan 19 03:14:05 2038
Tue Jan 19 03:14:06 2038
Tue Jan 19 03:14:07 2038
Fri Dec 13 20:45:52 1901
Fri Dec 13 20:45:52 1901
Fri Dec 13 20:45:52 1901



Solution

"The best way to predict the future is to engineer it." Consider testing your mission-critical code well ahead of time on a non-production test platform set just before the critical date. For more general applications, just using large types for storing dates will do the trick in most cases. For example, in GNU C, 64-bits (a "long " type) is sufficient to keep the time from rolling over for literally geological eons This just means any executables the operating systems runs will always get the correct time reported to them when queried in the correct manner. It doesn't stop the executables you may still want to be worried about

Well-written programs can simply be recompiled with a new version of the library that uses, for example, 8-byte values for the storage format. This is possible because the library encapsulates the whole time activity with its own time types and functions (unlike most mainframe programs, which did not standardize their date formats or calculations). So the Year 2038 problem should not be nearly as hard to fix as the Y2K problem was.

Admittedly, some don't feel that this impending disaster will strike too many people. They reason that, by the time 2038 rolls around, most programs will be running on 64-bit or even 128-bit computers. In a 64-bit program, a time_t could represent any date and time in the future out to 292 000 000 000 A.D., which is about 20 times the currently estimated age of the universe. The problem with this kind of optimism is the same root problem behind most of the Year 2000 concerns that plagued the software industry in previous years: Legacy Code. Even if every PC in the year 2038 has a 64-bit CPU, there will be a lot of older 32-bit programs running on them

The greatest danger with the Year 2038 Problem is its invisibility. The more-famous Year 2000 is a big, round number; it only takes a few seconds of thought, even for a computer-illiterate person, to imagine what might happen when 1999 turns into 2000. But January 19, 2038 is not nearly as obvious. Software companies will probably not think of trying out a Year 2038 scenario before doomsday strikes. Of course, there will be some warning ahead of time. Scheduling software, billing programs, personal reminder calendars, and other such pieces of code that set dates in the near future will fail as soon as one of their target dates exceeds 19-Jan-2038, assuming a time_t is used to store them.

Good luck, and hope no ones flying car breaks down in 2038

April 20, 2005

Microsoft Campus Tour

No word i have for such a link. It's been great exp to have a look of Microsoft Campus. Thanks to Sudhakar who shared such a link to me.

10 tips for better E-mails

E-mail is an extremely valuable communication channel for today's managers, but it can be abused if used carelessly or too much, Owens says. Here are 10 basic tips for better e-mail use and management.

1. Use e-mail as one channel of communication, but not your only one. It's fast and easy. It can document discussions. It enables high-impact messages to be sent around the world with the click of a mouse. But it also misleads bosses into thinking they can manage large groups of people through regular group e-mails, Owens says. Use e-mail wisely, but don't manage your company through it. You won't reach everybody you need to reach and your presence won't be felt.

2. Keep it short and sweet and don't allow e-mail threads longer than a football field. Know that e-mails longer than one screen-full often aren't read right away; they get shoved to the end of the day or the next morning. Know also when it's time to put down the mouse and go talk to someone, or pick up the phone. There comes a point when further e-mailing eats up time unnecessarily.

3. De-code your messages as much as possible. Say what you really want to have happen. Start with the subject line: Make it clear and compelling (and be willing to change it when the subject in a thread changes). Be certain about who really needs to be on the "to:" and the "cc:" line. Be clear about action items and priorities. Spell them out, as lists or bulleted items. Include a response button or some other mechanism if you must know that everyone has read and understood your message.

4. Encourage people to respond with questions. That's akin to keeping your office door open.

5. Save your wrath for face-to-face meetings. "Flame mails," or e-mails dripping with criticism or venom, often backfire. Terse e-mails, because they are not accompanied by the writer's facial expression or body language, can easily come across more harsh than intended. You control the message -- and the emotions on the other end -- much better by delivering it in person or over the phone.

6. Likewise, inject humor, but keep emoticons, smiley faces and joke mails to a minimum. The smiley faces do help clarify when you are being facetious. But too many facetious mails will erode at your attempts to write serious ones. What about joke e-mails? Some companies forbid them. Send them or pass them on at your own risk, Owens says. There is usually more downside than upside, but everybody needs a good laugh now and then. Again, too many joke mails will erode your attempts to send serious ones.

7. Consider setting a 5-minute buffer between when you send and when it goes out. Both Owens and Maureen Dolan Rosen, a human resources consultant, see value in managers being able to retract poorly written messages before they even go out. "A 5-minute rule won't hurt anyone," Owens says. In Microsoft Outlook, you can delay the delivery of messages for a specified time through the "Rules Wizard." If you're angry when you're about to write, take a step further. Get up and walk around or do something else before you write the mail.

8. Work in time each day to answer your e-mails, or get help. If you can't keep up during a normal day, build time into your work day or delegate some of the responsibility. When is it too late to respond to someone? Never. Just make sure you have a good explanation.

9. If you can't write e-mails effectively, get some training. Or at least get help from a secretary or subordinate. E-mail should have some role in your communication with employees, partners and others -- there is really no valid reason to avoid it. But know that any remote workers and others who don't see you regularly may judge you largely on your e-mails.

10. Use spell-check -- and a thesaurus. Avoid typos and mangled sentences. They make you look bad. Avoid clichés, too.

Ctrl-Alt-Delete

Have you ever wondered who has invented the "CTRL +ALT + DEL " key combination?
David Bradley

He is the one who spent 1 minute and 23 seconds writing the source code that has rescued and will cointinue to rescue PC users worldwide for decades.

This extraordinary IBM employee retired on Friday, January 14, 2005; after a prolonged service of 29 years.

His formula forces obstinate computers to restart when they no longer follow other commands. By 1980, Bradley was one of 12 people working on the debut.

The engineers knew they had to design a simple way to restart the computer whenever it fails to respond to the user. Bradley wrote the code to make it work.

Bradley says -
"I did a lot of other things than Ctrl-Alt-Delete, but I'm famous for that one."

His fame and success is achieved each time a PC user fails.

He commented on his relationship with Bill gates by saying, "I may have invented it, but Bill gates made it famous by applying my formula when ever any Microsoft's Windows operating system made by him CRASHES, thus I win when ever BILL GATES loses."

Soap Services

There is a new SOAP in market, just try it out... :) that might make your life colourfull.

What Great .NET Developers Ought To Know (More .NET Interview Questions)

Do you think you are prepared enough with .Net, for interview... Think it again... This link contains all the ques, which might be there in your interview.. just check it out.

ERWin Help

Hi all,

In TCS i got chance to work on ERWin, it's worth tool to work on, It's tool for Data Modeling. Have option of Reverse engineering - Forward engineering and several Reporting options.. Really it was cool time to work on ERWin.

10 Things You Shouldn't Do with SQL Server

This article consist some common errors/issues, which we might be doing when dealing with SQL Server.