Friday, July 30, 2010

SQL Server Date Formats

There are several date formats available in the SQL like the following few formats
  • mm/dd/yy
  • mm/dd/yyyy
  • dd.mon.yyy
for complete list of the SQL date fromats use the this link Date Formats.

Wednesday, July 21, 2010

Download .dll or .exe files from IIS server.

If try to download he exe or dll file from the IIS server, you will get 404 file error. But this is incorrect settings in the IIS.

Why:
IIS Manager >> Website/VD >> Properties >> Home Directory >> Application Settings

Execute permissions set to "Scripts and Executables" in IIS.
 
Resolution:
IIS Manager >> Website/VD >> Properties >> Home Directory >> Application Settings

Set Execute permissions to "Scripts only" in IIS.

Friday, June 18, 2010

Microsoft Cursor Engine error '80004005'

When you are trying to retirve data from oracle database from classic ASP. You will get the bellow error.

Microsoft Cursor Engine error '80004005'
Data provider or other service returned an E_FAIL status.
/localhost/file.asp, line 68


For this you need to add NVL function for the null value column

Data provider or other service returned an E_FAIL status.

When you are trying to retirve data from oracle database from classic ASP. You will get the bellow error.

Microsoft Cursor Engine error '80004005'
Data provider or other service returned an E_FAIL status.
/localhost/file.asp, line 68


For this you need to add NVL function for the null value column

Friday, June 11, 2010

Execute exe files through javascript

Before running the bellow script, you need to midify the setting of the internet explorer
  1.  Open IE
  2. Click Tools -> Internet options
  3. Click security Tab
  4. Select local intranet (Based on your requirement)
  5. Click Custom level button
  6. find "Initialize and script ActiveX controls not marked as safe for scripting"
  7. Click the enable button
  8. Click "Ok"
  9. Click "OK"
  10. Close your browser and re-open to test it
function executeCommands()
{
 var oShell = new ActiveXObject("Shell.Application");
 var commandtoRun = "iexplore.exe";
 oShell.ShellExecute(commandtoRun, "", "", "open", "1");
}

Tuesday, May 25, 2010

Oracle output on HTML file


SET MARKUP HTML ON SPOOL ON HEAD "<TITLE>SQL*Plus Report</title> -
<STYLE TYPE='TEXT/CSS'><!--BODY {background: ffffc6} --></STYLE>"
SET ECHO OFF
SPOOL employee.htm

SELECT sysdate from dual;
BY modified_date ASC;
SPOOL OFF
SET MARKUP HTML OFF
SET ECHO ON

Monday, May 17, 2010

Forgot to mention subject in mail???

  1. Open your Outlook,
  2. Press Alt+F11. This opens the Visual Basic Editor and then Press Ctrl+R which in turn open Project-Project 1 (left side)
  3. On the Left Pane, one can see "Microsoft Outlook Objects" or "Project1", expand this. Now one can see the "ThisOutLookSession".
  4. Double click on "ThisOutLookSession". It will open up a Code Pane on the right hand side.
  5. Copy and Paste the following code in the right pane (Code Pane) and save it Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
        Dim strSubject As String
        strSubject = Item.Subject
        If Len(Trim(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

     

Wednesday, May 5, 2010

Run Commands

Infrequently Used Run Commands

Below are a list of commands you can type into the Run dialog, split into several categories: programs, control panels, computer administration tools, and special folders.

Programs

Character Mapcharmap
Check Disk Utilitychkdsk
Clipboard Viewerclipbrd
Free Cellfreecell
Hearts Cardmshearts
Microsoft Chatwinchat
Minesweeperwinmine
On Screen Keyboardosk
Remote Desktopmstsc
Spider Solitarespider
Telnet Clienttelnet
Windows Magnifiermagnify

Control Panels

Accessibility Controlsaccess.cpl
Add Hardware Wizardhdwwiz.cpl
Add/Remove Programsappwiz.cpl
Administrative Toolscontrol admintools
Automatic Updateswuaucpl.cpl
Date and Timetimedate.cpl
Display Propertiesdesk.cpl
Folders Propertiescontrol folders
Fontscontrol fonts
Fonts Folderfonts
Game Controllersjoy.cpl
Internet Propertiesinetcpl.cpl
Keyboard Propertiescontrol keyboard
Mouse Propertiescontrol mouse
Network Connectionscontrol netconnections
Network Setup Wizardnetsetup.cpl
ODBC Data Source Administratorodbccp32.cpl
Password Propertiespassword.cpl
Phone and Modem Optionstelephon.cpl
Power Configurationpowercfg.cpl
Printers and Faxescontrol printers
Printers Folderprinters
Regional Settingsintl.cpl
Scanners and Camerassticpl.cpl
Security Centerwscui.cpl
Sounds and Audiommsys.cpl
User Account Managementnusrmgr.cpl
Windows Firewallfirewall.cpl

Computer Administration Tools

Computer Managementcompmgmt.msc
Device Managerdevmgmt.msc
Disk Cleanup Utilitycleanmgr
Disk Defragmentdfrg.msc
Disk Managementdiskmgmt.msc
Disk Partition Managerdiskpart
Dr. Watson System Troubleshootingdrwtsn32
Driver Verifier Utilityverifier
Event Viewereventvwr.msc
Group Policy Editor (XP Prof)gpedit.msc
Local Security Settingssecpol.msc
Local Users and Groupslusrmgr.msc
Performance Monitorperfmon
Resultant Set of Policyrsop.msc
Scheduled Taskscontrol schedtasks
Servicesservices.msc
Shared Foldersfsmgmt.msc
System Configuration Editorsysedit
System Configuration Utilitymsconfig
Utility Managerutilman
Windows System Security Toolsyskey

Computer Administration Tools

Application Data Folder%appdata%
Home Directory Drive%homedrive%
Home Directory%homepath%
Shared Home Directory%homeshare%
Temporary Folder%temp%
Windows Root Drive%systemdrive%
Windows Root Directory%windir%

Creating Your Own Run Commands

  • Win+R to open the Run dialog
     
  • Enter %windir% to open the Windows directory
     
  • Create a shortcut to the desired program
     
  • The name you give the shortcut is what you type in the Run dialog to start the program

Thursday, April 29, 2010

Image Opacity


.hovereffect img {
opacity:0.5;
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50);
-moz-opacity:0.5;
-khtml-opacity:0.5;
}
.hovereffect:hover img {
opacity:1.0;
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100);
-moz-opacity:1.0;
-khtml-opacity:1;
}
From : vandhemadharam

Wednesday, April 28, 2010

How to get system name using IP Address

  • NBTSTAT -A x.x.x.x
  • NSLOOKUP x.x.x.x
  • PING -A x.x.x.x

Thursday, January 7, 2010

How to use Reserved Words in .NET (C#)

If you can use tens and thousands of words as identifier, why should one use the few keywords reserved by C#?
private static void KeywordExample()
{ 
string string = "Some String";
}
Might be you still want to use ‘bool’, ‘string’ etc. But using this will throw “identifier expected, 'keyword' is a keyword - Compiler Error CS1041”
A reserved word for the C# language was found where an identifier was expected. Replace the keyword with a user-specified identifier.

To overcome this error, prefix the identifier with “@”. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier.
private static void KeywordExample()
{ 
string @string = "Some String";
Console.Write(@string);
}

Check Multiple Instances of an Application using C#

Simple code to check if multiple instances of current application are running in the machine using System.Diagnostics
        private static void check_application_process_instances()
        {
            Process[] oProcess;
            String sModuleName;
            String sProcessName;
            sModuleName = Process.GetCurrentProcess().MainModule.ModuleName;
            sProcessName = System.IO.Path.GetFileNameWithoutExtension(sModuleName);
            oProcess = Process.GetProcessesByName(sProcessName);
            if (oProcess.Length > 1)
            {
                MessageBox.Show("More than one instance is running!");
            }
        }

Tie in Max or Min Function - WITH TIES

If you have two employees with the same birth date - the youngest/oldest employee has a tie. Then use of WITH TIES clause will solve it.

If WITH TIES is also specified, all rows that contain the last value returned by the ORDER BY clause are returned, even if doing this exceeds the number specified by expression.

Top 1 could return two or even more rows in case of a Tie

Select TOP 1 WITH TIES BirthDate from HumanResources.Employee Order By 1 Desc

WITH TIES can be used to get the matching records of the last/first even if it is more than the given number or percent

WITH TIES requires an ORDER BY clause.

How to Convert CSV to XML using C#

Language Integrated Query (LINQ) can be used to convert a CSV file to XML. Here is the sample CSV file that needs to be converted

The following code reads the CSV file to an array. LINQ is used to loop through the array and the contents are written as XML using XElement (System.XML.Linq).

public void ConvertCSVToXML()
        {
            String[] FileContent = System.IO.File.ReadAllLines(@"C:\Temp\vba.csv");
            String XMLNS = "";
            XElement Inv = new XElement("Invoice",
                from items in FileContent
                let fields = items.Split(',')
                select new XElement("Item",
                    new XElement("ID", fields[0]),
                    new XElement("Name", fields[1]),
                    new XElement("Price", fields[2]),
                    new XElement("Availability", fields[3]),
                    new XElement("TotalPrice", fields[4])
                    )
                );
            System.IO.File.WriteAllText(@"C:\Temp\vba.xml", XMLNS + Inv.ToString());
        }