david 的个人资料David Yardy PE, MCSD.NET...照片日志列表 工具 帮助

日志


2月28日

SQL Server Management Studio - Query Analyzer

This is an issue that is good to put in the memory banks. 
In QA
     exec sproc '{put string in here > 128 characters}'   -- it works fine
     exec sproc "{put string in here > 128 characters}" -- this doesn't work

In the later example above you will get an error similar to maximum length 128 exceeded.  My first thought was the limitation was the parameter length/type.  After further review the problem was that I was exceeding the identifier length.

When double quotes surround an argument the parameter gets interpreted as [identifier] which is limited to 128 characters. 


Other SQL Server 2005 (32-bit) limits

Columns per base table 1024
Columns per SELECT statement 4096
Columns per INSERT statement 1024
Parameters per Stored Procedure/User-Defined function 2100
Rows per Table (limited by file size)
Tables per SELECT statement 256
File size (data) 16 terabytes
Identifier length (in characters) 128

2月23日

Vista and PHP

Yes I as in the position where I was installing PHP on my personal computer.  Don't ask.  Regardless the following were the steps required to setup PHP on Vista platform

  • download PHP from http://www.php.net/downloads.php (I selected PHP 5.2.5 zip file)
  • extract the zip file to your local file system
  • open IIS
    • Under the main settings [at the very top of your IIS Manager's hierarchy view, above Application Pools], add the following in this order: (see below for screen shots)
      • 2.1. an ISAPI Filter for php5isapi.dll
      • 2.2. an ISAPI and CGI Restriction entry for php5isapi.dll
      • 2.3. a Handler Mapping for php5isapi.dll
    • go to application pools
      • right click default application pool and select Advanced Settings
      • set the second option [Enable 32 bit] to True
  • At this point if you browse to your php file you may get a bad gateway error
  • Copy the php-ini-dist file to c:\windows directory
    • rename to php.ini
    • find ;cgi.force_redirect = 1 and change to cgi.force_redirect = 0
    • I also had to change the doc_root value to "."

Within IIS at the root level ISAPI Filters

image

ISAPI and CGI Restrictions

image

Handler Mappings

image

2月12日

DataBinder.Eval with Templates

I saw this tip regarding repeater/datalists/grids and displaying data from a data source.  I thought I repeat as it is new to me.

The DataBinder.Eval method uses reflection to evaluate the arguments that are passed in and to return the results. Consider limiting the use of DataBinder.Eval during data binding operations in order to improve ASP.NET page performance.

Consider the following ItemTemplate element within a Repeater control using DataBinder.Eval.

<ItemTemplate>
  <tr>
      <td><%# DataBinder.Eval(Continer.DataItem, "field1") %></td>
      <td><%# DataBinder.Eval(Continer.DataItem, "field2") %></td>
  </tr>
</ItemTemplate>

Using explicit casting offers better performance by avoiding the cost of reflection. Cast the Container.DataItem as a DataRowView.

<ItemTemplate>
  <tr>
     <td><%# ((DataRowView)Continer.DataItem)["field1"] %></td>
     <td><%# ((DataRowView)Continer.DataItem)["field2"] %></td>
  </tr>
</ItemTemplate>

2月1日

NullReferenceException with Asp.Net Cache

I have been chasing this NullReferenceException for a while.   I found the following information that appears to be an answer to my problem.  I am surprised that there is not more information published regarding usage of cache with threading etc.

Often in ASP.NET application we see a code which looks like this one:

if (Cache["SomeData"] != null)    {
    string name = ((SomeClass)Cache["SomeData"]).Name;
    //.....
}

This code is not safe enough and the second statement can generate a NullReferenceException sometimes. There is no guarantee that a cached object will stay in the cache between two calls. After the first call it can be deleted either by garbage collector or by another thread to refresh cached data.  So to overcome this problem rewrite the code using as operator:

SomeClass someClass = Cache["SomeData"] as SomeClass;
if (someClass != null)    {
   string name = someClass.Name;
   //.....
}

The above are c# versions.  In vb.net it would look like the following...

Dim oldMyCache As MyCache = TryCast(HttpRuntime.Cache("oldMyCache"), MyCache)
If oldMyCache IsNot Nothing Then
    _expired = True
End If

Notice here that we are using the vb.net TryCast command.