2008年3月26日

[SQL2005][SSIS]DTS_E_OLEDBERROR when executing SSIS package

When executing SSIS package imports data from Excel file into SQL 2005 Database
I get the following error

Error 0xc0202009: Data Flow Task: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E21.
An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80040E21  Description: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.".
(SQL Server Import and Export Wizard)
Error 0xc0202025: Data Flow Task: Cannot create an OLE DB accessor. Verify that the column metadata is valid.
(SQL Server Import and Export Wizard)
Error 0xc004701a: Data Flow Task: component "Destination - Employee" (205) failed the pre-execute phase and returned error code 0xC0202025.
(SQL Server Import and Export Wizard)

SQL 2005 checks data type before actually imports data from source to destination
For example, an Access column with MEMO data type is limit to 65536 bytes, which is greater than a SQL nvarchar's limitation.
This generates a DTS_E_OLEDBERROR when executing SSIS package.


To fix this behavior, map destination data column to a different data type, or increase its length(for example, nvarchar(50) to nvarchar(max))

2008年3月19日

[IIS] When browse IIS 6.0 web site using FQDN, a HTTP 401.1 or 401.3 error occurs

When browsing an IIS web site using IP address, everything looks fine, But when using FQDN or Computer Name, you keep getting HTTP 401.1 or 401.3

You might encounter this kind of errors if you have the following environment

  • IIS is running under an specificed Application Pool
  • The Application Pool is using a domain user account or under a local user account
  • The web site is configured using Integrated Windows Authentication only

When this error occurs, a Kerberos error entry will be logged under System Event with Event ID 4.

Resolution:

  1. If the application pool is running under a Domain Account
    1. Download SetSpn utility from here
    2. Install setspn utility
    3. Open command prompt and execute the following commands

      setspn.exe -a http/IIS_computer's_NetBIOS_name DomainName\UserName
      setspn.exe -a http/IIS_computer's_FQDN DomainName\UserName

      Domain\UserName is the user account your Application Pool is running under.

  2. If the application pool is running under a Local Account
    1. Open command prompt
    2. Locate and change directory to where Absutil.vbs located, by default, should be C:\Inetpub\AdminScripts
    3. Execute the following command

      cscript adsutil.vbs set w3svc/NTAuthenticationProviders "NTLM"

Reference:

David Wang's Blog : Explain HTTP 401.X errors

Microsoft Support : How to resolve HTTP 401.1

2008年3月17日

[Reading Notes]Reading Notes for [C# 3.0 Packet Reference] - 1

  1. Lamba Expressions
    1. Outer variables(Captured variables)

    2. Lamba Expression can reference local variables and paramaters of the method in which it is defined. In the following example, factor is called outer variable(captured variables).
      void Foo(){
      int factor = 2;
      Func<int, int> multiplier = n => n * factor;
      }
    3. A captured variable is evaluated when the Lamba expression is invoked, not evaluated when it's been captured.
    4. A captured variable's lifetime is extended to that of delegate captrues it.
      FuncFoo(){ int i = 0; return ()=>i++;}
      static void Main(){
      Func foo = Foo();
      Console.WriteLine(foo());//0
      Console.WriteLine(foo());//1
      }
  2. Anonymous Methods
    1. Sample:
      delegate int AnonymousFunc(int i);
      AnonymousFunc = (int x) => {return x*x;};
    2. Anonymous methods captures variables like Lamba Expressions do.
  3. Extension Methods
    1. Extension methods extend existing types with new methods, without altering original type.
    2. Syntax:
      public static class StringExtensions{
      public static bool IsNullOrEmpty(this String s){
      return (s == null s.CompareTo(String.Empty) == 0);
      }...}
    3. A compatible instance method always take precedence over an extended version.
      class Test{
      void Foo(object a){...} //this method always take precedence
      }
      static class Extensions{
      void Foo(this Test t,int x){...}
      }
  4. Anonymous Types
    1. A simple class created on the fly
    2. Syntax:
      var person = new {Name="Michael",Age=32,Class="Programmer"};
      int age = 32;
      var person2 = new {Name="Michael",Age = age; Class="Programmer"};
    3. Anonymous Types are used primarily when writing LINQ

    [VS2008]"Requested Registry Access not allowed" Error when create new project in VS2008/Vista

    When create new project in VS2008 on Vista
    A [Requested Registry Access Not Allowed] Error message was shown

    This message was shown due to some ACL problem on the registry keys VS2008 requires
    To fix the problem

    1. Download SubInAcl.exe from Microsoft Download site here
    2. Install SubInAcl, it will be placed in C:\program files\windows resource kit\tools by default.
    3. Create a batch file with the following commands

      subinacl /subkeyreg HKEY_CLASSES_ROOT\VisualStudio.vbproj.9.0 /grant=administrators=f
      subinacl /subkeyreg HKEY_CLASSES_ROOT\VisualStudio.vbproj.9.0 /grant=users=f
      subinacl /subkeyreg HKEY_CLASSES_ROOT\VisualStudio.vbproj.9.0 /grant=system=f
      subinacl /subkeyreg HKEY_CLASSES_ROOT\VisualStudio.csproj.9.0 /grant=administrators=f
      subinacl /subkeyreg HKEY_CLASSES_ROOT\VisualStudio.csproj.9.0 /grant=users=f
      subinacl /subkeyreg HKEY_CLASSES_ROOT\VisualStudio.csproj.9.0 /grant=system=f

    4. Save and execute the batch file.

    2008年3月6日

    [IIS][.Net]Execute .Net assembly in a shared location from IIS

    Here's the environment:

    Web Server A and B(Win server 2003/IIS6)

    On ServerA I have a folder,say ShareFolder. I set up a WebSite with ShareFolder as its home directory.

    On ServerB I create a website with its home directory points to ShareFolder

    When brows to http://ServerB/website , An error message was shown:

    Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

    The execution is block by .Net framework Code Access Security, to solove this problem, follow the instruction of Microsoft Arcitle ID 320268.

    To execute .Net assembly on remote machine, .Net has to trust codes from that machine, so we have to grant permission to codes come from remote server.

    [Reading Notes]Reading notes for [Programming C# 3.0, 5th Edition] - 1

    Structures

    • Structure is a lightweight alternative to class
    • Structure is of Value type(Which means it requires boxing/unboxing when transform value type to reference type and is created in the stack rather then the heap)
    • Not fully supports inheritance(can inherts only from an object and is implictily sealed)
    • Can not have default constructor nor destructor
    • From [From Java to C#:A developer's Guide] Charapter 26.3,You should choose to use a struct rather than a class for performance reasons. If you are writing a class that:
      • represents a small data structure with few data members, and

      • does not require the use of inheritance, and

      • it is convenient for it to be a value type instead of a reference type

    • Being a value type, an assignment results whole struct's value to be copied over, this might cause performance issues.

    1. Serializable & MarshelByRefObj
      1. A object marked as [Serializable] is passed by value.
      2. A object inherits from MarshelByRefObj is passed by reference, which means, when deserializing, client gets a proxy rather then an object.
    2. LINQ to SQL - About Data Corruption
    • [Chapter 15.2, LINQ to SQL Fundamentals]...LINQ ensures that multiple retrievals of a database record are represented by the same object instance; this makes it much harder for the aforementioned scenario to occur......" that would be reflected in Joe's representation of the object—they are looking at the same data, not at independent snapshots...
      • What if they are accessing the data from different process (can't be same object if LINQ does not provide an independent mempry storage) ? is the above stetments still sustain ? Require further tests.

    [BizTalk][RosettaNet]A4RN configuration on clustered servers

    While configuring A4RN 3.3 on BizTalk Server 2006, I got an error message
    "A Biztalk Isolated host instance configured with the user account '' was either not running or dose not exist...''

    Some may experience this kind of error with a specificed user account like '\btssvc', in this case, simply reconfig or recreated a trusted host instance with domain-name\btssvc as its security account.

    In my case, no account id was specificed in error message, I tried uninstall A4RN 3.3 then reinstall it but the problem stills.
    So I start guessing that maybe it's caused by cluster service, so I create a new trusted host instance on both BTS server(but not cluster these host instances!), and restart A4RN configuration wizard.

    And the error goes away...

    I guess the reason I got this error is that A4RN requires hosts marked as trusted, when configuring A4RN, config wizard seeks for trusted host instance and retrieve trusted user account to perform further configuration, since all trusted host instances are clustered and are handled by cluster service and may not currently running on that machine, config wizard is not able to have that trusted account id.

    After configuration, simply re-cluster newly created hosts or just delete them!

    [IIS]IIS Website with a virtual directory from shared folder

    We have 2 web servers with NLB by L4, 2 clustered file servers, all servers in same domain
    We created a web site(say test_web) on WEBSERVER_1, and on that website, I created a virtual directory redirect to shared folder on file server
    test_web's application pool uses domain\administrator(to ensure there are no other strange permission issues) as its identity, also, the web site allows only users authenticated by Windows Operation System.
    In testeb's web.config, set impersonate to true
    On file servr, shared folder permits Domain\Users with [Full Control] permission on NTFS and Share security(to ensure no other permission issues)

    My problem is
    I can only access to that folder when I browse to test_web by IE on web server, if I browse to test_web from my own notebook, access to that folder was denied.

    well, still don't know how to solve it and why the hell this happen...

    [SQL 2005]Xml data type in SQL 2005

    SQL 2005 insists your xml data to be UTF-16 encoded, if your data is not UTF-16 encoded, when inserting, a [Unable to Switch to current encoding] exception will be thrown.

    [Cluster]How to make your window service a clustered service ?

    You don't have to implement specific interfaces to make your service cluster-aware, but you have to:

    1. Deploy your service to all cluster node
    2. In cluster admin console, create a new Generice Service cluster resource under your cluster group
    3. Check [Use network name] to allow service to impersonate the virtual server
    4. Add all required dependencies

    The service itself must:

    1. Its start type must set to [Manual] so the SCM can wake up your service
    2. The service code must be written "cluster aware". Which means, keep in mind that you should not hard-code any resources related to the node your service is running under.
    3. Use virtual resources, in other word, you have to make sure every resources used by your service should be available in every moment
    4. Pay attention to multithread environment
    5. Uncheck [Affect the group] if your are not sure of service's performance, thus the cluster manager won't swith all resource once your service failed.

    Cluster and Remoting

    Some articles states that binds each channel to a specific ip address by using <bindTo> attribute in application's config file will make it easier to use remoting in a cluster environment. I setup a A-P mode clustered remoting hosts, and find it seem works fine even if I do not set the <bindTo> attribute. I'll keep an eye on this.

    Blog Archive

    About Me