Friday, May 4, 2012

ios project example

ios小项目——新浪微博客户端总结

Wednesday, May 2, 2012

Use TOP and DISTINCT together in t-sql

Surprisingly it is difficult to use TOP and DISTINCT together in SQL. This will not work: select top 2 distinct t.ID as tID, t.Name as tName from Table1 order by tID It can be replaced by something like this to work: select top 2 * from (select distinct t.ID as tID, t.Name as tName from Table1 t) y order by tID Also see some other web links, such as Here

Friday, April 20, 2012

Wednesday, April 18, 2012

Debugging experience

Debugging is a hard thing. Here records some of my experiences.

- A same program instance is running on many machines for years without problem. But today one single machine reports an error. A stored procedure that takes multiple parameters, is now getting those parameters in reverse order.
Reason: A query that returns the list of parameters is now returning the entries in reverse. MSSQL returns data set in undeterministic order if "order by" is not used. It has worked consistently for years on all the machines, now for unknown reason is functioning differently on one single machine.
Solution: Add "order by" clause to the query.

- The Database server in production was accidentally uninstalled ... This happened because the admin logged into the wrong server. As the solution, the desktop background is changed to reflect the server name.

"Same Domain Policy" limitation of jQuery

The same domain policy prevents javascripts hosted on one domain from accessing data from a remote domain. This is for security purpose. So when use jQuery, you can not directly access a web service from a remote server.

The solution is to create a serverside script (for example, in php, as shown below) on your domain, which will serve as a proxy, get the data from the remote domain, and then output it. For example:

<?php
readfile('http://remote_server.com/service?param=' . urlencode($_GET['param']);
?>

[1] Getting data from remote URL using jquery
[2] Cross-domain requests with jQuery

Blog Archive

Followers