My ZoneX

Waiting for Blogger Beta2!!

Thursday, December 29, 2005

SQL 2k Tips : UPDATETEXT

Thank you so much, Grace!


Sent: Tuesday, February 01, 2005 4:07 PM

Hi Micheal,

Do you know that ntext data type can’t do concatenation. To overcome this problem, we can use UPDATETEXT.
The following are the example of using UPDATETEXT.

DECLARE @ptrval binary(16)
Declare @strComments nvarchar(4000)

SET @strComments = 'comments'

SELECT @ptrval = TEXTPTR(rd.Comment)
FROM vyRequisitionDetails rd
WHERE rd.RequisitionID = 'REQPhyuHT02012005-Delhi'

UPDATETEXT vyRequisitionDetails.Comment @ptrval NULL 0 @strComments

Grace

Sunday, December 25, 2005

Adding and Removing Events..

Small .. but I didn't notice about that.. I think I might never notices about that if my friend, Lu taw lay, didn't tell me.... :P

VB
If CheckBox1.Checked Then
AddHandler Button1.Click, _
AddressOf button1_Click
Else
RemoveHandler Button1.Click, _
AddressOf button1_Click
End If

C#
if(this.checkBox1.Checked)
this.button1.Click += new System.EventHandler(this.button1_Click);
else
this.button1.Click -= new System.EventHandler(this.button1_Click);



References..
Handling Events in .NET

Thursday, December 22, 2005

VB6 - Detecting whether the program is running under the control of Visual Studio or not..

Private Declare Function GetModuleHandle _
Lib "kernel32" Alias _
"GetModuleHandleA" _
(ByVal lpModuleName As String) As Long


Public Function TestEnvironment() As Boolean
Dim ModuleHandle As String
Dim EnvFileName As String
Dim EnvVal As Variant
Dim ReturnVal As Long
Dim i As Long
EnvVal = _
Array("vb.exe", _
"vb32.exe", _
"vb5.exe", _
"vb6.exe")
For i = LBound(EnvVal) To UBound(EnvVal)
ModuleHandle = EnvVal(i)
ReturnVal = GetModuleHandle(ModuleHandle)
If ReturnVal <> 0 Then
EnvFileName = ModuleHandle
TestEnvironment = True
Exit For
End If
Next
End Function

Private Sub Command1_Click()
If TestEnvironment() = True Then
MsgBox ("Running under IDE")
Else
MsgBox ("Running as EXE")
End If
End Sub


Another way to do is to detect whether the Visual Studio 6 IDE open or not using some API.

References Link
Question: How can I test whether a program is running at design time or run time using VB6?


Tuesday, December 20, 2005

Useful Links - ASP.NET Page Refesh

Monday, December 19, 2005

Microsoft Codename

Microsoft codenames are the codenames given by Microsoft for their products before releasing
Thank you for giving me the useful links, Amiake-San!!! :-)

Informations related to Code-Name of Microsoft's Product

Visual Studio .NET 2003
Everett is the code-name of Visua Studio .NET 2003. Actually, Everett is the name of city located 30 miles away from the the headquarter of Microsoft in "Redmond", Washington State.

Links
Everett, Washington
Map - Goggle

Visual Studio .NET 2005
Whidbey is the code-name of Visua Studio .NET 2005. Whidbey is the name of an island floating on the Puget Sound, the opposite shore of Everett.

More Informations
Microsoft codenames

http://bink.nu/Codenames.bink

http://www.dnjonline.com/articles/backend/codenames.asp

Tuesday, December 06, 2005

.NET - A Love Story

.NET poem from Scott Kuhl weblog..

.NET - A Love Story

Tips : Probems in VS 2003 and VS 2005

Here is the good weblog site for Visual Studio 2005 setup issues and workarounds.
Error 1904 when installing the 1.0 Framework
A customer ran into the following error dialog when installing the 1.0 Framework:
Error 1904 Module C:\Windows\System32\mscoree.dll failed to register.
HRESULT -2146232576. Contact your support personal.
The customer had the 1.0, 1.1, and 2.0 Framework installed, then uninstalled, then reinstalled and eventually got themselves into a weird dirty state.
They finally ran the clean up tool but setup failed when they tried installing the 1.0 framework.
After debugging their machine, it turned out the following registry key was leaked:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v2.0
I asked the customer to delete that key and the 1.0 framework then installed successfully.
Can't move cursor in VS2005 Text Editor
A customer ran into this issue where they can't move the cursor in the text editor and other things didn't work such as control-Z and import/export settings.
The workaround is:
1)Shutdown Visual Studio
2)Click Start -> Run
3)Type in "devenv.exe /resetuserdata"
4)Open Task Manager and wait for devenv.exe to finish running
5)Restart VS
Thanks goes to James Lau for providing the workaround for this.

Sunday, December 04, 2005

Tips : devenv.exe Problem

Since I am super busy in my work :P, running devenv.exe from Run menu instead of finding the shortcut of VS 2003 in Start Menu can save me a lot of time. When Microsoft distributed a hundred versions of Whidbey I gladly installed/uninstalled the latest version for checking its new features [along with sending a thousand error report to microsoft .. ]:-))... Unfortunately, after UNINSTALLING Whidbey from my machine I was unable to call "devenv.exe" to launch Visual Studio 2003 coz some of register keys have been changed when I installed Whidbey.So after a lot of effort I found out how to fix this and I am sharing it with you all

Steps to perform ~
1) Open registry editor (regedit.exe)
2) Go to this path
HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\
Windows\CurrentVersion\App Paths\devenv.exe"

3) Check the value of this key..
[ you will see this string "
C:\Program Files\Microsoft Visual Studio 8\
Common7\IDE\devenv.exe"]

4) Change this string to
"C:\Program Files\Microsoft Visual Studio .NET 2003\
Common7\IDE\devenv.exe"5)

Done!!

Check : Type "devenv" in run menu... Wow! Visual Studio 2003 is opening...

Hope you will find it useful..


Friday, December 02, 2005

Tools : ILMerge

Overview

ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly. ILMerge takes a set of input assemblies and merges them into one target assembly. The first assembly in the list of input assemblies is the primary assembly. When the primary assembly is an executable, then the target assembly is created as an executable with the same entry point as the primary assembly. Also, if the primary assembly has a strong name, and a .snk file is provided, then the target assembly is re-signed with the specified key so that it also has a strong name.
ILMerge is packaged as a console application. But all of its functionality is also available programmatically. Note that Visual Studio 2005 does allow one to add an executable as a reference, so you can write a C# client that uses ILMerge as a library. (If you are using Visual Studio 2003, just rename ILMerge.exe to be a dll and then add it as a reference to your Visual Studio 2003 project.)
There are several options that control the behavior of ILMerge. See the documentation that comes with the tool for details.
Currently, ILMerge works only on Windows-based platforms. It does not yet support Rotor or Mono. It runs in the v2.0 .NET Runtime, but is also able to merge v1 or v1.1 assemblies.
If you have any problems using ILMerge please contact mbarnett _at_ microsoft _dot_ com. More details are available at the ILMerge web site.


More Info ~
Research Link
Download Link


Thursday, December 01, 2005

Outlook Tips : To prevent sending mails without mentioning 'subject'

To prevent sending mails without mentioning 'subject' use this code.
Steps - Open ur outlook, press alt+f11.On left pane in 'Microsoft Outlook objects', expand to see 'This outlook session'.Double click to open the editor.Copy and paste the following code and save the session.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim strSubject As String
strSubject = Item.Subject
If Len(strSubject) = 0 Then
Prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo
Then
Cancel = True
End If
End If
End Sub

Tips: Controlling Back Button of Internet Explorer 6.0

Using VBScript : PRB: Forward and Back Button Behavior in Internet Explorer


<% 
' The following line is the important part:
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"

%>
<HTML>
<BODY> 
<P>This page is using "Cache-Control: no-cache." This page should not becached for any reason whatsoever. Access to the page via the Back button should pullthe page back from the server.</P>
<P>Current Time:<%= Now() %>
</P>
</BODY>
</HTML>



Manually : Back button in Internet Explorer becomes unavailable.

C# Basic - Using Array in C#

C# Basic – Array Tuturials

In C#, an array starts at zero.. ( Arrays can be divided into four categories. These categories are single-dimensional arrays, multidimensional arrays or rectangular arrays, jagged arrays, and mixed arrays.

Single-dimensional Arrays
Single-dimensional arrays are the simplest form of arrays. These types of arrays are used to store number of items of a predefined type. All items in a single dimension array are stored in a row starting from 0 to the size of array –1.
int [] intArray;intArray = new int[5];
nt [] intArray;intArray = new int[3] {0, 1, 2};
string[] strArray = new string[5] {"Ronnie", "Jack", "Lori", “Max”, “Tricky”};
string[] strArray = {"Ronnie", "Jack", "Lori", “Max”, “Tricky”};
string[] strArray = new string[] {"Ronnie", "Jack", "Lori", “Max”, “Tricky”};

Multi-dimensional Arrays
A multidimensional array is an array with more than one dimension.

string[,] strArray;
int[,] numbers = new int[3, 2] { {1, 2}, {3, 4}, {5, 6} };
string[,] names = new string[2, 2] { {"Rosy","Amy"}, {"Peter","Albert"} };
int[,] numbers = new int[,] { {1, 2}, {3, 4}, {5, 6} };
string[,] names = new string[,] { {"Rosy","Amy"}, {"Peter","Albert"} };
int[,] numbers = { {1, 2}, {3, 4}, {5, 6} };
string[,] siblings = { {"Rosy", "Amy"}, {"Peter", "Albert"} };

Jagged Arrays
Jagged arrays are often called array of arrays. An element of a jagged array itself is an array. For example, you can define an array of names of students of a class where a name itself can be an array of three strings – first name, middle name and last name. Another example of jagged arrays is an array of integers containing another array of integers. For example,
int[][] numArray = new int[][] { new int[] {1,3,5}, new int[] {2,4,6,8,10} };

Again, you can specify the size when you call the new operator.

Mixed Arrays or Rectangular Arrays
Mixed arrays are a combination of multi-dimension arrays and jagged arrays. Multi-dimension arrays are also called as rectangular arrays.

More Informations

Programming C#: Working with Arrays
http://www.c-sharpcorner.com/Code/2002/July/WorkingWithArrays.asp
Array Class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemarrayclasstopic.asp
Array Members
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemarrayclasstopic.asp
Array Properties
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemarrayclasstopic.asp
Array Methods
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemarrayclasstopic.asp

IIS 6 - Virtual Directories Management with C#

C# - Visual Studio 2003
Programmatically Creating Virtual Directory and Deleting the Existing Virtual Directory on IIS 6.0?

#region Create Virtual Directory
/*
* Usage : CreateVirtualDirectory("localhost","MyWebApplication");
*
*/
public static bool CreateVirtualDirectory(string sWebSite,string sAppName,string sPath)
{
System.DirectoryServices.DirectoryEntry iISSchema = new System.DirectoryServices.DirectoryEntry("IIS://" + sWebSite + "/Schema/AppIsolated");
bool bCanCreate = !( iISSchema.Properties["Syntax"].Value.ToString().ToUpper() == "BOOLEAN");
iISSchema.Dispose();

if(bCanCreate)
{
bool bPathCreated=false;
try
{
System.DirectoryServices.DirectoryEntry iISAdmin = new System.DirectoryServices.DirectoryEntry("IIS://" + sWebSite + "/W3SVC/1/Root");

//make sure folder exists
if(! System.IO.Directory.Exists(sPath))
{
System.IO.Directory.CreateDirectory(sPath);
bPathCreated = true;
}

//If the virtual directory already exists then delete it
foreach(System.DirectoryServices.DirectoryEntry vd in iISAdmin.Children)
{
if(vd.Name==sAppName)
{
//iISAdmin.Invoke("Delete", new string(){vd.SchemaClassName,AppName};);
iISAdmin.Invoke("Delete", new string[]{vd.SchemaClassName, sAppName});
iISAdmin.CommitChanges();
break;
}
}


//Create and setup new virtual directory
System.DirectoryServices.DirectoryEntry vdir = iISAdmin.Children.Add(sAppName, "IIsWebVirtualDir");

vdir.Properties["Path"][0] = sPath;
vdir.Properties["AppFriendlyName"][0] = sAppName;
vdir.Properties["EnableDirBrowsing"][0] = false;
vdir.Properties["AccessRead"][0] = true;
vdir.Properties["AccessExecute"][0] = true;
vdir.Properties["AccessWrite"][0] = false;
vdir.Properties["AccessScript"][0] = true;
vdir.Properties["AuthNTLM"][0] = true;
vdir.Properties["EnableDefaultDoc"][0] = true;
vdir.Properties["DefaultDoc"][0] = "default.htm,default.aspx,default.asp";
vdir.Properties["AspEnableParentPaths"][0] = true;
vdir.CommitChanges();

//'the following are acceptable params
//'INPROC = 0
//'OUTPROC = 1
//'POOLED = 2
vdir.Invoke("AppCreate", 1);

return true;
}
catch(Exception ex)
{
if(bPathCreated)
{
System.IO.Directory.Delete(sPath);
throw ex;
}
}
}
return false;
}
#endregion



#region Delete Virtual Directory
/*
* Usage : DeleteVirtualDirectory("localhost","MyWebApplication");
*
*/
public static bool DeleteVirtualDirectory(string sWebSite,string sAppName)
{
System.DirectoryServices.DirectoryEntry iISSchema = new System.DirectoryServices.DirectoryEntry("IIS://" + sWebSite + "/Schema/AppIsolated");
bool bCanCreate = !( iISSchema.Properties["Syntax"].Value.ToString().ToUpper() == "BOOLEAN");
iISSchema.Dispose();

if(bCanCreate)
{
try
{
System.DirectoryServices.DirectoryEntry iISAdmin = new System.DirectoryServices.DirectoryEntry("IIS://" + sWebSite + "/W3SVC/1/Root");

string sWebPath = iISAdmin.Properties["Path"].Value.ToString();

//If the virtual directory already exists then delete it
foreach(System.DirectoryServices.DirectoryEntry vd in iISAdmin.Children)
{
if(vd.Name==sAppName)
{
sWebPath += "\\" + vd.Name;

//if(((System.DirectoryServices.PropertyCollection)((vd.Properties))).valueTable.Count > 0 )
//Original = IIsWebDirectory
//Custom = IIsWebVirtualDir
if(vd.Properties["KeyType"].Value.ToString().Trim() == "IIsWebVirtualDir")
sWebPath=vd.Properties["Path"].Value.ToString();

//iISAdmin.Invoke("Delete", new string(){vd.SchemaClassName,AppName};);
iISAdmin.Invoke("Delete", new string[]{vd.SchemaClassName, sAppName});
System.IO.Directory.Delete(sWebPath);
iISAdmin.CommitChanges();
return true;
}
}
}
catch(Exception ex)
{
return false;
}
}
return false;
}
#endregion

Some other informations related to IIS & .NET 2003

Create a Virtual Directory and Edit its Properties in IIS using C#
http://dotnetjunkies.com/WebLog/ramdash/articles/21777.aspx

Create Virtual Directory in IIS using VB.NET
http://www.vbforums.com/printthread.php?t=347207

Create Virtual Directory in IIS using C# [Easy Way]
System.EnterpriseServices.Internal.IISVirtualRoot vr = new System.EnterpriseServices.Internal.IISVirtualRoot();
string sErr=null;
vr.Create("IIS://localhost/W3SVC/1/Root",@"C:\Sync\","WebServices",out sErr);
Console.WriteLine(sErr);

Virtual Directory
http://www.c-sharpcorner.com/Code/2002/July/CreateVirtualDirs.asp

Creating your own Web Server using C#
http://www.c-sharpcorner.com/Internet/CreatingWebServerInCSIMA.asp

*******

To help a person who don't know about creating IIS. esp: beginner. :-)

[Using INetMgr]
===============

IIS Applications and Virtual Directories
http://authors.aspalliance.com/PaulWilson/Articles/?id=16

How to: Create and Configure Virtual Directories in IIS
http://msdn2.microsoft.com/en-us/library/zwk103ab.aspx

Internet Information Services (IIS) 6.0 Resource Kit
http://www.microsoft.com/downloads/details.aspx?FamilyID=80a1b6e6-829e-49b7-8c02-333d9c148e69&DisplayLang=en

How To Install MetaEdit 2.2 on Windows NT 4.0 or Windows 2000?
If you wanna know about IIS in deep, you should install this exe. This tool will let you know about IIS structures such as where IIS store all information about web folder. I would say that it's really interesting tool. Enjoy :-)
http://support.microsoft.com/default.aspx?scid=kb;en-us;301386&sd=tech
Hints :
What is MetaEdit 2.2?
MetaEdit 2.2 is designed to help administer Microsoft® Internet Information Server for Windows NT® Server 4.0, and Microsoft® Internet Information Services for Windows 2000®.

What is the Metabase?
The metabase is a hierarchical database that is used to store configuration values for IIS. In previous versions of IIS, such values were configurable by directly editing the registry. Some values are still configurable by editing the registry, but the metabase provides more granularity in the configuration of server properties. You can set server properties at the computer, Web site, virtual directory, directory, and file level by modifying the metabase.