Thursday, December 27, 2007

C# GUID Byte Array (Oracle) vs Casting (SQL)

ORACLE
guid = HexEncoding.ToString((byte[])dt.Rows[0]["GUID"]);


public static string ToString(byte[] bytes)
{
string hexString = "";
for (int i = 0; i <>

SQL
Guid guid = ((Guid)dt.Rows[0]["GUID"]);
string strGuid = guid.toString();

The ORDER BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified.

ORACLE
(SELECT STATUS FROM (SELECT * FROM A_RESULT ORDER BY PERCENTAGE_SCORE DESC) WHERE SESSION_MID = S_CLUSTER_ASSESSMENT.SESSION_MID AND SESSION_LID = S_CLUSTER_ASSESSMENT.SESSION_LID AND PARTICIPANT = G_PARTICIPANT.PARTICIPANT_NAME AND ROWNUM = 1) AS STATUS


MS SQL
(SELECT TOP 1 STATUS FROM (SELECT TOP 100 PERCENT * FROM A_RESULT ORDER BY PERCENTAGE_SCORE DESC) AS STATUS WHERE SESSION_MID = S_CLUSTER_ASSESSMENT.SESSION_MID AND SESSION_LID = S_CLUSTER_ASSESSMENT.SESSION_LID AND PARTICIPANT = G_PARTICIPANT.PARTICIPANT_NAME) AS STATUS

Convert Oracle Date to MS SQL Date

Oracle
_sqlQuery += ", to_date('" + DateFirstEnrolled + "', 'MM/DD/YYYY HH24:MI:SS')";

MS SQL
_sqlQuery += ", Cast('" + DateFirstEnrolled + "' as DateTime)";

Wednesday, December 26, 2007

Exceeds the maximum number of bytes per row (8060)

Change your NVARCHAR or VARCHAR to TEXT

Example:
[NOTES] [nvarchar](4000) NULL,

to

[NOTES] [text] NULL,

Tuesday, December 18, 2007

PathTooLongException: Exceeded the Maximum Path Limit of 256 Characters

http://en.wikipedia.org/wiki/Path_%28computing%29


The different types of paths in Windows are local file system (LFS), such as C:\File.ext, uniform naming convention (UNC), such as \\Server\Volume\File.ext, and Long UNC or UNCW, such as \\?\C:\File.ext or \\?\UNC\Server\Volume\File.ext.


One of the differences between LFS and UNC versus Long UNC is that LFS and UNC are limited, depending on the Windows version and/or individual API, to either 260 bytes in ACP format or 260 codepoints in UTF-16 format (or 260 characters in UCS-2 format). Long UNC is limited to 30,000+ codepoints in UTF-16 format (or 30,000+ characters in UCS-2 format) and must be in Unicode.


ACP stands for "ANSI Code Page", which is somewhat of a misnomer since none of the Windows code pages are actually ANSI compliant. The Windows operating system specifies a particular code page as the ACP, which then is used as the default / fallback code page for the 'A' suffixed path APIs. The ACP routines have the shortcoming in that they cannot represent all file paths that are representable in the operating system; they can only represent the character subset of Unicode UCS-2 paths which have characters in the particular code page's character set.

Friday, December 7, 2007

VBA Smart Quotes Replace to HTML

Blogger ate up my HTML and won't show the character formatting:
Single Quote = & #39;
Double Quote = & #34;
Section = & sect;

Function CleanQuotesToHtml(strContent As String) As String
' SINGLE QUOTES
strContent = Replace(strContent, "'", "")
strContent = Replace(strContent, ChrW(8216), "")
strContent = Replace(strContent, ChrW(8217), "")
' DOUBLE QUOTES
strContent = Replace(strContent, """", "")
strContent = Replace(strContent, ChrW(8220), "")
strContent = Replace(strContent, ChrW(8221), "")
' SECTION CHARACTER
strContent = Replace(strContent, Chr(167), "")
CleanQuotesToHtml = strContent
End Function

Monday, December 3, 2007

VBA Word Form Radio Button

To set the default radio button on a VBA form, set the "Value" of the radio button to "True".


Programatic Selection of a Radio Button using Visual Basic Application
Me.Option1.Value = True

Check This Out!

More Links to Good Information