August 2005 - Posts
I was illustrating TextBox Extender component that I had developed that automatically validates any TextBox on a form. I enterd "123" the TextBox and all was right with the world. I added ".-" in an attempt to make it non-numeric, when I got an application exception. Investigation revealed the following:
IsNumeric("123.-") ' Returns True
IsNumeric("123.+") ' Returns True
IsNumeric("123.*") ' Returns False
IsNumeric("123./") ' Returns False
Double.Parse("[Any of the above Combinations]") ' Returns System.FormatException
Is this a bug in the Framework? Or is there something I'm missing?
CDbl("123.-") ' Returns -123.0
CType("123.-", Double) ' Returns -123.0
This is really interesting. The default implementation of Double.Parse() is not the same as simply casting the string to a double.
Yesterday a co-worker and I were having a SQL problem. We were in a circumstance where we wanted two distinct UPDATE triggers to fire on the same table. We could have put all of the trigger code into a single trigger, but the exisiting SQL was already lengthy and complex enough. We thought we'd achieve some clarity by putting the new (unrelated) SQL in a separate trigger.
We encountered an issue though where an UPDATE caused Trigger1 to fire, which in turn caused Trigger2 to fire. When Trigger1 returned, then Trigger2 fired again. After trying all manner of different ways of trying to prevent this cascade effect, I found this article (requires sqlservercentral.com membership) and this SQL:
EXEC sp_configure 'nested triggers', 0
I was trying to test the PDF export generated by Sql Server Reporting Services, but I couldn't get the pdf documents to open. It wasn't just the pdf documents generated by reporting services--I couldn't open any pdf at all. I tried the uninstall/reinstall of Adobe route, but to no avail. This in fact exacerbated my problems. Now everytime I attempted to open Acrobat, Adobe started using 95% of my processor power and wouldn't let go. It still wouldn't open my document
A quick google didn't really bring anything up. Most tips I found involved reading large files (my pdf file was 57kb in size). I tried to go to the Adobe site itself, but something on their site seems to start the Adobe browser plug-in--which of course started eating 95-100% of my processing power right away. I had to uninstall adobe just to use the Adobe web site to find out what my problem was.
I found the solution, albeit in an oblique way. Apparently Adobe generates a lot of temp files and doesn't always clean them up. I found an article on the Adobe Forums that suggested navigating to the root directory and running "del Acr*.tmp /s". Boy was I in for a surprise. Almost immediately the command-line staring filling up with messages that Acr0000.tmp was deleted--and it went all the way up to AcrFFFF.tmp. Wow. So, after deleting the more than 65000 temp files that Adobe had created, I was finally able to open my pdf files.
Hopefully this blog will help the next person that has this problem.
Last week I blogged about a problem I was having finding common ground between the DataReader object, and the Datarow object. I complained of having to write two different constructors that were identical in nature except for the type of object received. Why the solution didn't occur to me before now I can't say, but the answer is the GoF Adapter pattern.
I just wrote an object that adapts the DataRow to the IDataRecord Interface. Problem solved. Simple.
There were some methods that I couldn't completely implement, such as the one that referenced the parent IDataReader object (there isn't one in this scenario), but it should work find for my purposes.
Public Class DataRowAdapter
Private _row As DataRow
Protected ReadOnly Property Row() As DataRow
Default Public Overloads ReadOnly Property Item(ByVal i As Integer) As Object Implements System.Data.IDataRecord.Item
Return Row(i) End Get End Property Default Public Overloads ReadOnly Property Item(ByVal name As String) As Object Implements System.Data.IDataRecord.Item
Return Row(name) End Get End Property
#End Region Public Sub New(ByVal row As DataRow)
Me._row = row End Sub