Monday, 1 December 2008
TSQL: How to send e-mail without using SQL Mail in SQL Server
http://support.microsoft.com/kb/312839
Misc: Debugging using Filemon
1) Download Filemon from http://www.sysinternals.com/Utilities/Filemon.html to your server. Unzip and run it.
3) Press Ctrl+L or click the "Filter" button in the menu bar (it looks like a funnel).
4) Uncheck "Log Reads" and "Log Successes" so you don't have hundreds of entries coming up every second. Click OK.
5) Press Ctrl+X or click on the "Clear" button to clear the list.
6) Try your ASP script again and voila, you should have an entry whose result is "ACCESS DENIED" in your list along with the file path and user.
7) Now you can find and right-click on the folder, go to properties->security and grant that user write permission in that directory.
In my case the folder was the "pickup" folder NOT in Intepub (as so many message boards suggest), but in Program Files->Exchsrv directory, and the user was not IUSR_COMPUTERNAME (as so many boards suggest), but NETWORK SERVICE as the exchange application pool on my server is running under the "network service" identity.
Whatever your unusual configuration, you should be able to pinpoint the problem using Filemon.
Friday, 21 November 2008
Javascript: Find query in page
HTML
<form name="form1" onsubmit="search(document.form1, frametosearch); return false">
<input name="findthis" size="15" title="Press 'ALT s' after clicking submit to repeatedly search page" type="text">
<input class="searchbtn" value="Find" accesskey="s" type="submit">
</form>
JavaScript
/******************************************
* Find In Page Script -- Submitted/revised by Alan Koontz
* Visit Dynamic Drive (http://www.dynamicdrive.com/) for full source code
* This notice must stay intact for use
******************************************/
// revised by Alan Koontz -- May 2003
var TRange = null;
var dupeRange = null;
var TestRange = null;
var win = null;
// SELECTED BROWSER SNIFFER COMPONENTS DOCUMENTED AT
// http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var nom = navigator.appName.toLowerCase();
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie = (agt.indexOf("msie") != -1);
var is_ie4up = (is_ie && (is_major >= 4));
var is_not_moz = (agt.indexOf('netscape')!=-1)
var is_nav = (nom.indexOf('netscape')!=-1);
var is_nav4 = (is_nav && (is_major == 4));
var is_mac = (agt.indexOf("mac")!=-1);
var is_gecko = (agt.indexOf('gecko') != -1);
var is_opera = (agt.indexOf("opera") != -1);
// GECKO REVISION
var is_rev=0
if (is_gecko) {
temp = agt.split("rv:")
is_rev = parseFloat(temp[1])
}
// USE THE FOLLOWING VARIABLE TO CONFIGURE FRAMES TO SEARCH
// (SELF OR CHILD FRAME)
// If you want to search another frame, change from "self" to
// the name of the target frame:
// e.g., var frametosearch = 'main'
//var frametosearch = 'main';
var frametosearch = self;
function search(whichform, whichframe) {
// TEST FOR IE5 FOR MAC (NO DOCUMENTATION)
if (is_ie4up && is_mac) return;
// TEST FOR NAV 6 (NO DOCUMENTATION)
if (is_gecko && (is_rev <1)) str =" whichform.findthis.value;" win =" whichframe;" frameval="false;" frameval="true;" win =" parent.frames[whichframe];" strfound="win.find(str);" strfound="win.find(str,">= 1)) {
if(frameval!=false) win.focus(); // force search in specified child frame
strFound=win.find(str, false, false, true, false, frameval, false);
// The following statement enables reversion of focus
// back to the search box after each search event
// allowing the user to press the ENTER key instead
// of clicking the search button to continue search.
// Note: tends to be buggy in Mozilla as of 1.3.1
// (see www.mozilla.org) so is excluded from users
// of that browser.
if (is_not_moz) whichform.findthis.focus();
// There are 7 arguments available:
// searchString: type string and it's the item to be searched
// caseSensitive: boolean -- is search case sensitive?
// backwards: boolean --should we also search backwards?
// wrapAround: boolean -- should we wrap the search?
// wholeWord: boolean: should we search only for whole words
// searchInFrames: boolean -- should we search in frames?
// showDialog: boolean -- should we show the Find Dialog?
}
if (is_ie4up) {
// EXPLORER-SPECIFIC CODE revised 5/21/03
if (TRange!=null) {
TestRange=win.document.body.createTextRange();
if (dupeRange.inRange(TestRange)) {
TRange.collapse(false);
strFound=TRange.findText(str);
if (strFound) {
//the following line added by Mike and Susan Keenan, 7 June 2003
win.document.body.scrollTop = win.document.body.scrollTop + TRange.offsetTop;
TRange.select();
}
}
else {
TRange=win.document.body.createTextRange();
TRange.collapse(false);
strFound=TRange.findText(str);
if (strFound) {
//the following line added by Mike and Susan Keenan, 7 June 2003
win.document.body.scrollTop = TRange.offsetTop;
TRange.select();
}
}
}
if (TRange==null || strFound==0) {
TRange=win.document.body.createTextRange();
dupeRange = TRange.duplicate();
strFound=TRange.findText(str);
if (strFound) {
//the following line added by Mike and Susan Keenan, 7 June 2003
win.document.body.scrollTop = TRange.offsetTop;
TRange.select();
}
}
}
if (!strFound) alert ("String '"+str+"' not found!") // string not found
}
Sysadmin: FTP scripts
@echo off
setlocal
::---------------------------------
:: Start Logging
::---------------------------------
set logfile="C:\_Job_Import_Export\EC\FTP Log\ECLicence.Log"
::---------------------------------
:: Setup Variables
::---------------------------------
set f=%temp%\ftpc.txt
::---------------------------------
:: Compose ftp commands file
::---------------------------------
echo open 192.168.0.1>>%f%
echo user username password>>%f%
echo binary>>%f%
echo cd _job_import_export>>%f%
echo cd "EC">>%f%
echo mput "C:\data\location\*.csv">>%f%
echo bye>>%f%
::---------------------------------
:: Execute ftp command
:: Use "-d" key for verbose output
:: Use "-i" key no interactive mode
::---------------------------------
echo ------------------------>>%logfile%
echo %date% %time% : Start FTP job>>%logfile%
echo ------------------------>>%logfile%
ftp -n -d -i -s:%f% >> %logfile%
::---------------------------------
:: Cleanup temp script
::---------------------------------
del /f /q %f%
::---------------------------------
:: %date% %time% : Backup files
::---------------------------------
L:
cd\
cd "data\location"
echo ------------------------>>%logfile%
echo %date% %time% : Backing Up Files>>%logfile%
echo ------------------------>>%logfile%
move *.csv "backups">>%logfile%
echo ------------------------>>%logfile%
echo %date% %time% : Job Completed>>%logfile%
echo ------------------------>>%logfile%
echo =-=-=-=-=-=-=-=-=-=-=-=->>%logfile%
endlocal
Javascript: getElementsByClassName
/*
Written by Jonathan Snook, http://www.snook.ca/jonathan
Add-ons by Robert Nyman, http://www.robertnyman.com
*/
function getElementsByClassName(oElm, strTagName, oClassNames){
var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
var arrRegExpClassNames = new Array();
if(typeof oClassNames == "object"){
for(var i=0; i<oClassNames.length; i++){
arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
}
}
else{
arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
}
var oElement;
var bMatchesAll;
for(var j=0; j<arrElements.length; j++){
oElement = arrElements[j];
bMatchesAll = true;
for(var k=0; k<arrRegExpClassNames.length; k++){
if(!arrRegExpClassNames[k].test(oElement.className)){
bMatchesAll = false;
break;
}
}
if(bMatchesAll){
arrReturnElements.push(oElement);
}
}
return (arrReturnElements)
}
Tuesday, 21 October 2008
Excel: View column as numbers instead of ABC
Tools > Options > General > R1C1 reference style
Google: Link to Maps
http://maps.google.com/maps?q=park+road,woolloongabba
With Start and End address:
http://maps.google.com/maps?saddr=queen+street,brisbane&daddr=eagle+street,brisbane
Tuesday, 30 September 2008
WSS3.0: Wrap Sharepoint Menu Items with custom HTML
DynamicItemFormatString="<li>{0}</li>"
Tuesday, 9 September 2008
CSS: Tips from Paul Sweatte
Only block level elements have margin and padding
Use even numbers to avoid covering 99% of the page
Use margin:0 auto and width:980px to center all container divs
Avoid using absolute or relative positioning on main content divs
Use a fixed width for all relatively positioned text to make sure it does not overflow its parent div or become truncated
Use block level tags around all inline elements so that no inline elements are a direct child of the container divs. Remember to set the dimensions of the inner blocks to be less than the dimensions of the container divs.
Use position:relative and left:xxx(where xxx is equal to the remaining space between the start of column and the edge of the window) to remove the space between the rightmost column of the layout and the body.
Use margin-left:xxx(where xxx is the same as above) as well as margin-right:yyy(where yyy is the minimum value needed to make the column visible) to achieve the same effect
Use position:relative when attempting to move elements within a container without moving any neighboring elements instead of using margin and padding adjustments
Use visibility:hidden instead of display:none to create a placeholder for unseen elements
Use display:block or vertical-align: bottom on images inside tables to avoid extra whitespace
Use display:table, display:inline-block, or display:compact instead of floats to align block level elements horizontally
Use display:block and set both width and padding values to align inline elements vertically and to align wrapping text and links
Use margin: 0 auto on elements with a width defined in pixels to center block level tags horizontally
Specify the line height to be the same as the height of the containing element to vertically center inline text
Use margin-top: xxx (where xxx is equal to the height of the container div minus the height of the centered element). Divide this value by two to vertically center a block element
Use margin-left: xxx (where xxx is equal to the width of the container div minus the width of the centered element). Divide this value by two to horizontally center a block element.
Use top: 50% and margin-top: -xxx(where -xxx is equal to half of the defined height in pixels) to center absolutely positioned content vertically
Use left: 50% and margin-left: -xxx(where -xxx is equal to half of the defined width in pixels) to center absolutely positioned content horizontally.
You may have to adjust the calculated margin-left values by about 10 pixels in IE specific styles sheets or conditional comments to account for box model differences.
Use position: absolute; bottom: 0; as well as the following steps to align a footer div with the end of a page at any resolution. Next create a container div that is the parent of every other div with position: relative; min-height: 100%; height: 100%. Then set the html and body tags to height:100%. Finally, add bottom padding to the main content div and margin-bottom:-xxx (where -xxx is equal to the height of the footer) to separate it from the footer. The padding may differ between IE and other browsers, so use a separate style sheet or conditional comments if necessary.
Use position:relative with left/right/top/bottom adjustment instead of floats for better cross browser consistency when laying out container elements
Use position:absolute or position:relative with margin adjustments instead of static positioning padding adjustments for better cross browser consistency when laying out content
Use absolute positioning to show important content(Headers, Breaking News) before the rest of the relative content loads
Create space on the page for absolute content by applying margins for the static content which is greater than the width or height of the absolute content
Use absolute positioning with margin shifting to reposition a class of elements (menu titles, footer text, gallery links) at once without giving them the same coordinates
Use vertical-align to center images and text on the same line. Don’t use the sub, super, text-top, or text-bottom values for cross browser consistency
Use list-style-type:none for a >ul< element, display:inline for its >li< elements, and add right side padding or margin for the >a< or >span< tags within to create a horizontal list that can used for tabs, menus, thumbnails, screenshots, etc.
Use display:table for the container div, display:table-row for the parent div, and display:table-cell for the nested divs to create rows and columns in standards compliant browsers.
Use the display:table-cell divs as a container to divide a large row into multiple div blocks for any column
Use display:block for the container div and parent div plus display:inline and zoom:1 for the nested divs to create rows and columns in IE6.
Use display:-moz-inline-box; and display:inline-block; for the container divs to create grids that don’t require zoom:1 or display:table. Remember to still use display:inline for the nested divs to support IE6.
Use vertical-align:top with display:-moz-inline-box to display content consistent with the behavior of display:inline-block on other browsers
If you use overflow:hidden with -moz-inline-box, set a fixed width for the container.
Use display: -moz-inline-box; -moz-box-orient:vertical; to create an inline box with vertically aligned block level child elements
Use display: -moz-inline-block; to create a thumbnail gallery using list elements that wrap and align consistently without floats
Set display properties (text-align, vertical-align,etc)on the parent element if they do not work on the
element itself
Set both the left margin and left padding of the list elements and avoid line-height for consistent placement of bullets across browsers.
Never float two or more columns to the same side, put each pair of left and right floated elements in a wrapper div big enough to contain both elements and padding
Use margin-right:auto with margin-left:0 and text-align:left to left align an hr tag across browsers
Nest an absolute-positioned element within a relative-positioned container with set width and height to freely position a block within a certain area
Use table{caption-side:bottom;} to move a table caption below the table instead of the default position above the table
Use absolute positioning with percentages for the simplest, most consistent display of troublesome elements
Use ‘text-indent: 0′ on elements that are specified ‘display:inline-block’ to avoid inheritance issues
Specify the line height to be the same as the height of the box to align text vertically
Don’t use percentages for margins or borders
Vertical margins and text alignment only apply to block elements
The vertical-align only applies to inline and table-cell elements
Use divs instead of paragraphs when margins don’t take effect
Use position:relative on any elements which need to have a z-index value
If you want relatively positioned elements in one div to overlap relatively positioned elements in another div, you have to raise the z-index of the entire div, or combine the content into the one container div
If you want one element to paint on top of everything else, but you want a child of that element to be behind everything else, make that element the only relatively positioned element, then position the child with a negative z-index.
Typography
Never define font-size for an element without defining it’s line-height
Never use italics
(font-size + vertical padding + vertical margin)/line-height for each element must be a multiple of a baseline number
(font-size + vertical padding + vertical margin) * line-height gives you the total height of each row of text.
Use percentages for all fonts to allow for browser selectable sizing
Never set percentages directly on a tag, always reference an ID or class to avoid cascading issues
Use margins and the
Use a:first-line to set a specific line-height for links that wrap
Use percentages instead of px for cross browser consistency
Use text-decoration:none and list-style-type:none to remove bullets and underlines from links and lists respectively
Use text-transform to capitalize headers and section titles
Use p:first-letter to set a large font and create a literature style drop cap effect for paragraphs
Use list-style-type:decimal in the style sheet instead of changing UL to OL in the HTML to number list items
Use white-space:pre with a return after each letter to display text that reads vertically
Use white-space: -moz-pre-wrap; for Firefox, word-wrap: break-word; for IE, and white-space: pre-wrap for Opera and Safari to force wrapping on predefined text
Use the
Set generous bottom margins equivalent left and right margins for paragraph tags globally for create consistent and maintainable leading and gutter standards
Set wider left margins for list items and quoted text to facilitate hanging punctuation
Inline text needs the same font-size, line-height, vertical alignment, padding, border, margins and position values to line up consistently across browsers.
Dimensions
Use ems as the measurement for container divs, and find the number of ems equal to 100% of the page width to use as your baseline
Reduce margins instead of increasing padding for cross browser consistency
Avoid negative margins on nested divs for cross browser consistency
Avoid defining conflicting values(colors, width, height) for the adjacent margins or borders of neighboring elements
Avoid padding and borders on inline text for cross browser consistency
Inline elements cannot have a defined width unless the display:block property is set
Width and height only apply to block or absolutely positioned elements
Add display:block and 100% width/height to anchor tags within table cells or vertical lists to make the click/hover area expand to the width of the parent element
Add display:block and width/height to image tags to maintain placeholder blocks for missing image files
Never set width or height on the same module where borders and padding are defined. Width goes on the parent, and then borders and padding go on a width:auto child
Never use a measurement for the line-height property
Always set a width on floated elements and their child elements
Use paragraphs instead of divs when width and height don’t take effect
Box Model
Use overflow:hidden to avoid scroll bars within a div and the expanding box problem in IE
Use width: auto and overflow: visible on button elements to avoid extra padding in IE
Use overflow:auto to avoid scroll bars within a textarea in IE
Use the HTML 4.0 Transitional doctype to force quirks mode on all browsers
Use the HTML 4.01 Strict doctype to force strict on all browser except IE
In the W3C box model, element width excludes padding and borders
In the classic IE box model, element width includes padding and borders, giving extra spacing for most content
IE6 always stretches boxes to display overflow content, while other browsers do not
IE6 doesn’t implement overflow:visible correctly
Use -moz-box-sizing: border-box; to emulate the IE box model in Firefox. Use box-sizing: border-box; to emulate it in Safari and Opera
Use -ms-box-sizing: content-box; to emulate the W3C box model in IE.
To remove the horizontal scrolling bar, declare overflow-x: hidden; as a style for the body tag
Background Colors and Images
Use the opacity property to create a rollover effect instead of swapping images
Use the background-position property to move an image to one of the eight compass directions behind the foreground text or image
Use the background-position property to change the hover state of links with background images using CSS sprites
Use background:transparent for rollovers where the parent element includes the image in the hovered position
Use background-image instead of image tags for images that are not content related
Defining the width of a static box that follows a float makes IE6 display differently than any standards compliant browser.
Don’t bother with quotation marks around background image URLs.
Use a ridiculous line-height or negative margin along with overflow:hidden to hide text replaced by images
Don’t use ems as the measurement value to hide text
To use an image for an hr tag, wrap it in a div that uses the image as a background URL and set the hr to display:none
Visual Interaction
Use cursor:pointer to emulate the onmouseover event cursor change
IE6 supports the :active, :hover, :focus, :link, :visited link states
Use :active instead of onclick events and :hover instead of onmouseover events when possible
Use “a[href=www.mysite.com]” to target elements with specific attribute values(CSS2 Attribute Selector)
Use “ul > li{…}” instead of “ul li{…}” to only target the first level children of a tag instead of all nested descendants(CSS2 Child Selector)
Add absolutely positioned elements within link tags and reference them in hover definitions(ex. A:hover span{…}) to create rollover dropdown menus without Javascript
Use a:active, a:focus{outline:0;width:0;height:0;} to remove the dotted line around clicked links
Use img {border:none;} to remove the border around images
Use :link,:visited to style links without styling anchor tags.
Use cursor styles and image maps to extend the click area of links to cover the dimensions of their parent elements without using Javascript
Use rel=”external” for all external links and a[rel~="external"] { target-new: tab; } (CSS3 Attribute Selector) to open links in a new tab
Use { target-name: modal; } (CSS3 Attribute Selector) to open links in a modal box
Use matching light colors for the top and left border and matching dark colors for the bottom and right border of a link. On hover, flip the color pairs and relatively position the link down and to the right by one pixel to generate a simple 3D button effect.
Stylesheet Organization
Use a CSS Validator to ensure that typos and conflicting declarations aren’t causing bugs on your page
Define classes to style block level elements(.content) instead of using tag references by ID (#main p) to make them independent of their parent elements
Define body.classname for each customizable element and define a button in Javascript to dynamically switch classes for each applicable node once the DOM event is triggered
Avoid semicolons on the last style declaration to avoid accidentally typing the end bracket before the semicolon and generating an error
Use styles to set properties for tables instead of table tag attributes for cross browser consistency
Add subclasses for common needs, such as highlighting the first or last item in a list, hiding and showing comment text, emphasizing the current navigation selection, and switching star rating colors on and off
Add IDs for standard layout components, such as site title, site logo, breadcrumbs, navigation, sidebars, content, surveys, and edit/back/search buttons
Style fonts and colors for standard layout components first to avoid redundancy and use cascading
when defining nested elements
Reset styles at the beginning of the style sheet to overwrite inconsistent defaults across browsers
Remove redundant and obsolete styles when moving test code to production
Define hover, focus, and active(e.g. :link:hover, :visited:active, etc.) rules in the preceding order of operation to cascade the rules properly
Use classes instead of IDs for any code intended to work inside the sandbox of a third party API, since IDs may be stripped out to avoid conflicts
Debugging
Test in at least four browser engines (Gecko, Webkit, Trident, Presto) each time you make a change
to avoid massive debugging efforts at the “end” of a layout task
Create a copy of the template and remove all divs except the misaligned one and its adjacent divs to debug positioning issues
Remove margins from inner divs when debugging ignored positioning values in absolutely positioned divs
Remove all inline text and start with non-breaking space as the placeholder content to debug width and height issues
Set margin, padding, font-size, and border size to zero for debugging unseen inheritance issues
Use a separate style sheet for IE when absolutely positioned elements or margins are inconsistent with other browsers
Use obvious background colors to highlight misplaced or misaligned nested elements when debugging
inner divs
Layout Emulation
Use multicolumn list to emulate newspaper column layout for articles
Style the corners using four or five pixel high strips before and after the main content div. These strips are created using bold tags. Each bold tag should be styled as display:block; overflow:hidden;. Surronding each set of strips should be a bold container styled as display:block; background:transparent; font-size:1px;. Each one except the last bold tag should be 1 pixel in height. Each one except the first bold tag should have the same background color as the content div. The horizontal margin for each bold tag should equal the sum of the tag’s position plus the number of remaining tags, plus one. This will produce rounded corners.
Use an alternative style sheet if no visited cookie exists for your site to load the home page with just the logo, set the visited cookie, and links to the standard style sheet which reveals the hidden content as an alternative to the traditional Flash based splash page
the main page to the splash page and the rest of the page’s content was hidden.
Sysadmin: FTP Commands
List of FTP commands for the Microsoft command-line FTP client
Command-line options
As you're starting the program from a DOS prompt:ftp [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [computer]
- -v - Suppresses verbose display of remote server responses.
- -n - Suppresses auto-login upon initial connection.
- -i - Turns off interactive prompting during multiple file transfers.
- -d - Enables debugging, displaying all ftp commands passed between the client and server.
- -g - Disables filename globbing, which permits the use of wildcard chracters in local file and path names.
- -s:filename - Specifies a text file containing ftp commands; the commands will automatically run after ftp starts. No spaces are allowed in this parameter. Use this switch instead of redirection (>).
- -a - Use any local interface when binding data connection.
- -w:windowsize - Overrides the default transfer buffer size of 4096.
- computer - Specifies the computer name or IP address of the remote computer to connect to. The computer, if specified, must be the last parameter on the line.
Client commands
- ! - Runs the specified command on the local computer
- ? - Displays descriptions for ftp commands
- append - Appends a local file to a file on the remote computer
- ascii - Sets the file transfer type to ASCII, the default
- bell - Toggles a bell to ring after each file transfer command is completed (default = OFF)
- binary - Sets the file transfer type to binary
- bye - Ends the FTP session and exits ftp
- cd - Changes the working directory on the remote computer
- close - Ends the FTP session and returns to the command interpreter
- debug - Toggles debugging (default = OFF)
- delete - Deletes a single file on a remote computer
- dir - Displays a list of a remote directory's files and subdirectories
- disconnect - Disconnects from the remote computer, retaining the ftp prompt
- get - Copies a single remote file to the local computer
- glob - Toggles filename globbing (wildcard characters) (default = ON)
- hash - Toggles hash-sign (#) printing for each data block transferred (default = OFF)
- help - Displays descriptions for ftp commands
- lcd - Changes the working directory on the local computer
- literal - Sends arguments, verbatim, to the remote FTP server
- ls - Displays an abbreviated list of a remote directory's files and subdirectories
- mdelete - Deletes one or more files on a remote computer
- mdir - Displays a list of a remote directory's files and subdirectories
- mget - Copies one or more remote files to the local computer
- mkdir - Creates a remote directory
- mls - Displays an abbreviated list of a remote directory's files and subdirectories
- mput - Copies one or more local files to the remote computer
- open - Connects to the specified FTP server
- prompt - Toggles prompting (default = ON)
- put - Copies a single local file to the remote computer
- pwd - Displays the current directory on the remote computer (literally, "print working directory")
- quit - Ends the FTP session with the remote computer and exits ftp (same as "bye")
- quote - Sends arguments, verbatim, to the remote FTP server (same as "literal")
- recv - Copies a remote file to the local computer
- remotehelp - Displays help for remote commands
- rename - Renames remote files
- rmdir - Deletes a remote directory
- send - Copies a local file to the remote computer (same as "put")
- status - Displays the current status of FTP connections
- trace - Toggles packet tracing (default = OFF)
- type - Sets or displays the file transfer type (default = ASCII)
- user - Specifes a user to the remote computer
- verbose - Toggles verbose mode (default = ON)
Sunday, 7 September 2008
Persits ASPEmail: Server object error 'ASP 0177 : 800401f3'
Problem Description
When trying to create an instance of a Persits component, the line of codeSet obj = Server.CreateObject("Persits.
") generates the following error (Windows NT/IIS4)
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
Invalid class stringOn Windows 2000/IIS5, the error message is
Server object, ASP 0177 (0x800401F3)
Invalid ProgID.
Solution
This error means that either the component has not been registered on the server or the ProgID passed to the Server.CreateObject method is misspelled. On Windows 2003 and XP, it may also mean a permission problem on a system registry key.Make sure the component DLL is present on the server. The exact physical location of the DLL is not important. To register the component on the server, open MS DOS prompt and type
c:\> regsvr32 c:\path\aspupload.dll
(you must use your component's appropriate path and file name).
The correct Persits component ProgID's and file names are listed in the following table:
Name File ProgID AspEmail aspemail.dll "Persits.MailSender" AspEncrypt aspencrypt.dll "Persits.CryptoManager" AspGrid aspgrid.dll "Persits.Grid" AspJpeg aspjpeg.dll "Persits.Jpeg" AspUpload aspupload.dll "Persits.Upload" AspUser aspuser.dll "Persits.AspUser" XUpload xupload.ocx "Persits.XUpload" AspPDF asppdf.dll "Persits.PDF" On Windows 2003 and XP, this error may also mean the component's ProgID key in the system registry has been assigned insufficient permissions. Run regedt32, open the key HKEY_CLASSES_ROOT\ProgID, select Permissions from the Edit menu, and grant the "Everyone" account Full Control over the key. See the table above for the correct ProgID values.
Friday, 5 September 2008
WSS3.0: Enable quicklaunch on webpart pages
When you create a new Web Part Page within SharePoint 3.0 (Site Settings >
Create > Web Part Page) the Quick Launch Bar does not appear.
This to me is silly, because you spend time creating a nice menu, but it
doesn't appear on all pages.
So to ensure the Quick Launch Bar appears on all pages, including any newly
created Web Part pages, you need to open the SharePoint 3.0 site in
SharePoint Designer, open the Master Page and locate these 2 Content
Placeholders.
runat="server">"CODE"
For the record, you have a Master Page and you have many Content Pages.
Now the way it works as I see it, the Master Page has all the Quick Launch
code nestled in these content placeholders, and the Quick Launch is only
visible to the Content Pages which ask it to be visible.
You could go and manipulate the actual Web Part Page (which is already
created) and force it to show the Quick Launch Bar, but what happens when a
non-technical user goes and creates a new Web Part Page? They will have to
call the developer and ask them to manipulate the page to get the Quick
Launch to show up, which is not a good plan.
My plan was to manipulate the Master Page and force the Quick Launch Bar to
show up on every page. Even new Web Part Pages (that get created by
non-technical users).
So here̢۪s what I did:
Find the Quick Launch CODE that is nestled within the first Content
Placeholder stated above. Now find the Closing Content Placeholder Tag for
this CODE and move it to the top of the Quicklaunch CODE. So the Content
place holder will look like
runat="server">
And the Quick Launch CODE is outside of the Content Placeholder tags. This
now forces the Quick Launch to show up on every page. Bloody simple aye.
You are not quite finished yet because the Quick Launch width shrinks a
little bit and the words wrap to the next line.
So now find the second content Placeholder stated above, and do the same
thing as you did for the previous CODE.
NOTE:
DO NOT delete the Content Placeholders, as they are still needed to render
(load) the page. The page will error if they are deleted.
I have not encountered any issues in doing this yet, but remember, when
using SharePoint designer you can always revert to the original Master Page
if things go pear shaped.
Ref : http://www.eggheadcafe.com/software/aspnet/29440009/show-quick-launch-on-webp.aspx
Thursday, 4 September 2008
CSS: IE and Firefox Hacks
.hello {
text-align: center;
background-color: #FF0000;
*background-color: #00FF00;
_background-color: #0000FF;
}
If you are familiar with CSS you'll understand all of the syntax except
for the "*" and "_" in front of the background-color properties. What
do they do?
The CSS specs say that browsers should read any
property names they know about and ignore any property names they don't
know about. In the above CSS the spec compliant browsers know about a
property named "background-color" but don't know about properties named
"*background-color" and "_background-color".
To cut a long story
short, the Internet Explorer CSS parser is overly aggressive at trying
to discover the names of properties and will in fact ignore leading
non-alphanumeric characters. From my testing this appears to be the
case from at least IE5 onwards.
It became convention amongst web
developers to used an underscore in front of property names when
targeting CSS for IE, although any non-alphanumeric character will
work. However, the CSS 2.1 spec made underscore a valid character in a
property name, so IE7 specifically removed underscore from their
aggressive parsing. From IE7 onwards web developers have been using an
asterisk instead of an underscore when targeting CSS at IE, although
any non-alphanumeric character will do. Interestingly, the removal of
the underscore hack in IE7 allows you to target CSS at pre-IE7 (using
underscore) and post-IE7 (using asterisk or some other non-alphanumeric
character) browsers.
So with this background knowledge here is how the above CSS would be interpreted by different browsers:
* Firefox, Opera, Safari and all non-IE browsers would correctly parse "background-color", fail to parse "*background-color" and "_background-color", and will set the background color of the div with class "hello" to red.
* IE6 and earlier versions of IE will successfully parse "background-color", "*background-color" and "_background-color". The background color value will come from the last successfully parsed property, so the background color of the div with class "hello" will be set to blue.
* IE7 and later versions of IE will successfully parse "background-color", "*background-color" but fail to parse "_background-color". The background color value will come from the last successfully parsed property, so the background color of the div with class "hello" will be set to green.
One final note on this IE leading non-alphanumeric character hack: It is invalid CSS so the strictest parsers will give you an error.
Firefox CSS Hacks
There are plenty of CSS hacks for IE, but what about Firefox?
I've found one hack that allows you to target Firefox 2 or Firefox 3, but some versions of IE also pick up the CSS intended for Firefox. Extending our CSS file above:
.hello {
text-align: center;
background-color: #FF0000;
*background-color: #00FF00;
_background-color: #0000FF;
}
/* Target Firefox 3 */
.hello, x:-moz-any-link, x:default {
background-color: #FFFFFF;
}
/* Target Firefox 2 */
.hello, x:-moz-any-link {
background-color: #FF00FF;
}
In Firefox 2 the background color of the div with class "hello" will be
pink, but strangely it will also be pink in IE5 and IE7 (they will pick
up the last CSS property intended for Firefox), and blue in IE5.5 and
IE6 (they don't pick up the CSS intended for Firefox).
If you find any Firefox CSS hacks that will only be applied to Firefox please let me know.
REF: http://robertmaldon.blogspot.com/2008/03/css-tricks-that-target-specific.html
Google: Chrome Browser easter eggs
Persits ASPEmail: Read Receipts
Monday, 1 September 2008
CSS: CSSP ie CSS Positioning
Web design usually means something more than just fonts, colours and
graphical elements. It also implies some sort of layout. A web designer has
three available tools for creating a layout:
* tables,
* floats,
* positioning.
Layout tables belong in the last millennium. Floats are often the best
solution, especially when you don't know in advance which column will be the
longest. Older browsers, and Internet Explorer, aren't too good at dealing with
floats, though. Besides, that's a separate topic.
Positioning is perhaps one of the most misunderstood parts of
CSS 2. Let us look a little closer at how it works.
This article is now available in Polish: Bezwzględnie względny, in Spanish: Relativamente Absoluto, in Turkish: CSS Hizalama, and in Dutch: Relatief, absoluut
Absolute positioning is sometimes referred to as CSS-P.
Beginners using Dreamweaver tend to call it layers, which is
unfortunate, because it can be confused with Netscape's proprietary
But let's start from the beginning. The position
property in CSS accepts four different values (plus
inherit):
* static,
* relative,
* absolute,
* fixed.
For all values except static we can affect the element's
position through the top, bottom, left
and right properties.
Static Positioning
Elements with position:static, which is the default value for
all elements, are not positioned at all. Their placement on the canvas is
determined by where they occur in the document.
Thus the static value is only used for overriding a
previously set value.
We will use the term "statically positioned" in this article, even
though it isn't fully correct.
Relative Positioning
Elements with position:relative are positioned relative to
themselves. This may sound strange, but it can be useful sometimes.
If we specify a value for either of the four edge properties, the relatively
positioned element is shifted in relation to the position it would have occupied
if it had been statically positioned.
This may sound like Greek to you, but it's actually quite logical. If we just
set position:relative on an element, without specifying any of the
edge properties, the element ends up exactly where it would have been if we had
set position:static, or if we hadn't set position at
all.
If we set top:10px, the element is shifted 10 pixels from its
original top edge. That means it moves downward. A negative value shifts the
element in the opposite direction, so we could achieve the exact same result by
setting bottom:-10px. This means it's not meaningful to specify
both top and bottom, or both left and right. There may, however, be reasons for
specifying, for instance, top and left together, if we
want to shift an element both vertically and horizontally.
Now, this isn't very useful for creating columns, because a relatively
positioned element remains in the document flow – in the position where it
originally was. It still takes up space, but not where it's actually shown, but
where it would have been shown, had it been statically positioned.
What does this mean in the real world? Relative positioning is mostly useful
for shifting an element a few pixels in either direction, or you'll get a
"hole" in your page. There is, however, another use for it that is much
more important: A relatively positioned element counts as positioned, even if we
don't shift it a single pixel in any direction. We will soon see why that is
important.
Absolute Positioning
What people normally mean by positioning, CSS-P or layers, is
elements with position:absolute. The top,
bottom, left and right properties specify
the distance to the corresponding edge of the element. But from what?
Ironically, absolute positioning is relative. Yes, you read that right. An
absolutely positioned element is positioned relative to another element, called
the containing block. Here comes the definition of that. Take a few
deep breaths and hold on tight to the armrests of your chair.
The containing block of an absolutely positioned element is its nearest
positioned ancestor, or, if there is no such element, the document's
initial containing block.
By "positioned ancestor" we mean a structurally superior element whose
position property is absolute, fixed or
relative. So here is that important use for relatively positioned
elements that we touched on a minute ago. By setting
position:relative for an element, without shifting it at all, we
can establish a new context for its absolutely positioned children. Sounds easy,
doesn't it?
But if there is no positioned ancestor then? That's where the so-called
initial containing block comes into the picture. The CSS
standard helpfully says that this is "chosen by the user agent". ("User
agent" is the application that processes a web page, for instance a browser,
some assistive technology, or a search engine.) The standard also states that it
could be related to the viewport. In practice this means either of the
BODY or HTML elements.
Absolutely positioned elements are completely removed from the document flow.
This means they don't take up any space. Or, to phrase it differently, they
don't affect subsequent elements. We thus have to make sure ourselves that no
other content ends up underneath our positioned element, unless that is the very
effect we're after, of course.
An absolutely positioned element with top:100px is consequently
placed so that its top edge is 100 pixels from the top edge of its containing
block. In browsers that support CSS you can specify all four edges
and let the browser compute the width and the height. Unfortunately this doesn't
work in Internet Explorer, so it's almost always necessary to specify at least
the width of an absolutely positioned element.
It is perfectly legal to specify negative values for the edge properties, but
if you do, you should be very aware of what the containing block is. Otherwise
you risk putting the element completely or partially off the screen.
Fixed Positioning
We established earlier that absolute positioning is relative, so it should
come as no surprise that fixed positioning is absolute.
An element with position:fixed is positioned absolutely with
respect to the viewport (the browser window). Fixed positioning is very similar
to absolute positioning, but there are differences. The position is always
computed with respect to the viewport; the viewport is always the containing
block. The element is removed from the document flow and it stays put even if
the user scrolls the document.
Unfortunately Internet Explorer doesn't support fixed positioning. There are
a number of more or less complicated ways to circumvent that, but fixed
positioning isn't actually as useful as one may think. Sure, it's conceivable to
have a menu in the left or right column that is always visible, but most users
today expect everything on the page to move upwards when they scroll.
Finally
Absolute positioning is useful for multi-column layouts, as long as you
always know which column is longest. Since the absolutely positioned elements
are removed from the document flow, the don't affect subsequent elements.
Therefore it is very difficult to have a full-width footer appear after all the
columns.
As with any web design, you should try to use relative units with
positioning, so that the layout can adapt to different window sizes. The value
for left, for instance, should be specified in em or
%, not in px.
If you specify the width for an absolutely positioned element, either
explicitly via width in percents, or implicitly
via left and right, the standard says that it should
be computed relative to the containing block. Both Internet Explorer
and Opera get this wrong, unfortunately, and use the width of the
parent element as the basis for their computations. Gecko-based
browsers like Mozilla and Firefox behave correctly.
With all types of positioning, including relative, you should set margins and
padding explicitly, especially if you want it to look the same cross-browser.
Browsers have different standard values for these properties.
When positioned elements overlap, we can control the stacking order with the
z-index property. The higher the z-index, the closer
to the user the element ends up. Unfortunately this isn't quite as
straightforward as it sounds, since each containing block establishes its own
context for z-index. So to put one element on top of another
element, with a different containing block, you need to increase the
z-index for the first element's containing block. In
really complex layouts you can find yourself in impossible situations, if you
want to stack three elements where the middle one has a different containing
block than the other two. As far as we know, this cannot be done.
Absolute positioning is often used with DIV elements, but it's
perfectly valid to position any element.
Sunday, 31 August 2008
WSS3.0 Creating a new theme
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES"
![clip_image004[7]](http://weblogs.asp.net/blogs/danlewis/WindowsLiveWriter/CreateaCustomThemeforWSS3.0orMOSS2007_9E7/clip_image004%5B7%5D_thumb.jpg)
In your new theme folder, rename OLDNAME.INF file to NEWNAME.INF (Wheat to LewTek) Ensure its upper case!
- Open NEWNAME.INF with notepad or your favorite text editor (LEWTEK.INF)
- Change the value of title under [info] from Oldname to Newname.
- Change all values under [titles] from Oldname to Newname.
Make theme available in sharepoint
Next we need to edit this file so that we can actually choose our newly created theme. This will make it available in the list of themes on the Site Theme page.
- Open SPTHEMES.xml in notepad or any other text editor for editing. It is located in the following directory:
- "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\SPTHEMES.XML"
- Next you need to add your new template. Add the following lines under the
tag (you may find it easier to just copy and paste the tags for an existing theme, and then changing it):
<Templates>
<TemplateID>LewTek</TemplateID>
<DisplayName>LewTek</DisplayName>
<Description>Type a description for your new theme.</Description>
<Thumbnail>images/thlewtek.gif</Thumbnail>
<Preview>images/thlewtek.gif</Preview>
</Templates>
Preview Thumbnail
- The thumbnail and preview tag reference an image. This image does not exist yet and you’ll need to create it. Once your theme is complete, you can take a screenshot of it and then resize it.
- Now if you navigate back to the Site Theme page and refresh it – you’ll see your custom theme available to apply to the site. You’re done!
- The file theme.css in your theme folder contains all of your styles
- Edit this style sheet to make changes to your theme’s look – change the colors, change the font, etc...
- Images in your theme folder can be edited / replaced.
- After making any changes to your theme, reset IIS prior to reapplying the theme.
- Make incremental backups of your Theme folder as you are working. Somewhere along the way you WILL mess up and need to revert.
WSS3.0: Master Pages vs Themes
Master Pages
- Can totally change the look of a site.
- Can hide SharePoint components that you don't want to use.
- Will allow you to alter the layout of the page, in addition to changing the colors and images used in the site.
- Will not affect _layouts pages. You will need to use a workaround. Application pages will not be changed.
Themes
- Can re-skin the layout of a site to use different images and colors.
- Can only hide SharePoint components that can be controlled through hiding it in the CSS (display: none set on a class/ID).
- Affects _layouts pages. But you will need to apply theme to each subsite individually.
- Can be used as an alternate CSS file application method, similar to alternate CSS setting in MOSS sites.
- Are installed on the web server unless you customize the file.
Friday, 29 August 2008
Sharepoint: Tips
ToolPaneView=2 to the end of the URL
e.g. http://sharepoint/default.aspx?ToolPaneView=2
ToolPaneView=3
brings up the search dialog
Monday, 25 August 2008
Excel: Conditional Formatting
For example, the following data would be hard to read when there are hundreds of columns and thousands of rows:
Whereas the following data is much easier to scan and read:
To create this effect, in Conditional Formatting create a formatting rule where
Format values where this formula is true:
=(A2=A1)
Text Format:
Font Color = Grey
Sysadmin: AT scheduling command
at 00:30 /every:M,T,W,Th,F,S,Su "e:\Constant_bak.bat"
Inside batch file, it copies a file and backs it up.
copy \\ebnews99\e$\constants.asp \\ebnews99\e$\constants_bak.asp
Sunday, 24 August 2008
Sysadmin: SORT command
The "/+1" defines at which character from the beginning of a new line should the utility start ordering from.
/t is the temporary storage location used to processed the data, useful if the data exceeds available memory
/c is the output file location
sort /+1 source.txt /t c:\temp\tempstorage.txt /o c:\temp\sorted.txt
Thursday, 21 August 2008
Sysadmin: Windows XP/2000 Command List
- at (windows XP/2000)
Scheduling utility. - bootcfg (XP only) This utility allows you to set up your boot options, such as your default OS and other loading options.
- cacls (XP, 2000, & NT4.0) Changes the ACLs (security Settings) of files and folders. Very similar to chmod in Linux.
- comp (XP & 2000) This utility is very similar to diff in Linux. Use the /? switch to get examples of command usage.
- contig (works with NT4.0 and newer) A great defrag utility for NTFS partitions.
- control (XP only) - unpublished!
Allows you to launch control panel applets from the command line. - defrag (XP only - NT4.0 and Win2k use contig) Yes, XP comes with a command line disk defrag utility. If you are running Win2k or NT4.0 there is still hope. Contig is a free defrag program that I describe on the defrag page.
- diskpart (XP only) Use this command to manage your disk partitions. This is the text version for the GUI Disk Manager.
- driverquery (XP only) Produces a list of drivers, their properties, and their versions. Great for computer documentation.
- eudcedit (XP only) -
- findstr
Find String - similar to Linux's Grep. - fsutil (XP only) - unpublished!
This is a utility with a lot of capability. Come back soon for great examples. - getmac (XP & 2000) This command gets the Media Access Control (MAC) address of your network cards.
- gpresult (XP & 2000) This generates a summary of the user settings and computer group policy settings.
- gpupdate (XP only) Use this utility to manually apply computer and user policy from your windows 2000 (or newer) domain.
- ipconfig (XP, 2000 & NT4.0) This handy tool displays IP settings of the current computer and much more.
- MMC (XP, 2000 & NT4.0) - Microsoft Management Console This is the master tool for Windows, it is the main interface in which all other tools use starting primarily in Windows 2000 and newer systems.
- more Utility used to display text output one screen at a time. Ex. more c:\windows\win.ini
- msconfig (XP only) The ultimate tool to change the services and utilities that start when your Windows machine boots up. You can also copy the executable from XP and use it in Win2k.
- msinfo32 (XP &smp; 2000) An awesome diagnostic tool. With it you can get a list of running processes, including the residing path of the executable (great for manually removing malware) and get detailed information about hardware and system diagnostics.
- narrator (XP only) Turns on the system narrator (can also be found in accessibility options in control panel). Will will allow your computer to dictate text to you.
- netsh (XP & 2000) A network configuration tool console. At the 'netsh>' prompt, use the '?' to list the available commands and type "exit" to get back to a command prompt.
- netstat (XP) A local network port tool - try netstat -ano.
- nslookup (all) A DNS name resolution tool.
- openfiles (XP Only)
Allows an administrator to display or disconnect open files in XP professional. Type "openfiles /?" for a list of possible parameters. - Pathping (XP & 2000) A cross between the ping and traceroute utilities. Who needs Neotrace when you can use this? Type "pathping
" and watch it go. - recover (XP & 2000) This command can recover readable information from a damaged disk and is very easy to use.
- reg (XP & 2000) A console registry tool, great for scripting Registry edits.
- sc (XP & 2000) A command line utility called the Service Controller. A power tool to make service changes via a logon/logoff or startup/shutdown script.
- schtasks (XP only) A newer version of the AT command. This allows an administrator to schedule and manage scheduled tasks on a local and remote machines.
- secedit (XP & 2000) Use this utility to manually apply computer and user policy from your windows 2000 (or newer) domain. Example to update the machine policy: secedit /refreshpolicy machine_policy /enforce To view help on this, just type secedit. NOTE: In Windows XP SP1 and news, this command is superceded by: gpupdate /force
- sfc (XP & 2000) The system file checker scans important system files and replaces the ones you (or your applications) hacked beyond repair with the real, official Microsoft versions.
- shutdown (XP & 2000) With this tool, You can shut down or restart your own computer, or an administrator can shut down or restart a remote computer.
- sigverif (XP only) Microsoft has created driver signatures. A signed driver is Microsoft tested and approved. With the sigverif tool you can have all driver files analyzed to verify that they are digitally signed. Just type 'sigverif' at the command prompt.
- systeminfo (XP only) Basic system configuration information, such as the system type, the processor type, time zone, virtual memory settings, system uptime, and much more. This program is great for creating an inventory of computers on your network.
- sysedit (XP/2000) System Configuration File Editor. An old tool that was very handy for the Windows 9X days. msconfig is what you want to use now.
- tasklist (XP pro only) Tasklist is the command console equivalent to the task manager in windows. It is a must have when fighting scumware and viruses. Try the command: tasklist /svc to view the memory resources your services take up.
- taskkill (XP only) Taskkill contains the rest of the task manager functionality. It allows you to kill those unneeded or locked up applications.
- tree (XP & 2000) An amazing experience everyone should try! This command will provide a 'family tree' style display of the drive/folder you specify.
- WMIC (XP & 2000) Windows Management Instrumentation Command tool. This allows you to pull an amazing amount of low-level system information from a command line scripting interface.
control userpasswords2, for example will launch a helpful local user admin utility.
unpublished!
Private Character editor. Yes with this program built into Windows XP you can create your own font!
Of course this list in note exhaustive. We wanted to focus on tools that are particularly helpful that everyone would use. For the official list, please visit: Microsoft Windows XP Pro Command Reference
Tuesday, 19 August 2008
Sysadmin: CCMexec.exe kills my pc
A quick google around later, I found out that this file is used by Microsofts SMS service. Apparently used by the SMS host to deploy software and patches to desktop pc's across the corporate network. Basically another big brother tool from M$.
Killing this executable cured my PC from its spastic habits but I'll need to investigate more as to why it only runs on my PC and only at 10:30AM each day!! It is basically sucking the life force out of my HD causing it to wear and will probably make it sucidal in the end.
Thursday, 7 August 2008
TSQL: CASE statements example
a.SarID,
a.Createdate as CreatedDate,
a.ApprovedDate,
a.CompletedDate,
CASE a.status
WHEN 'C' THEN 'COMPLETED'
WHEN 'R' THEN 'REJECTED'
WHEN 'A' THEN 'APPROVED'
WHEN 'L' THEN 'LODGED'
WHEN 'X' THEN 'X'
WHEN 'P' THEN 'P'
ELSE 'Unknown'
END as RequestStatus,
(select fname + ' ' + sname from intranetwarehouse..staffdetails where id = a.personid) as LodgeFor,
a.createdby as LodgeByUsername,
a.approvedby as ApprovedByUsername,
(select fname + ' ' + sname from intranetwarehouse..staffdetails where id = a.approverid) as ApproverName,
e.name as SystemName,
CASE e.status
WHEN 'I' THEN 'Inactive'
WHEN 'A' THEN 'Active'
ELSE 'Unknown'
END as isSystemActive,
d.name as ApplicationName,
CASE d.status
WHEN 'I' THEN 'Inactive'
WHEN 'A' THEN 'Active'
ELSE 'Unknown'
END as isApplicationActive,
c.name as OptionName,
CASE c.status
WHEN 'I' THEN 'Inactive'
WHEN 'A' THEN 'Active'
ELSE 'Unknown'
END as isOptionActive,
CASE b.status
WHEN 'P' THEN 'PENDING'
WHEN 'A' THEN 'APPROVED'
WHEN 'R' THEN 'REJECTED'
WHEN 'L' THEN 'LODGED'
ELSE 'Unknown'
END as OptionApprovalStatus,
a.Comment
from ittservice..sar as a, ittservice..optionaccessrequests as b, ittservice..options as c, ittservice..applications as d, ittservice..systems as e
where a.sarid = b.sarid
and b.optionid = c.optionid
and c.applicationid = d.applicationid
and d.systemid = e.systemid
and year(a.createdate) = '2008'
order by a.sarid
Tuesday, 8 July 2008
Javascript: Maximize and Minimize
function Minimize()
{
window.innerWidth = 100;
window.innerHeight = 100;
window.screenX = screen.width;
window.screenY = screen.height;
alwaysLowered = true;
}
function Maximize()
{
window.innerWidth = screen.width;
window.innerHeight = screen.height;
window.screenX = 0;
window.screenY = 0;
alwaysLowered = false;
}
</SCRIPT>
<A HREF="javascript:onClick=Minimize()">Minimize</A>
<A HREF="javascript:onClick=Maximize()">Maximize</A>
<html>
<head>
<title>Maximize Your Potential</title>
<script>
function maximize() {
window.moveTo(0, 0);
window.resizeTo(screen.width, screen.height);
}
maximize();
</script>
</head>
<body>
<h1 align="center">Maximize Your Potential</h1>
This page is self-maximizing.
</body>
</html>
function openWindowMax(location) {
sizeX = screen.width
sizeY = screen.height-50
var posx = (screen.availWidth-sizeX)/2;
var posy = (screen.availHeight-sizeY)/2;
var windowString = 'toolbar=no,location=no,menubar=no,status=no,resizable=no,directories=no,scrollbars=yes,copyhistory=no,width='+sizeX+',height='+sizeY+',left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
newWindow = window.open(location, "", windowString);
newWindow.moveTo(0,0);
}
Thursday, 26 June 2008
IIS : SMTP Email howto use telnet to test
220 FIC Microsoft ESMT
830 ready at Fri, 2 Dec 2005 09:24:56 +0000 mail Service, Version: 6.0.3790.1
>>HELO me.localdomain
250 FIC Hello [1.1.1.1]
>>mail FROM: example@example2.com
250 2.1.0 example@example2.com....Sender OK
>>RCPT TO: example2@example2.com
250 2.1.5 example2@example2.com
>>DATA
354 Start mail input; end with
>>Just a test
>>.
>>
250 2.6.0
or delivery
>>quit
221 2.0.0 FIC Service closing transmission channel
Monday, 23 June 2008
Javascript: Validate file extension when uploading files
function CheckFileExtension(obj){
val=obj.value.substring(obj.value.length-4,obj.value.length);
if (val!='.jpg'&&val!='.gif'&&val!='.bmp'&&val!='.png'&&val!='.jpeg'&&val!='.JPG'&&val!='.GIF'&&val!='.BMP'&&val!='.PNG'&&val!='.JPEG'){
return false;
}
}
Tuesday, 17 June 2008
ASP: URLDecode
' URL decode to retrieve the original value
Function URLDecode(sConvert)
Dim aSplit
Dim sOutput
Dim I
If IsNull(sConvert) Then
URLDecode = ""
Exit Function
End If
' convert all pluses to spaces
sOutput = REPLACE(sConvert, "+", " ")
' next convert %hexdigits to the character
aSplit = Split(sOutput, "%")
If IsArray(aSplit) Then
sOutput = aSplit(0)
For I = 0 to UBound(aSplit) - 1
sOutput = sOutput & _
Chr("&H" & Left(aSplit(i + 1), 2)) &_
Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
Next
End If
URLDecode = sOutput
End Function
Indexing Service: Setting up indexing service
Introduction
A lot of web sites provide search capabilities, where you can simple type
several words, press "Search" button, and you'll receive a list of pages which
contains these words. It's simple. But how can you implement these features in
your own web application? Yes, you have to use indexing service which will index
your files or web pages. After that you can use full text search
features.
There are a lot of solutions which allow you to provide this functionality in
your application. One of them is Microsoft Indexing Service. It's part of
Windows 2000 and later Windows versions. So, if you provide only Windows
solutions (ASP.NET web application, Windows Forms application, etc.) you have to
see this Microsoft's product.
On of the biggest goal of Indexing Service that it's totally free. You can
use it without any restriction or additional licenses. I think that this is so
big goal, because other indexing products cost a lot of money. If you develop
small or middle project you don't want to pay thousands dollars for full text
search tool.
If you will choose Indexing Service you should remember that it can index
only file system. For example, you can't use it for indexing files which stored
in your database. This is a big minus of Microsoft Indexing Service, but I
believe that you will solve this limitation.
In this manual I'll try to describe you how to install, configure and use
Microsoft Indexing Service. We'll develop simple application which will allow
you to use full text search features for web pages which located on your local
file system.
Installation and configuration Microsoft Indexing Service
If you are using Windows XP or later Windows version, you'll use Microsoft
Indexing Service 3.0. And if you're still using Windows 2000, you'll use
Microsoft Indexing Service 2.0. This service is installed to your machine by
default. But you could disable its installation, when you installed operating
system. You have to check that Indexing Service is installed on your machine. To
do this you go to "Add or Remove Programs" in your Control Panel. Choose
"Add/Remove Windows Components" there. You have to check that "Indexing Service"
is installed. If it isn't installed, install it, please.
Now Microsoft Indexing Service has been installed, and you can configure it.
Please, open "Computer Management" configuration tool. Choose "Services and
Applications", "Indexing Service". In this entry you can manage your Microsoft
Indexing Service.
First of all you should create new catalog in Indexing Service for folder
which will contain indexes. Open context menu for "Indexing Service" and choose
"Catalog" in "New" submenu. You type "Name", choose "Location" and press
"OK".
After that you have to add folders which will be indexed. For this choose
"Directories" entry, open its context menu and choose "Directory" in "New"
submenu. Choose folder with your documents in opened dialog box and press "OK"
button to include selected directory to the index. If you decide to exclude
folder from existing index, please choose "No" for "Include in Index?" parameter
in this dialog window. This parameter is "Yes" by default.
If your Indexing Service is started it will index new catalog. Otherwise you
should start Indexing Service and it will index catalog automatically. You can
create or recreate index folder manually. To do this you should open context
menu for specified folder in existing catalog and choose "Rescan (Full)" or
"Rescan (Incremental)" in "All Tasks" submenu. Of course, your Microsoft
Indexing Service has to be started at this time.
If you choose "Indexing Service" entry in your "Computer Management" you will
see state of the Indexing Service. Sometimes this information can help you if
you have big storage and can't find file there.
There is another important setting of Indexing Service "Indexing Service
Usage". This setting allow you say Indexing Service how often it should update
indexes. For example, if you application use only static storage service have to
update index not so often as if you use dynamic data storage and your data is
updated very often. To configure this parameter you should open context menu for
"Indexing Service" entry and choose "Tune Performance" in "All Tasks"
submenu.
Now you can check index. To do this please choose "Query the Catalog" in your
catalog. You'll see form which allows you search something in your index. First
of all you can test simple full text search. Enter something in query field and
press "Search" button. After that you will see files which contain entered
words. Of course, you can execute more difficult queries using this tool. Choose
"Advanced query" if you want execute some queries. After that you can use
Microsoft Indexing Service queries to take some needed information. This query
language is the same language as SQL, but it contains some syntax
extensions.
Query Microsoft Indexing Service
You can use SQL to query Microsoft Indexing service. But there are several
extensions for Indexing Service's SQL dialect which you have to know.
The most useful command, when you use Microsoft Indexing Service, is SELECT
command. It's clear, because you shouldn't add, delete or update information in
your indexes. You only select query Indexing Service to retrieve some
information about indexed files.Let's see example query:
SELECT Path FROM SCOPE() WHERE FREETEXT(Contents, 'Hello World')<br /></pre><br />
<p>This query returns you all paths to files which contain "Hello World" text.
And it can help me describe you Microsoft Indexing Service's SQL
extensions.</p><br />
<p>First of all let's speak about <em>FROM</em> expression. In this example we
query all data which index contain. <em>SCOPE()</em> function allows you tell
Indexing Service which data you decide to examine. By default, if you don't use
any parameters, it examines all data in your index. This function can optimize
your queries, because it can limit indexes for search. For example, you can use
<em>SCOPE ('"/books"') </em>. At this time you will query only "/books" folder,
not all folders in your index. Query execution speed will be more that if you
would use simple <em>SCOPE()</em> function. For more search limitation you can
use special traversal types. For example, <em>SCOPE ('DEEP TRAVERSAL OF
"/books"') </em>. If you use this expression, Indexing Service will search in
"/books" directory and in all directories beneath them. If you use <em>SHALLOW
TRAVERSAL</em> Microsoft Indexing service will examine only "/books" directory.
For example, <em>SCOPE('SHALLOW TRAVERSAL OF "/books"') </em>.</p><br />
<p><em>WHERE</em> expression is the same as in SQL standard, but there are few
extensions for it too. There are Comparison Predicates. You can see they in this
table:</p><br />
<table border="1" cellspacing="0" width="60%"><br />
<tbody>
<tr style="background-color: silver;"><br />
<td>Operator</td><br />
<td>Symbol</td><br />
<td>Example</td><br /></tr><br />
<tr><br />
<td>Equals</td><br />
<td>=</td><br />
<td><em>WHERE DocAuthor = 'John Doe'</em></td><br /></tr><br />
<tr><br />
<td>Not equals</td><br />
<td>!= or <></td><br />
<td><em>WHERE DocTitle != 'Finance'</em></td><br /></tr><br />
<tr><br />
<td>Less than</td><br />
<td><</td><br />
<td><em>WHERE WordCount < 1000</em></td><br /></tr><br />
<tr><br />
<td>Greater than</td><br />
<td>></td><br />
<td><em>WHERE WordCount > 500</em></td><br /></tr><br />
<tr><br />
<td>Less than or equal to</td><br />
<td><=</td><br />
<td><em>WHERE WordCount <= 500</em></td><br /></tr><br />
<tr><br />
<td>Greater than or equal to</td><br />
<td>>=</td><br />
<td><em>WHERE WordCount >= 500</em></td><br /></tr><br /></tbody></table><br />
<p>You also can use Boolean operators which are evaluated using following
rules:</p><br />
<ul><br /><li><em>NOT</em> is evaluated before <em>AND</em>. <em>NOT</em> can only occur
after <em>AND</em> (as in <em>AND NOT</em>; the combination <em>OR NOT</em> is
not allowed). <br />
</li><li><em>AND</em> is evaluated before <em>OR</em>. <br />
</li><li><em>AND</em> expressions are associative and can be applied in any order.
For example, <em>A AND B AND C</em>, is the same as <em>(A AND B) AND C</em>,
which is the same as <em>A AND (B AND C) </em>. <br />
</li><li><em>OR</em> expressions are associative and can be applied in any order.
<br /></li></ul><br />
<p>There is LIKE predicate too. But there are several predicates which extend
SQL language:</p><br />
<ul><br /><li><em>ARRAY</em>. This predicate performs comparisons of two arrays using
logical operators. For example, <em>... WHERE username = SOME ARRAY ['Admin' ,
'root'] </em>. This example returns you files which contain username parameter
and this parameter is 'Admin' or 'root'. <br />
</li><li><em>CONTAINS</em>. This predicate using for full text search. For example,
<em> WHERE CONTAINS(country,'"USA" OR "Russia"') </em>. This example return
files, which contains country property and this property is "USA" or "Russia".
<br />
</li><li><em>FREETEXT</em>. This predicate allows you find words and phrases in
indexed files. It's better to use it if you need find anything in the content of
your files. For example, <em> WHERE CONTAINS(Contents,'Hello World !!!') </em>.
<br />
</li><li><em>MATHCES</em>. Predicate performs queries using regular-expression
pattern. It's more powerful than <em>LIKE</em> predicate. For example, <em>
WHERE MATCHES (Contents, '|(USA|)|{1|}' ) </em>. This example matches any string
in which exactly one instance of the pattern "BUSA" occur. <br /></li></ul><br />
<p>For additional information you have to see <a href="http://msdn2.microsoft.com/en-us/library/aa163263.aspx">Indexing Service
Articles on MSDN web site</a>.</p><br />
<p>Now you know how to prepare queries to Microsoft Indexing Service, but you
still need take list of properties, which can be used in your queries. There are
a lot of default properties for each index, which you can find in following
table.</p><br />
<table border="1" cellspacing="0" width="60%"><br />
<tbody>
<tr style="background-color: silver;"><br />
<td>Friendly Name</td><br />
<td>Datatype</td><br />
<td>Property</td><br /></tr><br />
<tr><br />
<td>A_HRef</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML HREF. This property name was created for Microsoft® Site Server
and corresponds with the Indexing Service property name HtmlHRef. Can be queried
but not retrieved.</td><br /></tr><br />
<tr><br />
<td>Access</td><br />
<td>VT_FILETIME</td><br />
<td>Last time file was accessed.</td><br /></tr><br />
<tr><br />
<td>All</td><br />
<td>(not applicable)</td><br />
<td>Searches every property for a string. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>AllocSize</td><br />
<td>DBTYPE_I8</td><br />
<td>Size of disk allocation for file.</td><br /></tr><br />
<tr><br />
<td>Attrib</td><br />
<td>DBTYPE_UI4</td><br />
<td>File attributes. Documented in Win32 SDK.</td><br /></tr><br />
<tr><br />
<td>ClassId</td><br />
<td>DBTYPE_GUID</td><br />
<td>Class ID of object, for example, WordPerfect, Word, and so
on.</td><br /></tr><br />
<tr><br />
<td>Characterization</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Characterization, or abstract, of document. Computed by Indexing
Service.</td><br /></tr><br />
<tr><br />
<td>Contents</td><br />
<td>(not applicable)</td><br />
<td>Main contents of file. Can be queried but not retrieved.</td><br /></tr><br />
<tr><br />
<td>Create</td><br />
<td>VT_FILETIME</td><br />
<td>Time file was created.</td><br /></tr><br />
<tr><br />
<td>Directory</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Physical path to the file, not including the file name.</td><br /></tr><br />
<tr><br />
<td>DocAppName</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Name of application that created the file.</td><br /></tr><br />
<tr><br />
<td>DocAuthor</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Author of document.</td><br /></tr><br />
<tr><br />
<td>DocByteCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of bytes in a document.</td><br /></tr><br />
<tr><br />
<td>DocCategory</td><br />
<td>DBTYPE_STR | DBTYPE_BYREF</td><br />
<td>Type of document such as a memo, schedule, or whitepaper.</td><br /></tr><br />
<tr><br />
<td>DocCharCount</td><br />
<td>DBTYPE_I4</td><br />
<td>Number of characters in document.</td><br /></tr><br />
<tr><br />
<td>DocComments</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Comments about document.</td><br /></tr><br />
<tr><br />
<td>DocCompany</td><br />
<td>DBTYPE_STR | DBTYPE_BYREF</td><br />
<td>Name of the company for which the document was written.</td><br /></tr><br />
<tr><br />
<td>DocCreatedTm</td><br />
<td>VT_FILETIME</td><br />
<td>Time document was created.</td><br /></tr><br />
<tr><br />
<td>DocEditTime</td><br />
<td>VT_FILETIME</td><br />
<td>Total time spent editing document.</td><br /></tr><br />
<tr><br />
<td>DocHiddenCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of hidden slides in a Microsoft® PowerPoint
document.</td><br /></tr><br />
<tr><br />
<td>DocKeywords</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Document keywords.</td><br /></tr><br />
<tr><br />
<td>DocLastAuthor</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Most recent user who edited document.</td><br /></tr><br />
<tr><br />
<td>DocLastPrinted</td><br />
<td>VT_FILETIME</td><br />
<td>Time document was last printed.</td><br /></tr><br />
<tr><br />
<td>DocLastSavedTm</td><br />
<td>VT_FILETIME</td><br />
<td>Time document was last saved.</td><br /></tr><br />
<tr><br />
<td>DocLineCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of lines contained in a document.</td><br /></tr><br />
<tr><br />
<td>DocManager</td><br />
<td>DBTYPE_STR | DBTYPE_BYREF</td><br />
<td>Name of the manager of the document's author.</td><br /></tr><br />
<tr><br />
<td>DocNoteCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of pages with notes in a PowerPoint document.</td><br /></tr><br />
<tr><br />
<td>DocPageCount</td><br />
<td>DBTYPE_I4</td><br />
<td>Number of pages in document.</td><br /></tr><br />
<tr><br />
<td>DocParaCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of paragraphs in a document.</td><br /></tr><br />
<tr><br />
<td>DocPartTitles</td><br />
<td>DBTYPE_STR | DBTYPE_VECTOR</td><br />
<td>Names of document parts. For example, in Excel part titles are the names of
spread sheets, in PowerPoint slide titles, and in Word for Windows the names of
the documents in the master document.</td><br /></tr><br />
<tr><br />
<td>DocPresentationTarget</td><br />
<td>DBTYPE_STR | DBTYPE_BYREF</td><br />
<td>Target format (35mm, printer, video, and so on) for a presentation in
PowerPoint.</td><br /></tr><br />
<tr><br />
<td>DocRevNumber</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Current version number of document.</td><br /></tr><br />
<tr><br />
<td>DocSlideCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of slides in a PowerPoint document.</td><br /></tr><br />
<tr><br />
<td>DocSubject</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Subject of document.</td><br /></tr><br />
<tr><br />
<td>DocTemplate</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Name of template for document.</td><br /></tr><br />
<tr><br />
<td>DocTitle</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Title of document.</td><br /></tr><br />
<tr><br />
<td>DocWordCount</td><br />
<td>DBTYPE_I4</td><br />
<td>Number of words in document.</td><br /></tr><br />
<tr><br />
<td>FileIndex</td><br />
<td>DBTYPE_I8</td><br />
<td>Unique ID of file.</td><br /></tr><br />
<tr><br />
<td>FileName</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Name of file.</td><br /></tr><br />
<tr><br />
<td>HitCount</td><br />
<td>DBTYPE_I4</td><br />
<td>Number of hits (words matching query) in file.</td><br /></tr><br />
<tr><br />
<td>HtmlHRef</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML HREF. Can be queried but not retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading1</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H1. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading2</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H2. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading3</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H3. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading4</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H4. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading5</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H5. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading6</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H6. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>Img_Alt</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Alternate text for <IMG> tags. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>Path</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Full physical path to file, including file name.</td><br /></tr><br />
<tr><br />
<td>Rank</td><br />
<td>DBTYPE_I4</td><br />
<td>Rank of row. Ranges from 0 to 1000. Larger numbers indicate better
matches.</td><br /></tr><br />
<tr><br />
<td>RankVector</td><br />
<td>DBTYPE_I4 | DBTYPE_VECTOR</td><br />
<td>Ranks of individual components of a vector query.</td><br /></tr><br />
<tr><br />
<td>ShortFileName</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Short (8.3) file name.</td><br /></tr><br />
<tr><br />
<td>Size</td><br />
<td>DBTYPE_I8</td><br />
<td>Size of file, in bytes.</td><br /></tr><br />
<tr><br />
<td>USN</td><br />
<td>DBTYPE_I8</td><br />
<td>Update Sequence Number. NTFS drives only.</td><br /></tr><br />
<tr><br />
<td>VPath</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Full virtual path to file, including file name. If more than one possible
path, then the best match for the specific query is chosen.</td><br /></tr><br />
<tr><br />
<td>WorkId</td><br />
<td>DBTYPE_I4</td><br />
<td>Internal ID for file. Used within Indexing Service.</td><br /></tr><br />
<tr><br />
<td>Write</td><br />
<td>VT_FILETIME</td><br />
<td>Last time file was written.</td><br /></tr><br /></tbody></table><br />
<p>As you can see, there are a lot indexed properties for each file, but
sometime you want to extend this list.</p><br /><br />
<h2>How to add new properties for indexed file</h2><br /><br />
<p>First of all I have to say, that this feature works only for web pages,
because it is base on HTML <em><meta></em> tag.</p><br />
<p>Now you have several indexed web pages and you want to add several special
properties for them. For example, you will add "country" and "city" properties.
First of all you should add <em><meta></em> tags to all files which will
contain these new properties:</p><br /><pre lang="html"><meta name="country" content="Russia" /><br /><br /><meta name="city" content="Moscow" /><br /><br /></pre><br />
<p>After these changes you have to restart Indexing Service. Now you can open
entry "Properties" and see that right now Microsoft Indexing Service knows about
your special parameters for files. But still you can't use these new parameters
in queries.</p><br />
<p>Select "Properties" node of your catalog and choose property, which you added
to the files using <em><meta></em> tag. Double click on this property.
Switch on "Cached" checkbox and choose data type for new property in opened
dialog box.</p><br />
<p><img alt="Microsoft Indexing Service Installation" src="http://file.cscoding.com/file/8%5C4017%5CMicrosoft_Indexing_Service_HOW_TO5.jpg" /></p><br />
<p>After that you should create Column Definition File which contains
information about your new added parameters. File could have ".idq" extension,
but this isn't important. Column Definition File uses following format:</p><br /><pre>[Names]<br />Propertyname( Data type ) = GUID [<span class="cpp-string">"Name"</span> | Property ID] <br /></pre><br />
<p>Data type parameter is optional. If you don't define it, Microsoft Indexing
Service will take data type from parameters definition for your catalog.</p><br />
<p>For my example it contains this:</p><br /><pre>[Names]<br />country = d1b5d3f0-c0b3-11cf-9a92-00a0c908dbf1 <span class="cpp-string">"country"</span><br />city = d1b5d3f0-c0b3-11cf-9a92-00a0c908dbf1 <span class="cpp-string">"city"</span><br /></pre><br />
<p>All these data you can take from dialog box for properties
configuration.</p><br />
<p>After Columns Definition File is created, information about this file has to
be added to Indexing Service registry settings. Add String entry named
<em>"DefaultColumnFile" </em>to the registry key
<em>"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ContentIndexCommon"</em>.
<em>"DefaultColumnFile" </em>should contain full path to your Columns Definition
File.</p><br />
<p>Restart Microsoft Indexing Service. After that run full rescan of your
indexed folder. Now you are able to use these new parameters in your
queries.</p><br /><br />
<h2>Using Microsoft Indexing Service in .NET applications</h2><br /><br />
<p>Microsoft Indexing Service exposes itself to the developer as OLE DB
provider. Its name is MSIDXS. You can use ADO.NET for query you Indexing
Service. To do this you have to create new System.Data.OleDb.OleDbConnection
object using this sample connection string:</p><br /><pre>Provider= <span class="cpp-string">"MSIDXS"</span>;Data Source=<span class="cpp-string">"Documents"</span><br /></pre><br />
<p>In Data Source parameter you should use name of your catalog in indexing
Service.</p><br />
<p>Let's create sample code which will query Indexing Service for few words in
files' contents. <br />In this sample there is queryString variable. It is an
instance of SearchParameters structure. This structure contains information
about Data Source and Query string. Here is the definition of this
structure:</p><br /><pre lang="cs">struct SearchParameters<br />{<br /> private string storage;<br /><br /> public string Storage<br /> {<br /> get { return storage; }<br /> set { storage = value; }<br /> }<br /><br /> private string query;<br /><br /> public string Query<br /> {<br /> get { return query; }<br /> set { query = value; }<br /> }<br />}<br /></pre><br />
<p>First of all you create new OleDbConnection object:</p><br /><pre lang="cs">string connectionString = string.Format(<span class="cpp-string">"Provider= \"</span>MSIDXS\<span class="cpp-string">";Data Source=\"</span>{0}\<span class="cpp-string">";"</span>, queryString.Storage);<br />OleDbConnection connection = new OleDbConnection(connectionString);<br /></pre><br />
<p>After that you create new OleDbCommand which associated with this
connection:</p><br /><pre lang="cs">string query = string.Format(@<span class="cpp-string">"SELECT Path FROM scope() WHERE FREETEXT(Contents, '{0}')"</span>, queryString.Query);<br />OleDbCommand command = new OleDbCommand(query, connection); <br /></pre><br />
<p>Note that MSIDXS provider doesn't support commands with parameters. This is
bad. I hope that Microsoft will fix this issue in next version of Microsoft
Indexing Service.</p><br />
<p>Now you are able to execute this command and retrieve list of files which
contain selected text:</p><br /><pre lang="cs">connection.Open();<br /><br />ArrayList result = new ArrayList();<br /><br />OleDbDataReader reader = command.ExecuteReader();<br />while (reader.Read())<br />{<br /> result.Add(reader.GetString(0));<br />}<br /><br />connection.Close();<br />
In this code checking returned value to NULL is not necessary, because
Indexing Service always returns path to found file.
Summary
Microsoft Indexing Service is totally free and powerful product which
included to Windows 2000 or later Windows versions. But it's simple very much.
You can easy create indexes. You can also query these indexes using OLE DB data
provider. If you are working with Microsoft .NET it will easy very much. In this
article I tried to describe you how to install, configure and query. I also
recommend you see my example, which I attached to this manual. This example will
show you how to use full text search features. I hope that this article will
help you to start using Indexing Service.