Search This Blog

Tuesday, December 28, 2010

New look

With extra time on my hands, I am finally had time to use new template designer with Blogger.  Finally, adjustable width templates w/o any of the hassle.  Not sure if I completely like the new look yet.

FYI, to anyone whose is interested, the mineral featured on the blog banner is a mineral species named Wulfenite. 

So you want useless mineral trivia for 1000.....

Wulfenite was discovered as a mineral species before the element Tungsten was discovered. 
Kind of interesting that in the pre1800s, natural substances commonly contained elements still undetermined.

DotNetZip Library

In my quest for application development using as many free and open source libraries as possible (due largely to the small audience of my mineral collecting software...)

DotNetZip Library - DotNetZip is an easy-to-use, FAST, FREE class library and toolset for manipulating zip files or folders. Zip and Unzip is easy: with DotNetZip, .NET applications written in VB, C# - any .NET language - can easily create, read, extract, or update zip files. For Mono or MS .NET.

Monday, December 13, 2010

Find Replace Characters in Text field in SQLServer 2000 database

Based on article posted at http://sqlserver2000.databases.aspfaq.com/how-do-i-handle-replace-within-an-ntext-column-in-sql-server.html

I needed to write a find and replace for CHAR(146) ` in a text field.  Above article for fort nText and the same solution for text worked with nText with the following changes:
   -  VARCHAR(32) from nVARCHAR(32)
   -  use @lenOldString = DATALENGTH(@oldString) instead of SET @lenOldString = DATALENGTH(@oldString)/2.

DECLARE
@TextPointer BINARY(16),
@TextIndex INT,
@oldString VARCHAR(32),
@newString VARCHAR(32),
@lenOldString INT,
@currentDataID INT;

SET @oldString = '’';
SET @newString = '''';

IF CHARINDEX(@oldString, @newString) > 0
BEGIN
PRINT 'Quitting to avoid infinite loop.';
END
ELSE
BEGIN

--Need the for nText fields
--SET @lenOldString = DATALENGTH(@oldString)/2

--Use this for text fields
SET @lenOldString = DATALENGTH(@oldString)

DECLARE irows CURSOR
LOCAL FORWARD_ONLY STATIC READ_ONLY FOR
SELECT
DataID
FROM
dbo.tbData
WHERE
PATINDEX('%'+@oldString+'%', TextData) > 0;

OPEN irows;

FETCH NEXT FROM irows INTO @currentDataID;
WHILE (@@FETCH_STATUS = 0)
BEGIN

SELECT
@TextPointer = TEXTPTR(TextData),
@TextIndex = PATINDEX('%'+@oldString+'%', TextData)
FROM
dbo.tbData
WHERE
DataID = @currentDataID;

SELECT @TextPointer, @TextIndex

WHILE
(
SELECT
PATINDEX('%'+@oldString+'%', TextData)
FROM
dbo.tbData
WHERE
DataID = @currentDataID
) > 0
BEGIN


SELECT
@TextIndex = PATINDEX('%'+@oldString+'%', TextData)-1
FROM
dbo.tbData
WHERE
DataID = @currentDataID;

UPDATETEXT dbo.tbData.TextData @TextPointer @TextIndex @lenOldString @newString;
END
FETCH NEXT FROM irows INTO @currentDataID;
END

CLOSE irows;
DEALLOCATE irows;


END

Friday, December 3, 2010

One year later and crystal reports still suck.

Here I am a year later revisiting report changes I made almost one year to the day in 2009.  For those in working as a software developer you might be able to guess why I am doing this again one year later, it is because the product has not been released yet even though much of the development was completed 12 months ago!  Okay, I can tell myself I am fine with this (yeah right), let's get the part that I forgot from a year ago.  BTW, I had created a document a year ago to detail how the changes were being made so if someone else (again yeah right) had to make similar changes, this hypothetical person might learn from my pain but I missed this little gem....

Here is the dialog to Set database Location for a crystal report.
Nothing here to dislike.... oh wait
If you highlight database connection in the top tree and the then highlight the live connection in the lower tree and then click Update.  Works fine.

Reverse the order, highlight the live connection and the connection you want to change and then click Update - Does not work.....

Verdict: This sucks.....