Wednesday, March 13, 2013

Goodbye, Google Reader

One of my favorite Google tools - Google Reader will be closed soon. Google Note was gone. Now comes powering down Google Reader. I have to find another tool to keep track of wonderful IT news...

Wednesday, August 22, 2012

Token-based server access validation failed with an infrastructure error.

Recently I went in a newly built MS SQL Server 2008 R2 instance on Windows Server 2008 R2 server, I got login failure when trying to connect to SQL Server instance through SQL Server Management Studio (SSMS) using windows authentication. And I have added my account as SA in the SQL instance. I checked the error message detail. It was:

Error: 18456, Severity: 14, State: 11.

Login failed for user 'Domain\myuser'. Reason: Token-based server access validation failed with an infrastructure error.

This is the first time I got this error since I didn’t run any SQL server on Windows Server 2008 R2 before. After a little bit research, it was caused by UAC (User Access Control). I ran SSMS with option “Run as Administrator”. And I was able to login to SQL Server successfully. Here is a blog post explaining very clear about it.

Wednesday, August 15, 2012

How to enable new resolutions on Lenovo S10-3t

The best resolution for S10-3t is 1024x600. But actually it can support better resolution than that. Here is the trick to edit the registry to get new screen resolutions:

  • Run "regedit.exe"
  • Go to 
    • HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\
      Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\0000
    • Find "Display1_DownScalingSupported" and open it.
    • Change the value to 1
    • Close the registry and restart your system.

Monday, August 13, 2012

A best explanation of REST

Recently found a blog post has a clear explanation of REST protocol “Clarifying REST”.

Friday, August 10, 2012

Mobile’s three kingdoms story…

iOS: New versions are coming out every month. I have to upgrade again…

Android: New version is out. But when can I get the upgrade…

Windows Phone: New version is finally coming. But why can’t I get the upgrade…

Wednesday, August 08, 2012

Wednesday, August 01, 2012

How to drop a database with publication

I got a database on a log shipping subscriber server which I want to drop it. But the publisher database has some active publications. SQL Server doesn't allow you to drop it directly because it thinks it has replications going on. So the way to drop it is putting the database into Offline mode first. Then you should be able to drop it. (NOTE: PLEASE ALWAYS MAKE SURE YOU HAVE A BACKUP BEFORE DROPPING ANY DATABASE!!!)

ALTER DATABASE MyDB SET OFFLINE;


Thursday, July 26, 2012

Call SOAP Web Service With Basic Authorization

Recently I have to call a SOAP Web Service with basic authorization in .Net program. But there is not a simple way to configure the Service Proxy to send the authorization header in HTTP package. I did a little bit search on Internet. Found this solution. Basically, it is adding the header info when initiating the call to web service. It needs an “Authorization” header which is added to the HTTP call which contains the base64 encoded user name and password like this:

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Following are the sample code from this post.

Firstly a method to encode the credentials:

private string EncodeBasicAuthenticationCredentials(string username, string password)
{
  //first concatenate the user name and password, separated with :
  string credentials = username + ":" + password;

  //Http uses ascii character encoding, WP7 doesn’t include
  // support for ascii encoding but it is easy enough to convert
  // since the first 128 characters of unicode are equivalent to ascii.
  // Any characters over 128 can’t be expressed in ascii so are replaced
  // by ?
  var asciiCredentials = (from c in credentials
                     select c <= 0x7f ? (byte)c : (byte)'?').ToArray();

  //finally Base64 encode the result
  return Convert.ToBase64String(asciiCredentials);
} 

Now that we have a means of encoding our credentials we just need to add them to the headers of our WCF request.  We can easily do this by wrapping the call in an OperationContextScope:

var credentials = EncodeBasicAuthenticationCredentials("username", "password");

using (OperationContextScope scope =
          new OperationContextScope(service.InnerChannel))
{
  HttpRequestMessageProperty request = new HttpRequestMessageProperty();
  request.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " + credentials;

  OperationContext.Current.OutgoingMessageProperties.Add(
                                     HttpRequestMessageProperty.Name, request);

  service.DoSomethingAsync();
}

Friday, July 20, 2012

How to make barcode font display correctly in web service

Just got an issue when using barcode font in a web service hosting in IIS7. The barcode font can't display in the document which is generated inside the web service. And the solution to make it work is setting the option "Load User Profile" of IIS 7 application pool to True.

Friday, June 01, 2012

How to check what SQL Server Trace Flags are enabled

If you use some trace flags in SQL Server, and want to find out what trace flags are enabled, just run this:

dbcc tracestatus(-1)

Thursday, May 31, 2012

VS debugger 'magic names'

There is a discussion on StackOverflow about "Where to learn about VS debugger 'magic names'". It is quite useful if you are looking inside the compiler.

http://stackoverflow.com/questions/2508828/where-to-learn-about-vs-debugger-magic-names

Continue to blog...

Almost forgot I have this blog site. I decided to continue to write something again. :)

Monday, June 02, 2008

Using common table expression in SQL 2005

SQL 2005 has a new feature called Common Table Expression (CTE). You don't need to use table variable any more. It is more powerful. You can use it for recursive query, aggregation query etc.

Ex.

WITH tmp_a (col1, col2, col3)
AS
(
SELECT col1, col2, col3 FROM a WHERE a.flag = 1
)

SELECT * FROM tmp_a
WHERE tmp_a.col1 like 'aa%'

Wednesday, April 02, 2008

Monday, March 24, 2008

Running SSIS packages under other Users

There is one place need your very special attention when you try to deploy SSIS package, and let other users run the package. That is "Package Protection Level". By default it chooses "Encrypt sensitive data with user key". That is why you can't run it under the other users' account. Maybe you can try to use "Rely on server storage and roles for access control".

SQL 2005 64bit with Linked Server SQL 2000 Query Issues

We just upgrade our main DB from SQL 2k to SQL 2k5 64bit. But we still need to use linked server to link to another SQL 2k for running some queries. But I get the following error when trying to execute some query:

OLE DB provider "SQLNCLI" for linked server "SQL 2k Server" returned message "Communication link failure".
Msg 10054, Level 16, State 1, Line 0TCP Provider: An existing connection was forcibly closed by the remote host.Msg 18456, Level 14, State 1, Line 0

The solution is: When running a query, SQL 2k5 64bit is trying to invoke the sp_tables_info_rowset_64 store procedure. But this proc is not in SQL 2k server. So one wrapper is needed to put in SQL 2k server to make the query work.

Create Procedure sp_tables_info_rowset_64
@table_name sysname,
@table_schema sysname = null,
@table_type nvarchar(255) = null
as
declare @Result int
set @Result = 0
exec @Result = sp_tables_info_rowset @table_name, @table_schema, @table_type

Sunday, March 23, 2008

Running SSIS package programmatically

Here I found a nice blog post for Running SSIS package programmatically. Sql Server Integration Service is still a little bit confusing. Not just like you can easily run some SSIS packages on remote DB server which most likely every DBA dreaming for that. You need to use SQL Agent or do some programming of Web Service to run it.


Thursday, March 06, 2008

Silverlight Cool...

Yesterday on MIX08, Scott Guthrie announced the Silverlight 2 Beta. Demonstrating their support for Silverlight, customers and partners also took part in the keynote, including AOL, Aston Martin, Cirque du Soleil, DoubleClick, Hard Rock, Move Networks and NBCOlympics.com on MSN. Scott talked about Web, Media, RIA, and Mobile. Those cool demos really impressive. You can't image how good those HD Video, and Rich Inteactive Applications experiences are. AOL demo their Blazing Fast Email client using Silverlight. And the performance is so good, much better than AJAX.

IE 8 beta 1 for Developer

Microsoft announced IE 8 Beta 1 for Developer on MIX 08 yesterday. I download and install it today. I'm really interested in a few features:
  • Activities: No more copy and paste to search, map or blog in another tab or window. Very convenient.
  • Webslice: This is also a cool feature like they demo it using ebay.
  • Developer tools: Very cool and useful.
  • Emulate IE7: If you don't like IE8, you can switch back to IE7 engine.

But when I tried out, still have some problems because it is still in "Beta".

  • Performance: it is too slow on my XP SP2 machine.
  • Most of the website doesn't look good. I try Yahoo, MSN, MSDN etc.

Hope it will be better in next Beta. :)

Wednesday, March 05, 2008

Microsoft Office Live is up

Microsoft is offering their new Office Live Workspace service now for free. The user can upload and share documents as well as access important information from any computer. The user will also be entered into a $100,000 Sweepstakes drawing or win one of 30,000 other prizes just for signing up.

Although it is still in Beta. But looks very nice. Especially more familiar than Google Document for me who works with Microsoft Office everyday.