Tuesday, March 31, 2009

Bike to work statistics March

Bike to work: 12 days.
Total workdays: 21 days
Bike commute percentage: 57%
Total distance ride: 8.55 * 2 * 12 = 205.2 KM
Total Calories burned in riding: 342 * 12 = 4104

According to the calories I burned, I should have lost 456 g fat. Adding the 570 fat I should have burned(calculated) in Feb, I should be 1.026 KG lighter than I was in January.
But……… I actually gained ~ 1 pound in these 2 months.

Record my BMI here: 21.64

Monday, March 23, 2009

Have you been to Visual Studio?

I was talking with a friend about my trip to L.A.
"Where did you visit?" She asked.
"Disneyland and Visual Studio" I answered without hesitation.

Thursday, March 19, 2009

Lost in translation

There is some MSN robots, I got one for translation.
I gave it an email in English, then it tanslated into Chinese. Then I let it translate the Chinese paragraph back to English, then back to Chinese. After a few round, the meaning is totally changed.
-----------------------
1) I worked on TD 40496 and I just wanted to thank you for the notes you had left in TD. That was very helpful and if that wasn’t in the TD, it would have taken me a lot of time to figure out the problem.
2)我的TD 40496和我只是想感谢你注意到你已离开在TD 。这是非常有益的,如果不是在TD ,它会对我采取了大量的时间找出问题。
3)My TD 40496 and I just want to thank you notes you have left at TD. This is very beneficial, if not in the TD, it would have taken me a great deal of time to identify the problems.
4)我国的TD 40496和我只是想感谢你注意到你已经离开运输署。这是非常有益的,如果不是在TD ,它会对我采取了大量的时间来确定的问题。
5)China's TD 40496 and I just want to thank you notes you have left the department. This is very beneficial, if not in the TD, it would have taken me a great deal of time to determine the problem.
6)中国的TD 40496和我只是想感谢你注意到你已经离开了新闻部。这是非常有益的,如果不是在TD ,它会对我采取了大量的时间来确定这个问题。
7)Chinese TD 40496 and I just want to thank you notes you have left the Department of Public Information. This is very beneficial, if not in the TD, it would have taken me a great deal of time to determine the problem.

Wednesday, March 18, 2009

【爆笑】 才气纵横的英文翻译,你绝对想不到






“TO THROW TO THROW”= 抛扔 ── 中华文化博大精深,抛和扔是不一样滴......


进站口 = JIN MOUTH?开开开开开开什么玩笑.......






中国海事,拼音大王!


“芬达”是 “THE FRAGRANCE REACHES”…… 吓人啊! “小可乐”是“SMALL MAY BE HAPPY”,那“可口可乐”是不是“MAY BE MOUTH MAY BE HAPPY?” 搞不懂“小雪碧”是这样译的?看来你对中国文化了解的还不够深,原来“20TH SOLAR TERM”是二十四节气中的“小雪”,加上“BLUE”,就是小雪碧了……


这个 369 翻译的......你成心让外宾看不明白的吧!












Tuesday, March 3, 2009

Be careful with ExecuteScalar() and ExecuteReader()

If you use ExecuteScalar() to get a value from a sql command, and updates some records in the same command. (For example, generate a new ID, return the new ID and create the record for this ID). You should always put the select value sentence in the end of the transaction. Otherwise you may get surprised that you can still get the new ID with no exception when actually the record is not created!
There are 2 simplified examples. Believe me, they won’t throw.

Example 1:
string sql = @"select 123
RAISERROR('error msg', 16, 1)";
command.ExecuteScalar(context.MetaDBConnectionString, CommandType.Text, sql);

Example 2:
string sql = @" SET XACT_ABORT ON
select 123
BEGIN TRAN
RAISERROR('error msg', 16, 1)
COMMIT TRAN";
command.ExecuteScalar(context.MetaDBConnectionString, CommandType.Text, sql);

If you change to use ExecuteReader(), there won’t be any exceptions either. But the same sql throws if you use ExecuteNonQuery() or ExecuteDataset().
For ExecuteScalar()/ExecuteReader(), SqlException only throws if you move RAISERROR before the select sentence.

I found some explaination from Internet for this behavior:

> ExecuteReader

Since your proc raises the error after the first result set is returned, you
need to invoke the SqlDataReader.NextResult method before the error is
thrown:

SqlDataReader dr = command.ExecuteReader();
while (dr.Read());
while(dr.NextResult());

> and ExecuteScalar?

ExecuteScalar returns only the first column of the first result set so the
exception is not raised in the app code. If you need the exception raised,
consider using ExecuteReader with NextResult instead. ExecuteScalar is
basically just a convenience method that wraps ExecuteReader and retrieves
only the first result set.