tag:blogger.com,1999:blog-94736302009-02-21T13:14:28.888+08:00bitScrap... the bits and pieces of 'code adventure' ... .i.http://www.blogger.com/profile/03817226297503474535noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-9473630.post-66883767198045600482007-01-04T02:14:00.000+08:002007-01-04T02:39:46.667+08:00SMS Character Set & Sending special charctersLike they say necessity is the mother of invention, today, i was forced to understand the GSM SMS standards. I was trying to send a range of special characters in my message. After hours of grueling work and debugging, I realized only a handful of special characters are allowed.<br /><br />So, I dug up the standard for SMS - <a href="http://www.csoft.co.uk/sms/character_sets/gsm.htm">GSM 03.38</a>. This corresponds to an ISO character set called <a href="http://en.wikipedia.org/wiki/ISO_8859-1">ISO 8859-1</a>, which is extremely similar to Microsoft's <a href="http://en.wikipedia.org/wiki/Windows-1252">Windows-1252</a> character set.<br /><br /><span style="font-weight: bold;font-size:130%;" >Sending a message through Kannel</span><br /><br />I was using <a href="http://kannel.org/">Kannel, the open source SMS Gateway software</a> to send out the SMSs. Now, Kannel accepts all <a href="http://kannel.org/download/1.4.1/userguide-1.4.1/userguide.html#AEN4201">messages posted over HTTP only in the Windows-1252 encoding</a>.<br /><br />So if you're using ASP.NET, you must URL encode your text using the <a href="http://en.wikipedia.org/wiki/Windows-1252">Windows-1252</a> encoding before making the HTTP request to Kannel. Otherwise, the message received on the device on the other end will look like gibberish.<br /><br /><span style="font-weight: bold;font-size:130%;" >Receiving a message through Kannel (<span style="font-style: italic;">Kannel Post</span>)</span><br /><br />When Kannel receives a message, It tries to see if the character encoding matches <a href="http://en.wikipedia.org/wiki/ISO_8859-1">ISO 8859-1</a>. If it decoding the message fails using the 8-bit character set, it tries 16-bit Unicode Big Endian (<a href="http://en.wikipedia.org/wiki/UTF-16BE">UTF-16BE</a>).<br /><br />If it is configured to post the message to a designated URL, it will first URL Encode the received text using using the determined formatting, and then supply the character set in the URL as a query string parameter.<br /><br />If you want to receive your messages in <a href="http://en.wikipedia.org/wiki/ISO_8859-1">ISO 8859-1</a>, it is important to stick to the characters defined in the set. Failing to do so will call your Post URL with Unicode encoded text.<br /><br /><span style="font-size:130%;"><span style="font-weight: bold;">Resources / References:</span></span><br /><ul><li><a href="http://www.kannel.org/">Kannel: Open Source WAP and SMS gateway</a></li><li>GSM 03.38 Character Set: <a href="http://www.csoft.co.uk/sms/character_sets/gsm.htm">Ref 1</a>, <a href="http://usa.bulksms.com/docs/eapi/submission/character_encoding/">Ref 2</a>, <a href="http://www.dreamfabric.com/sms/default_alphabet.html">ISO 8859-1 Mapping</a><br /> </li><li><a href="http://en.wikipedia.org/wiki/ISO_8859-1">ISO-8859-1 Encoding</a>, <a href="http://en.wikipedia.org/wiki/Windows-1252">Windows 1252 Encoding</a><br /></li></ul><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9473630-6688376719804560048?l=bitscrap.indradeep.com%2Findex.html'/></div>.i.http://www.blogger.com/profile/03817226297503474535noreply@blogger.com1tag:blogger.com,1999:blog-9473630.post-1152042369285884112006-07-05T03:33:00.000+08:002006-07-26T18:28:38.396+08:00How to hard reset a Microsoft Windows Mobile SmartphoneWell, I was trying to develop an applicaion to start on boot. When I changed the registry wrongly, the phone wouldnt' boot. The only way out was to hard reset the phone.<br /><br />Officially, O2, a brand of HTC claims that hard reset can not be done by the end users. There is however a way to hard reset the Xphone / Xphone II / C500 /smt5600 / SP3 / SP3i / SP5 / SP5m.<br /><br /><span style="font-weight: bold;">Following are the hard reset instructions:</span><br /><ol><li>Turn off the phone. (If the power button fails to respon, take the battery out.)<br /><br /></li><li>Press the two soft keys while the phone is off. (I find it easy to set the phone on the table with the power button pointing towards the right. Then use the index and the middle finger of the left hand to press the soft keys simultaneously.<br /><br /></li><li>Press the power button for 1.5 seconds. (Timing is sensitive. You make take several tries to get it right. ) Essentially, the picture is that the phone is off, you are holding the two soft keys, and then you press the power button for 1.5 seconds and release it.<br /><br /></li><li>Press '0' when instructed. (When the phone will power up, and the screen will display an instruction to <span style="font-style: italic;">press '0' restore factory defaults, other keys to quit.</span>)<br /><br /></li><li>Wait while the phone hard resets itslef.</li></ol><br /><span style="font-weight: bold;">References</span>:<br /><ul><li><a href="http://www.modaco.com/index.php?showtopic=198362">Modaco Forum : Hard reset your smartphone</a></li><li><a href="http://www.ppcsg.com/lofiversion/index.php/t50669.html">PPCSG Forum</a></li><li><a href="http://www.pocketpcaddict.com/forums/pocket-pc-tips/14964-how-hard-reset-your-pocket-pc.html">Pocket PC Addict Foorum</a><br /></li></ul><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9473630-115204236928588411?l=bitscrap.indradeep.com%2Findex.html'/></div>.i.http://www.blogger.com/profile/03817226297503474535noreply@blogger.com1tag:blogger.com,1999:blog-9473630.post-1151304829570536082006-06-26T12:31:00.000+08:002006-06-29T18:26:55.936+08:00Application unlocking a Windows Mobile 2003 / 5.0 SmartphoneMost Windows Mobile Smartphone devices by default are configured to be Application Locked. That is a rather irritating limitation for people like myself who develop on Windows Mobile devices quite extensively.<br /><br />Since most Windows Mobile Smartphones are difficult to hard reset (especially mine - <a href="http://www.seeo2.com/product/XphoneII/template/XphoneIIProductInfo.vm">O2 Xphone II</a>), a malicious app can make you run down to the service center to get your phone hard reset! Microsoft has built in the Application Lock for smartphone, to protect the device from malicious applications accessing the core windows <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/wce51conPrivelegedAPIs.asp">privileged APIs</a>.<br /><br />What this means is that if you want to have functionalities in your application which interfaces to core phone functionalities, such as SMS message interception, keypad hooking, etc, you need to have privileged access (on locked devices) for your application. An application has privileged access to the core APIs if it is code signed by certain dedicated authorities:<br /><ul><li><a href="http://www.geotrust.com/products/signing_services/code_signing_windows_mobile.asp">GeoTrust</a></li><li><a href="http://www.verisign.com/products-services/security-services/code-signing/microsoft-smartphone-code-signing/index.html">VeriSign</a></li></ul>If you have a locked phone, and you want to run an application which is not code-signed, you must first unlock the phone. After digging through piles of segmented information, this is how I went about unlocking my application.<br /><br />Download the following (<a href="http://bitscrap.indradeep.com/data/Application_Unlock_Smartphone.zip">bundle</a>):<br /><ul><li><a href="http://www.modaco.com/index.php?act=Attach&type=post&id=17041">Registry Editor (HTC Signed)</a></li><li><a href="http://www.smartphone.net/software_detail.asp?id=951">Windows Mobile Smartphone Lock Checker</a></li><li><a href="http://www.modaco.com/index.php?act=Attach&type=post&id=12151">RAPI Config & ResetSecurity.xml</a></li></ul>Once you have downloaded the necessary components, perform the following.<br /><br /><span style="font-weight: bold;">Installation</span><br /><ul><li>Connect your device to the PC using <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4c254e3f-79d5-4012-8793-d2d180a42dfa&DisplayLang=en">ActiveSync</a>.<br /></li><li>Copy the registry editor, and lock checker to the phone memory through active sync file transfer<br /></li></ul><span style="font-weight: bold;">Check for application lock<br /></span><ul><li>Use the device file explorer to navigate to the directory to which you had copied the lock checker.</li><li>Tap the file to execute it.</li><li>The application will tell you if you phone is locked. If your phone is unlocked, you can skip the rest of this article. Otherwise, go on to the next step.<br /></li></ul><span style="font-weight: bold;"><br />Registry Updates<br /></span><br />Change the value of the following registry keys in [<code>HKEY_LOCAL_MACHINE \ Security \ Policies \ Policies</code>]:<br /><ul><li>Key: <code>00001001</code>, Value: <code>1</code></li><li>Key: <code>00001005</code>, Value:<code>40</code></li><li>Key: <code>00001017</code>, Value: <code>144</code></li></ul><span style="font-weight: bold;">Running the Security Unlock<br /></span><ul><li>Open command prompt<br /></li><li>Go to the path which contains <code>RapiConfig.exe</code> and <code>ResetSecurity.xml</code></li><li>Key in: <code>rapiconfig /p resetsecurity.xml</code></li><li>Hit Enter</li></ul><span style="font-weight: bold;">Verify the Application Lock</span><br /><ul><li>Use the device file explorer to navigate to the directory to which you had copied the lock checker.</li><li>Tap the file to execute it.</li><li>The application should now say that your device is unlocked.<br /></li></ul><br /><span style="font-weight: bold;">Bibiliography:</span><br /><ul><li>Modaco Forum: <a href="http://www.modaco.com/INFO_Decert_SIM_Unlock_C550-t222786.html">(Registry Editor Signed by HTC)</a>, <a href="http://www.modaco.com/Motorola_MPx220_and_Audiovox_SMT6500_app_lockedl-t116301-s15.html">(App unlocking guide)</a></li><li>Usenet: microsoft.public.pocketpc.activesync <a href="http://groups.google.nl/group/microsoft.public.pocketpc.activesync/browse_thread/thread/e2ef70da6a8d3215/a6aef6754139640b?lnk=st&q=%22Unlocking+Windows+Mobile+5+Smartphones%22&amp;amp;amp;amp;amp;amp;amp;rnum=1&hl=nl#a6aef6754139640b">(Guide to Certificate/Application Unlocking Windows Mobile 5 Smartphones)</a></li><li>MSDN: <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppcgen/html/smartphone_security.asp">A Practical Guide to the Smartphone Application Security and Code Signing Model for Developers</a> (thanks <a href="http://ivarun.com">Varun </a>for the link).<br /></li></ul><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9473630-115130482957053608?l=bitscrap.indradeep.com%2Findex.html'/></div>.i.http://www.blogger.com/profile/03817226297503474535noreply@blogger.com2tag:blogger.com,1999:blog-9473630.post-1145589527248711882006-04-21T11:00:00.000+08:002006-04-21T11:22:59.920+08:00Wondering how to hibernate when you have 1 GB + RAM?And then you try to hibernate your laptop. The screen blackens out as if it is going into hibernation mode, but then it comes right back and windows throws you the message :<br /><blockquote style="font-style: italic;">Insufficient system resources exist to complete the API</blockquote>Have you got more than 1 GB or RAM? Well then, you've got a problem that you need a fix for. Microsoft Windows XP has a documented history of hibernation problem for computers that have more than 1 GB of main memory.<br /><br />I recently got a Dell Inspiron 6400 laptop with 2 GB RAM, and somehow, from time to time, I couldn't hibernate. After doing some research on google, I stumbled upon the two articles on the Microsoft Knowledge Base:<br /><ul><li><a style="font-weight: bold;" href="http://support.microsoft.com/?kbid=330909">Article 330909</a> : Talks about the problem for the base Windows XP Professional, Tablet and Home editions. It provides a hotfix that can be downloaded and installed to rectify this problem. Unfortunately, this may not applicable to most of us since we are likely to be running service pack version of Windows XP.<br /><br /></li><li><a style="font-weight: bold;" href="http://support.microsoft.com/kb/909095/">Article 909095</a> : Addresses the error messgae that is thrown when we try to hibernate. This applies to the latest releases of Microsoft Windows XP editions (SP2, Tablet 2005 and Media Center 2005). However, obtaining the hotfix for this one is not so straight forward.</li></ul>The Knowledge Base Article 909095 stated clearly that the hotfix must be obtained from Microsoft support. So, I tried to find out how the support could be contacted, but it seems that there is a service charge for getting support.<br /><br />The web site clearly states that the vendor could be contacted for this fix. So, I wrote a service request to Dell to get me the fix from Microsoft.<br /><br />After juggling a few emails back and forth, the service person called me back saying that I must speak with Microsoft myself to obtain the fix. He joined me to a conference call with Microsoft Asia Pacific Support.<br /><br />The entire process of the questionaire took about 20 minutes. But by the end of it, I had the fix in my mailbox. When I asked them why I must go through all this to get a simple fix, <span style="font-weight: bold;">the support personnel explained that the fix is meant only for this certain purpose. If it is installed on PCs which don't have this specific problem, then, some other things may stop functioning</span>!<br /><br />The process does seem rather lengthy, but I'm extremely impressed with the quality of support Dell and Microsoft are providing. The problem has not surfaced since I installed the hotfix. Lets find out whether what I got in my mailbox yesterday was a proper cure!<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9473630-114558952724871188?l=bitscrap.indradeep.com%2Findex.html'/></div>.i.http://www.blogger.com/profile/03817226297503474535noreply@blogger.com1tag:blogger.com,1999:blog-9473630.post-1127724380628605352005-09-26T16:22:00.000+08:002005-09-26T16:46:50.420+08:00Happy surfing with Opera & Proxomitron<p class="MsoNormal"><span lang="EN-GB">Well... I have been a die-hard fan of <a href="http://www.mozilla.org/products/firefox/">Firefox</a>, and its plug-ins. I still am, but I must say, getting back to <a href="http://opera.com/">Opera</a>, years after I tried it out for the first time, has been a rather pleasant experience.<br /><br />The particular things I liked the most about Firefox were the tabbed browsing, and the Adblock plug-in. They made browsing so much nicer by cutting the Ads & other tertiary items from the different pages. People have posted a lot of Adblock hosts and URL lists, and so, it was relatively easy to have an ad free experience online.<br /><br />Nevertheless, I tried out Opera, just for the heck of it mostly. The Opera 8 interface I must say is fantastic. The browser loads fast itself, and it renders the pages rather nicely. The <a href="http://opera.com/features/">features </a>which I liked the most are:<o:p></o:p></span></p> <ul type="disc"> <li class="MsoNormal" style=""><span lang="EN-GB">Subscription to RSS Feeds<o:p></o:p></span></li><li class="MsoNormal" style=""><span lang="EN-GB">Saving sessions, and restoring them later<o:p></o:p></span></li><li class="MsoNormal" style=""><span lang="EN-GB">Zooming into a page, which scales entire page - including graphics and layout<o:p></o:p></span></li><li class="MsoNormal" style=""><span lang="EN-GB">Mouse gestures<o:p></o:p></span></li> </ul> <p class="MsoNormal"><span lang="EN-GB">They made the whole browsing experience simply richer.<br /><br />In spite of the cool features, what I missed the most from firefox to opera was the Adbock. Wherever I went, swarming ads took aeons to download, and once they downloaded, they distracted the reading.<br /><br />So, after some googling, I came across <a href="http://www.proxomitron.info/">Proxomitron</a>, a personal ad-blocking proxy. The cool thing about Proxomitron is that it is absolutely transparent to all browsers / applications that need to use it.<br /><br />I could use it from IE, Firefox, Opera, or any other application which allows HTTP requests to go through a proxy.<br /><br />Among its <a href="http://www.proxomitron.info/45/help/Intro.html">features</a>, Proxomitron has a set of rules built in which checks the HTTP header, and the contents for certain attributes. The attributes which can be set, or used for detection is rather extensive (daunting for first timers like me), but overall, it is quite easy to set up.<br /><br />Once I configured Proxomitron on my computer, there was no truning back. It cut out almost ALL ads, and worked way better than Adblock. The built in pattern recognizers were much more efficient on Proxomitron, than they were in Adblock.<br /><br />With the ads, being cut out at the request itself, the pages loaded much faster than they would have using adblock. It kept most of the ad placeholders intact, with small messages in red linking to the ads, so that I can go to the ad if I had wanted to.<br /><br />The rendering kept the layout of the page intact, and I didn't have to loose sleep over a completely re-organized page.<br /><br />My recommendation: Try it out. Its worth it!</span></p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9473630-112772438062860535?l=bitscrap.indradeep.com%2Findex.html'/></div>.i.http://www.blogger.com/profile/03817226297503474535noreply@blogger.com0tag:blogger.com,1999:blog-9473630.post-1126262261547857042005-09-09T18:13:00.000+08:002005-09-12T10:33:05.260+08:00Programming for Windows Mobile 2003 SmartphoneOne of the primary reasons why I wanted to buy a Windows Smartphone was because it came with the .NET Compact Framework, and I could write programs for it!<br /><br />Having worked with a Windows PDA a couple of times, it wasn't too difficult to get started. All you need are:<br /><ul> <li><a href="http://msdn.microsoft.com/vstudio/">Microsoft Visual Studio .NET</a><br /></li> <li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=A6C4F799-EC5C-427C-807C-4C0F96765A81&displaylang=en">Windows Mobile SDK</a></li> <li>A Windows <a href="http://en.wikipedia.org/wiki/Smartphone">Smartphone</a>, or a smartphone emulator!</li> </ul> From the Visual Studio, you can create a <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_evtuv/html/etoriUvnameStartPage.asp">Smart Device Application</a> projct, and from there on, it is as simple as programming for windows forms.<br /><br />When you run the application, you can debug it using the emulator, or the phone itself. In my first attemt at programming for smartphone, I created a notepad application called iNote.<br /><br /><div style="text-align: center;"><span style="font-weight: bold;font-family:verdana;font-size:100%;" ><span style="font-size:85%;"><br /><img src="http://bitscrap.indradeep.com/images/iNote.jpg" alt="iNote Application" /><br />iNote: Sample Windows Smartphone Notepad Application<br /></span><br /></span><span style=";font-family:trebuchet ms;font-size:100%;" ><span style="font-weight: bold;">Download: <a href="http://bitscrap.indradeep.com/data/iNote.exe">Executable</a>| <a href="http://bitscrap.indradeep.com/data/Notepad.zip">Source Code in C#.NET</a></span></span><span style="font-weight: bold;font-family:verdana;font-size:100%;" ><br /></span></div> <span style="font-size:100%;"><br /><br />References:<br /></span> <ol> <li><span style="font-size:100%;"><a href="http://sitescooper.org/tao_regexps.html" target="_blank"></a><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppcgen/html/smartphone_2003.asp">MSDN: Develop for Windows Mobile-based Smartphones Using the .NET Compact Framework</a><br /> </span></li><li><span style="font-size:100%;"><a href="http://www.regular-expressions.info/" target="_blank"></a><a href="http://weblogs.asp.net/nleghari/articles/smartphone.aspx">Microsoft Smartphone Programming</a><br /></span></li><li><span style="font-size:100%;"><a href="http://gnosis.cx/publish/programming/regular_expressions.html" target="_blank"></a><a href="http://www.oreillynet.com/pub/a/wireless/2004/01/07/smartphone.html">O'Reilly: Design Considerations for Microsoft Smartphone Applications</a></span></li> <li><span style="font-size:100%;"><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win_ce/html/pwc_ProgrammingtheSmartphone.asp">MSDN: Programming the Smartphone</a></span></li> <li><span style="font-size:100%;"><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win_ce/html/pwc_TheNETCompactFramework.asp">MSDN: The .NET Compact Framework</a><br /> </span></li> </ol><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9473630-112626226154785704?l=bitscrap.indradeep.com%2Findex.html'/></div>.i.http://www.blogger.com/profile/03817226297503474535noreply@blogger.com0tag:blogger.com,1999:blog-9473630.post-1126258887222313002005-09-09T16:19:00.000+08:002005-09-09T17:59:59.110+08:00Javascript Frame finderWhat do you do when a page in a child frame is told to load a document in another frame? Rather straight forward I'd assume. You just make a hyperlink to that page, and set the target to the destination frame.<br /><br />Now, the situation becomes a little more complex if you are using javascript. Especially if the script is being automatically triggered! Since in the javascript DOM, the frames are modeled in a tree strucutre, one can do an exhaustive search of all frames in the tree.<br /><br />In the process of writing a function to traverse the entire tree to find a frame by its name, I realized that recurision is not possilbe in Javascript! (correct me if I'm wrong here :)<br /><br />The script for searching a frame in a document is here :<br /><br /><pre><blockquote>var stack = new Array(100);<br /><br /><code>function FindFrame ( frameName )<br />{<br /> var frame;<br /> stack.push(top);<br /><br /> while ((frame = stack.pop()) != null && complete == false)<br /> {<br /> // Make sure that the list of child frames is not empty<br /><br /> var frm = frame.frames;<br /> if (frm == null || frm.length <= 0) return;<br /><br /> for (i=0; i < rm.length; i++)<br /> {<br /> if (frm[i].name = frameName)<br /> return frm[i];<br /> <br /> stack.push(frm[i]);<br /> }<br /> }<br /> return null;<br />}</code></blockquote></pre><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9473630-112625888722231300?l=bitscrap.indradeep.com%2Findex.html'/></div>.i.http://www.blogger.com/profile/03817226297503474535noreply@blogger.com1tag:blogger.com,1999:blog-9473630.post-1126248972479098792005-09-09T14:51:00.000+08:002005-09-09T16:10:04.743+08:00Reflect MS SQL Server Database Schema using SQLCan a program learn the structure of the database? I guess thats what the code generators are all about. They use templates to automate the writing of redundant code.<br /><br />Well... I decided to come up with something along the lines, but the first step was to learn the schema of the database that I was working with. After doing some research, I found out that there are a couple of ways of reading a database schema from a MS SQL Server database:<br /><ol> <li>the <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ia-iz_4pbn.asp"><span style="font-style: italic;" title="Information Schema details on MSDN">Information_Schema</span></a> view</li> <li>the <span style="font-style: italic;"><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sys_00_690z.asp" title="List of system tables and their descriptions on MSDN">system tables</a> </span>in the database</li> </ol> Infomration schema is a convenient abstraction of the system tables, since it organizes the schma information for easy retrieval. Yet, there are pieces of information which I requried for my adventure which the information schema had ignored.<br /><br />So, I had to go back to the system tables. Although it is not easy to get started with the sys* tables, they can be very powerful tools! I finally managed to get what I had wanted to using the system tables. Following is the list of scripts which can be used to retrieve schema information of a database.<br /><br /><span style="font-weight: bold;">List of databases on the server</span><br /><blockquote><code>USE MASTER<br /><br />SELECT dbid [DatabaseID], name [DatabaseName]<br />FROM SYSDATABASES</code></blockquote><br /><br /> <span style="font-weight: bold;">List all the tables in a database</span><u></u><br /><blockquote><code>USE <database><br /><br />SELECT id [TableID], name [TableName]<br />FROM SYSOBJECTS<br />WHERE xtype = 'U'</code></blockquote><br /><br /><span style="font-weight: bold;">List of all columns in the system</span><br /><blockquote><code>USE <database><br /><br />SELECT tab.id [TableID], tab.name [TableName],<br />col.colid [ColumnID], col.name [ColumnName],<br />col.type [DBTypeID], typ.name [DBTypeName], col.length [Size], col.isnullable [IsNullable]<br />FROM SYSCOLUMNS col<br /><br />INNER JOIN SYSOBJECTS tab<br />ON col.id = tab.id<br />AND tab.xtype = 'U'<br /><br />INNER JOIN SYSTYPES typ<br />ON col.type = typ.type<br />AND col.xtype = typ.xtype<br />and col.xusertype = typ.xusertype</code></blockquote><br /><br /><span style="font-weight: bold;">List of all relationships in the system</span><br /><blockquote><code>USE <database><br /><br />SELECT DISTINCT<br />RO.name AS PrimaryTable,<br />RCOL.name AS PrimaryColumn,<br />FO.name AS ForeignTable,<br />FCOL.name AS ForeignColumn<br /><br />FROM SYSFOREIGNKEYS FK<br /><br />INNER JOIN SYSCOLUMNS FCOL<br />ON FK.fkeyid = FCOL.id<br />AND FK.fkey = FCOL.colid<br /><br />INNER JOIN SYSCOLUMNS RCOL<br />ON FK.rkeyid = RCOL.id<br />AND FK.rkey = RCOL.colid<br /><br />INNER JOIN SYSOBJECTS FO<br />ON FK.fkeyid = FO.id<br /><br />INNER JOIN SYSOBJECTS RO<br />ON FK.rkeyid = RO.id</code></blockquote><br /><span style="font-weight: bold;">List of all Database Types</span><br /><blockquote><code>SELECT name [DBTypeName]<br />FROM SYSTYPES</code></blockquote><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9473630-112624897247909879?l=bitscrap.indradeep.com%2Findex.html'/></div>.i.http://www.blogger.com/profile/03817226297503474535noreply@blogger.com1tag:blogger.com,1999:blog-9473630.post-1102262246001348982004-12-05T23:34:00.000+08:002005-08-24T11:27:08.816+08:00Regular Expression Validators<span style="font-size:100%;">Regular expressions are used to match patterns in a string. I suppose it is used quite commonly in Linux / Unix for 'grep' and other search tools.<br /><br />Regular expressions could be used quite conveniently for checking text fields for ASP.NET Web Forms, or Windows forms.<br /><br />ASP.NET comes with a<span style="font-style: italic;"> Regular Expresssions Validator</span>, which could be attached to a text box. Once the regular expression is specified, and the error message is set on the validator, then, upon the form submission, if the text box contains an invalid entry, the error will be displayed.<br /><br />In .NET, the<span style="font-weight: bold;"> </span><span style="font-style: italic;">System.Text.RegularExpressions</span><span style="font-weight: bold;"> </span> namespace has functions to perform regular expressions.<br /><br /></span> <div style="text-align: center;"><span style="font-size:100%;"><img src="http://bitscrap.indradeep.com/images/regex.jpg" alt="The regular Expressions application" align="middle" height="254" width="400" /><br /></span></div> <div style="text-align: center;"><span style="font-weight: bold;font-family:verdana;font-size:100%;" ><span style="font-size:85%;">The Regular Expression Checker<br /></span><br /></span><span style=";font-family:trebuchet ms;font-size:100%;" ><span style="font-weight: bold;">Download: <a href="http://bitscrap.indradeep.com/data/RegularExpressions.exe">Executable</a>| <a href="http://bitscrap.indradeep.com/data/RegularExpressions.zip">Source Code in C#.NET</a></span></span><span style="font-weight: bold;font-family:verdana;font-size:100%;" ><br /></span></div> <span style="font-size:100%;"><br />I made a sample application called Regular Expression Checker which uses the .NET Regular Expression constructs.<br /><br />The application applies a regular expression to a chunk of text, and displays the matches. I found it quite painful to build my application repeatedly to check whether my regular expressions were correct. This app saves me the time and the pain of constant building!<br /><br />References:<br /></span><ol> <li><span style="font-size:100%;"><a href="http://sitescooper.org/tao_regexps.html" target="_blank">A Tao of Regular Expressions</a></span></li> <li><span style="font-size:100%;"><a href="http://www.regular-expressions.info/" target="_blank">Regular-Expressions.info</a></span></li> <li><span style="font-size:100%;"><a href="http://gnosis.cx/publish/programming/regular_expressions.html" target="_blank">Learning to use Regular Expressions</a></span><br /></li> </ol><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9473630-110226224600134898?l=bitscrap.indradeep.com%2Findex.html'/></div>.i.http://www.blogger.com/profile/03817226297503474535noreply@blogger.com1