Monday, September 10, 2007

Accessing Windows XP Machines

Have you noted that when you try to access a Windows XP machine, in the Connect To window (Login screen) the User name field is disabled?
Earlier versions of Windows did not had this disabled so we were able to logon as any valid user by typing the account name and the password. But in Wondows XP this was disabled by a security policy.

This policy will also restrict the machine's ability of sharing files, per user sharing will not be possible.
Want to change it? Ok proceed by openning the Local Security Policy Settings window through Start -> Control Panel -> Administrative Tools -> Local Security Policy.
Now go to Network Access section and find out Net access : Sharing and security model for local accounts.
Then open the properties page of that by double clicking or right clicking and clicking on properties.

Did you note that the default is, Guest only - local users authenticate as Guest change this to Classic - local users authenticate as themselves.
Then press Ok to apply the setting and close all the opened windows.

Now from some other machine try to access your machine. See the difference. Now you can type any user name and the appropriate password and log in.

Also if you now go to folder properties you will see that the Sharing tab is having different content than earlier and also you will see a new tab named Security. You can use these tabs to set per user security and access rights.

For people who would like to know more, following is the explanation for the setting Net access : Sharing and security model for local accounts given by Microsoft.



Network access: Sharing and security model for local accounts
This security setting determines how network logons using local accounts are authenticated. If this setting is set to Classic, network logons that use local account credentials authenticate by using those credentials. If this setting is set to Guest only, network logons that use local accounts are automatically mapped to the Guest account.

The Classic model allows fine control over access to resources. By using the Classic model, you can grant different types of access to different users for the same resource. By using the Guest only model, you can have all users treated equally. All users authenticate as Guest, and they all receive the same level of access to a given resource, which can be either Read Only or Modify.

There are two models available:

  • Classic: Local users authenticate as themselves.
  • Guest only: Local users authenticate as Guest.

Default:Guest only on Windows XP Professional. Classic on the Windows Server 2003 family and Windows XP Professional computers joined to a domain.

Important:With the Guest only model, any user who can access your computer over the network (including anonymous Internet users) can access your shared resources. You must use the Internet Connection Firewall (ICF) or other similar device to protect your computer from unauthorized access. Similarly, with the Classic model, local accounts must be password protected; otherwise, those user accounts can be used by anyone to access shared system resources.
This setting only affects computers running Windows XP Professional which are not joined to a domain.This policy will have no impact on computers running Windows 2000.

Notes:This setting does not affect interactive logons that are performed remotely by using such services as Telnet or Terminal Services.When the computer is not joined to a domain, this setting also modifies the Sharing and Security tabs in the Windows Explorer to correspond to the sharing and security model that is being used.

The Car of the Future - M 200G

Have you seen the car of the future? Even though people call this a car this is more towards a personal helicopter. The M 200G is manufactured by Moller International located in Davis, California, USA. This is capable of vertical take-off and landing.

Read more at BBC.
http://news.bbc.co.uk/1/hi/business/6970031.stm

In the future there won't be necessary to us to wait in long traffic ques. But what will happen if all the people buys this car?

I think it will increase the Air Traffic :-).
Windows Vista Service Pack 1

Microsoft is going to release Service Pack 1 (SP1) for Windows Vista. It will have the updates that Microsoft had released up to now and also some reliability and performance improvements addressing the issues they have found.

The beta version is planned to be available in few weeks time from today (2007-September-09).

Thursday, August 30, 2007

Importing Yahoo contacts to Outlook
This was actually a doubt that I had in my mind after I had accidently deleted my contact list by synchronizing in wrong way. This is possible and the method is as follows.
1. Open your Yahoo Mail and click on the Options -> Mail Options on the top right corner of the page.2. Select Contacts Options from the left pane.
3. Click on Import/Export under Management column.
4. Go down to Export section and press on the button named Export Now which is infront of Microsoft Outlook and save the file to your hard disk when it prompts.
5. Open Outlook and click on File -> Import and Export..., then select Import from another program or file option and click next.
6. Select Comma Separated Values (Windows) from the list and click next.
7. Browse for the file that you saved in Step 4 then select what to do if it finds duplicate items and click next.

8. Select the Contacts item from the list and click next.
9. If you want to map the contact fields manually you can do so by clicking on Map Custom Fields..., most of the time this is not required.
10. To do the import click Finish.
WOW you have successfully imported Yahoo contacts to Outlook.

Wednesday, August 22, 2007

Changing Manufacturer Icon in System Properties

Changing Manufacturer Icon in System Properties
Recently a friend of mine did ask me how to change the manufacturer icon and supported by text in System Properties. Even though, I have changed the Boot Screens and Welcome screen languages when I was at my earlier employer I forgot how to achieve this. :-)

Then after some trying I found the way and thought it is better to blog it.

1. You have to create an icon to be shown as the manufacturer logo. Also remember that even though how large your image, System Properties will only show 180x114 pixels.
  • The point is that the image you create should be 180x114 pixels to be shown as a whole.
  • The image name should be OEMLogo.bmp.
2. Create an ini file to hold the Manufacturer, Model and Support Information.
Open notepad and create a file in the following structure.

[General]
Manufacturer= Arjuna
Model= My Model

[Support Information]
line1= Tele xxx - xxxxxx
line2= Fax ### - ######
line3= EMail ME@MyCompany.Com
line4= What ever you want

When saving you have to save this file as OEMInfo.ini.

3. Ok, since now files are ready, you have to copy them to system32 folder inside windows installation folder. The default location would be C:\WINDOWS\system32.

Job well done !, now if you go on to System Properties you will see the image that you have just created with the information that you have just saved in the notepad.

Thursday, August 16, 2007

Query Shortcuts in SQL Server 2005

There is a nice feature which I did not come accross until recently. That is Query Shortcuts. This can be very helpful when executing regularly used queries.

For example consider SELECT * statement that we use.

When ever we need to get the full record set of a table we are writing SELECT * FROM tblTable. So if we have 10 tables we need to write the same SELECT * FROM part 10 times or we may need to copy and paste that. Also mosstly, as developers we are using this statement for temporary purposes to just see what is there inside the table later we will delete the queries. In such cases the query shortcuts come in handy.


But to use them you have to set them up.
1. Open SQL Server Management Studio (SQL SMS) and go to Tools -> Options..., this will bring up the Options page.
2. In that, expand the Environment category and click on the Keyboard.
3. Now select a key combination which is easy for you to use (I selected Ctrl + 3.). Then in front of the key combination under Stored Procedure type SELECT * FROM and press ok.

Setup is done, now we'll use it.
4. Now open a new Query Window in SQL SMS. Then drag a table from the Object Explorer.
5. While the table name is selected, press the key combination (My case it is Ctrl + 3.).


See what happened?

It will run the SELECT * FROM tblTable query even though the query window is just having the table name.
Not only SELECT * FROM you can run what ever queries by using this method. But a limitation which I see is that we cannot create our own key combinations (I prefer assigning Ctrl + S or Ctrl + Space for SELECT * FROM rather than Ctrl + 3.).
I think this is useful to many developers to improve their productivity.

Wednesday, August 15, 2007

Nice Windows Shortcut

Do you know that you can use both sides of the title bar to close an application in Windows?
Obviously in the right side you have the Close button which you can left click to close the application.
What about the left side? Yes If you double click on the left side then also application will close.
  • Windows XP and earlier
In the left corner of the title bar there will be a small icon , if you double click on this that will trigger the same action of application exit.
  • Windows Vista
In vista there will be no icons, but if you click on the left corner that will still trigger the application exit.


  • Office 2007
The new Office version will have a big circle on its top left corner . If you double click on or near this again the application exit will be triggered.
Wireless Electricity

Did you get to know that people are trying to send electricity wireless. Even though this is still at testing I think when this succeeds lot of people will enjoy true wirelessness. Since nowadays even we have wireless devices we need a cable when charging them. This will remove that disadvantage.

Read more at,
http://gizmodo.com/gadgets/notag/mit-dudes-develop-mind+boggling-wireless-electricity-267238.php.

Tuesday, August 14, 2007

Intel Core 2 Quad Processors





Intel has released Intel Core 2 Quad Processors, these are capable of handling 4 threads simultaneously.
Read and experience more at Intel.

http://www.intel.com/products/processor/core2quad/index.htm
http://www.intel.com/products/processor/core2quad/demo/demo.html

All recent processors.
http://www.intel.com/performance/desktop/dighome/index.htm

Monday, August 13, 2007

Debugging Web Services

I tried debugging some Web Methods (WM) in a Web Service (WS) using Microsoft Visual Studio 2005 and noted the following things.

When your WM having simple parameters (Integers, Strings) if you run your project internet explorer will open up with text boxes to enter your parameters. After entering there will be a button named Invoke to invoke the WM. That will invoke your WM with the parameters you have provided.

But the thing is if your WM is accepting complex types as parameters (Objects, Datasets, Tables {Even though it is not recomended to supply complex objects like datasets to WMs there may be scenarios that it will save lot of development time of yours.}) then you will not see either textboxes or an Invoke button. As a result you will not be able to debug the WM.

Do not worry because I found the way to debug.

First you have to publish your WS to Internet Information Services (IIS). To make things simple for you Visual Studio will do the publishing for you. Before that make sure that your IIS is running by typing http://localhost/ in your web browser.

Then right click on your WS project in the Solution Explorer and click on Publish.... This will open up the Publish Web form to you. In that enter the target location as shown. Remember to change the IP address used to your IP address or you can put your machine name or localhost instead using IP address.



Click on Publish. This will create a virtual folder inside IIS and your compiled WS will be copied in to the virtual folder. Now your WS is hosted. In some cases you may have to give permission to the WS. If you needs then open IIS Manager by typing 'InetMgr' in the run windows. Browse to your newly created virtual folder, right click on the folder and click on properties.



In WebService properties window check if 'Script Source Access' check box is checked, if not then check that and click Apply and click Ok.

Now we have published the WS, we'll setup debugging.

Right click the WS in the Solution Explorer and click Properties. In the project properties page click on the Web tab. In that as the default, WS will be set to run on a virtual server comming with Visual Studio. We have to change this because we are not been able to debug on virtual server. To do this select the radio button 'Use IIS Web Server' and set the project URL to the same location you entered in the Publish Web screen.



Now close the WS properties screen and press F5 or Debug -> Start Debugging. This will start the Internet explorer and will load your web service. Keep that as it is and put some breakpoints in the WS code.

Then use the web service. I did use the WS from a PDA application. When ever the call is made the web service will break at the breakpoints you have put then you will be able to debug as usual (using the windows as such Immediate, Watch, etc)

Conclusion
In Visual Studio normally it will start the WS in its virtual server. We have to point that to IIS to make it debuggable. That can be done by setting Web properties in the WS properties.

Thursday, August 09, 2007

Making a normal Column, an Identity column in SQL Server CE

In SQL CE making a normal column an identity column is not possible. This is because the process involved in the making of identity columns. If you would like to know more about the Identity creation behaviour please read my earlier article.

http://arjunachith.blogspot.com/2007/08/making-normal-column-identity-column-in.html

In SQL CE the process mentioned in the article is not possible because that SQL CE does not support enabling and disabling IDENTITY INSERT.

If you did try it out, should have noted that even SQL CE table editor is not supporting this.

So if you really want to change a column in to an identity column (which already having unique values) then what you can do is, create a new table and copy the data your self. But the problem is that you will not get the old values in the identity column because there is no way to copy them without turning the IDENTITY INSERT off. So identity column data will be new from 1 to n, But all other information will be there in the table with the identity column in place. If you even wants to keep the old identity values you can keep that old identity column and create a new column for the Identity column.

Friday, August 03, 2007

Making a normal Column, an Identity column in SQL Server

Do you know that you cannot just change a normal column into an identity column in SQL Server? This is because that identity columns can only be created when creating new tables.

Now some people will say that how cannot that be? Because they are used to change using the SQL Server Management Studio (SQLSMS). What management studio will do is, it will create a temporary table with the Identity column and copy all your existing data there. Later it will delete the original table and will rename the temporary table to the original.

For example we will take Sales.Individual table in the AdventureWorks database.



Think that we need to add a column named Id as an identity column. What we will do is just type after ModifiedDate column and make the new column an identity column.

In such a case when we save the change SQLSMS will first create a temporary table which matches the new schema with the identity column.

Then it will set IDENTITY INSERT OFF and will copy the data from the original table to the newly created temporary table.

After this it will delete the original table and will rename the temporary table as the original table.

Did any one thought that the SQLSMS is doing this much of work for us without our knowledge?
Retrieving Schema Information of SQL CE Database

There are very limited features offered in SQL Compact Edition (SQL CE). But with those offered you can do many things if you know what is there and what is not there.

Following are some views available in SQL CE which you can use to retrieve information about the tables in the database.

-- Gets the list of Columns with their associated Tables. You will be able to retrieve the column properties such as Data Type, Allow Null, Default Values, etc.
SELECT * FROM INFORMATION_SCHEMA.COLUMNS

-- Retrieves information about the indexes contained in the database.
SELECT * FROM INFORMATION_SCHEMA.INDEXES

-- Retrieves information about the Primary Keys used in the tables.
SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE

-- Retrieves all the Tables in the database including the System tables.
SELECT * FROM INFORMATION_SCHEMA.TABLES

-- Retrieves all the Constrains in the database.
SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS

-- Retrieves all the Data Types available in the database.
SELECT * FROM INFORMATION_SCHEMA.PROVIDER_TYPES

-- If you have any referential integrity constraints in your database defined, those will be returned by this.
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
Did you ever thought why we are saying "Many Happy Returns of the Day" on someones Birthday

Visit this link and find out more.
http://www.smh.com.au/news/big-questions/why-do-you-wish-a-person-many-happy-returns-of-the-day-on-theirbirthday/2005/08/25/1124562965035.html

Thursday, August 02, 2007

Dual Booting Windows Vista

As I normally need several Operating Systems installed in my machine, after installing Vista also I tried the same. This made me to find, that the Vista boot loader is different to the earlier OS boot loaders. Because of this difference if you install earlier version of OS after installing Vista, you will not be able to start Vista.
These are the things which I found out.
If you need to multi boot Vista, then first install the oldest OS first. If the OSes are Windows XP, Windows 2003 and Windows Vista then install Windows XP first then Windows 2003 and finally Windows Vista.
Also note that if you install any earlier version after installing Vista you will have to fix the Vista boot loader. This can be done by booting the computer using the Vista installation CD and trying a start up recovery.
A good article is located at http://www.itnews.com.au/News/NewsStory.aspx?story=55148.
Retrieving MAC Address in Compact Framework

Recently I have seen that getting the MAC address of a Pocket PC network card using the .Net Compact Framework requires calling to the API 'iphlpapi.dll'. This is because the Windows Management Instrumentation (WMI) classes are not in Compact Framework. Otherwise you should have used WMI to get the MAC address.
But believe me that the process involved in Compact Framework to get the MAC address is complex. So as a suggestion I would say to use the OpenNETCF class libraries. You have to use OpenNETCF.Net and OpenNETCF to successfully get the MAC address. If you want to know what is happening underneath you also can download the OpenNETCF source code too.

OpenNETCF web site is http://www.opennetcf.com/, visit them and see.

The code for getting the MAC address of the first adapter using OpenNETCF would be,

' Creating a variable to hold all the retrieved adapters.
Dim adpcol As OpenNETCF.Net.AdapterCollection = OpenNETCF.Net.Networking.GetAdapters
If adpcol.Count = 1 Then
' adpcol.Item(0).MacAddress will be returning in Byte stream, you have to use Bit Converter to convert the stream to string.
GetDeviceMAC = BitConverter.ToString(adpcol.Item(0).MacAddress)
Else
GetDeviceMAC = "No Adapters Fetched"
End If

(You have to refer OpenNETCF.Net and OpenNETCF to make this code run.)
Yahoo! Go 2.0


Have you tried Yahoo Go 2.0? It has many new additions than the earlier version of Yahoo Go. In supported areas you can even get the traffic reports and maps.

Also note that Yahoo Go 1 service will be stopped on 27th of August 2007.

Try it out at http://mobile.yahoo.com/go.

I am sure that you will like the new version with many new features.

Thursday, July 12, 2007

Analyzing Device Application Performance


Recently I tried analyzing my applications' performance running on a Pocket PC. This can be achieved using .Net Compact Framework (.Net CF) Remote Performance Monitor (RPM). .Net CF RPM provides facility to monitor applications which run on devices that are connected to the computer using Active Sync or by general network.

To monitor your device application performance you have to have at least .Net CF SP1 since .Net CF RPM will come with .Net CF Service Pack 1. If you have not yet installed .Net CF SPs then download the SP2 from Microsoft using the following link.
http://www.microsoft.com/downloads/details.aspx?FamilyID=aea55f2f-07b5-4a8c-8a44-b4e1b196d5c0&DisplayLang=en


RPM consists of 3 main files.
1. NetCFRPM.exe - This is the application file which will run on your computer. This will show performance related data of the device application. This file can be found at C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\bin if you installed the Service Packs to the default location.

2. netcflaunch.exe - This will give you the connection parameters to the device. The details provided will be in handy if the device is not connected to the computer using Active Sync.

3. netcfrtl.dll - This dll facilitates the connection between the computer and the device.

You have to copy both above files to the device Windows folder (\Windows).


If you need more information on how to use .Net CF RPM visit Steven Pratschner's .Net CF weblog articles.
http://blogs.msdn.com/stevenpr/archive/2006/04/17/577636.aspx
http://blogs.msdn.com/stevenpr/archive/2007/03/08/finding-managed-memory-leaks-using-the-net-cf-remote-performance-monitor.aspx

Tuesday, July 10, 2007

Installing Office 2007 Ultimate on Windows Vista Ultimate

As it always happens, last few days I was busy with a curious error while trying to install Office 2007 Ultimate edition on my newly installed Windows Vista.

The errors I got were.


I have seen many posts on the internet but many were regarding upgrading to the released version from beta. But my case was different because it was a fresh copy of Vista and it was a DVD received from Microsoft.
After some struggle I got Office installed and would like to share how I succeeded. What I suspect was that it was having a problem copying files from source to destination at a stretch. The way I did was like this.

The first advice I give is, If you are installing office to some other directory than default given directory, please create that exact directory in your hard disk and point the setup to that directory.
Then try normal installation of Office 2007. If you are in my category it will fail after giving one of the above errors. Let it fail by pressing Abort button because we have no other option.

Again start the installation, this time select the top node, right click and select "Install on first use" (This will make all the software's install at the first attempt made to use them.) and continue with the setup.
In our earlier setup, it failed saying that one of the cabinet file was corrupt so cannot continue with the setup. This time because we used the option install on first use this error will not appear.

After successfully completing the setup. Try running Word for the first time. This will start the setup process. Sometimes you may be required to insert or point to the installation source during setup. If the same above mentioned error comes click Abort. Even you click Abort Word will start. Then after closing Word do the same on PowerPoint and let PowerPoint also start.

Now you have Word and PowerPoint up and running. Close all opened software's and insert you Office installation source and start the installation again. This time select "Run from Computer" option (or what ever options you want to select). Then start the installation. When Office setup starts the progress bar remove your installation source (CD, DVD,...). Because the new installer will keep the required files for the setup, it will run normally for sometime. If any files for the selected options are missing then installer will ask at that place to point to the source.

After sometime the setup will request for the files which are missing (My case it asked for ExcelLR.cab). This time it will allow you to browse for the file. Be careful this will allow you only once to browse, if you select the wrong location then it will give setup fail message and you have to restart setup after pressing Abort. When browsing for the file remember to just point to the folder above the actual file not to the actual file it is requesting. (In my case I directed to the folder CD:\English\OfficeSystem2007\ULTIMATE2007\Excel.en-us.)

If you properly followed everything setup will now continue without errors.
If you are still having problems then I recommend you to find another edition of Office 2007 (Enterprise, Professional) and try installing Excel with that edition. After successfully completing that setup run the Ultimate setup again. Then when the progress bar starts remove the installation source. You may have to browse for the installation source after sometimes. After you installed ultimate edition successfully remove the other edition using add remove programs. And perform a repair operation on the ultimate setup. This will fix any edition clashes and will configure ultimate edition properly.

Tuesday, June 19, 2007

Automating Actions in Photoshop

Recently I had to edit several hundred images. The point was that I had to do the same thing to all the images. So I struggled a bit to find a way to automate the process. In this way Adobe Photoshop will do the same actions to all the images without my involvement. Cool right, Ok then before explaining the way to do this I'll explain what I am going to do.


To make things simple, just imagine that you need to put some text to some images and needs to save the images as Jpeg. First things first, so open one image from your image set after starting Adobe Photoshop (Please note that I am using Adobe Photoshop CS2).

1. We need to record our actions to make Photoshop repeat them on other images.

Open the Actions pane by clicking on Window -> Actions or pressing Alt + F9.

Now create a new Set by clicking on the folder like icon at the bottom of the actions pane. When new set window comes put a name that you want. I kept the default name which was Set 1.

Then create a new Action by clicking on the small icon located little right to the New Set icon.

In the New Action window you can specify a name (Action 1), a set which this action will belong, a key combination to initiate the action and a color for the action if you want.

Now you are ready to record the actions. After double checking whether the Begin Record button (Circuler button as the second button from the left in the Action pane.) is activated, use the Horizontal Type Tool (T) to insert the required text into the image. Format the text as you want.

Since now we are done with the required actions, stop the Recording by clicking on the Stop Playing/Recording button (The left most button [rectangular] on the Action pane.) Note that not only putting text, you can do many things available in Photoshop at this point and record to Automate later.

2. Now you have successfully created the repitative tasks. What you have to do now is to perform all these tasks on the images you have.

If all the images you want to change are not in the same folder put all of them to one folder. Having images inside sub folders are ok.

Then Click on File -> Scripts -> Image Processor.


In Image Processor select the second radio button at Step 1 and click on Select Folder... button and select the folder where your images are.

Select the Step 2 as you like. (What I choose is to save the images on a folder named New Folder under my original folder)

Select the Save as Jpeg check box and type appropriate quality in Step 3 (5 in my case).

In the Step 4 select the set (Set 1) and action (Action 1) you have created above.

If you want any Copyright information you can enter them also.
After selecting everything click on Run to start the batch process.

You will be able to see Photoshop automating. How helpful is this? Was a lot to me.
Happy playing with images.
Installing Visual Studio 2005 SP1


Did you try installing SP1 for Visual Studio without any errors? If not or if you are still did not start the installation some of the following details will help.

The list of things that Microsoft had fixed in Visual Studio 2005 SP1 is located at http://support.microsoft.com/?kbid=918526.

Most of the time the setup will fail due to the insufficient disk space. So before trying to install the SP1 check whether you have at least 6.3 GBs of free disk space. If you have installed VS in other partition than Windows I recommend to check for free disk space in both partitions.
Another common error which can happen when installing this is,

Error 1718. File FileName was rejected by digital signature policy.

This error is due to the Software Restriction Policies (also known as SAFER) that exist in the operating systems that came after Windows XP. This was introduced to help users avoid running unsafer files. SAFER will be used by Windows Installer to check the file signatures to confirm that the files were not tampered. Note that this error can happen when installing any large Windows installer package or Windows installer patch.

This error occurs when there is no contiguous piece of virtual memory to accommodate the file. Then the Windows installer will fail to validate the file and result in this error.

There are few things you can do to fix this,

1. You can edit the registry to make the PolicyScope value to 1 before you install the package.

2. By changing the SAFER settings to allow administrators to install the package.

3. Installing the hotfix if you are running Windows 2003,

For any of this you can get more information from Microsoft by visiting http://support.microsoft.com/?kbid=925336.

Apart from that Visual Studio SP1 release note can be found at http://support.microsoft.com/?kbid=928957.

Also I suggest that you refer Heath Stewart's articles for more installation tips. Heath is Technical Lead working at Microsoft http://blogs.msdn.com/heaths/archive/tags/VS+2005+SP1/default.aspx.

Even though I had no luck recovering the applications without formatting the system which crashed with the failed installation of Visual Studio SP1, I guess you will have much more luck after reading these articles.

Wednesday, June 13, 2007

Have you tried Google Analytics?

Google Analytics is a free tool provided by Google which will analyze your web site usage. It will monitor your site and will generate reports such as
* number of users visited
* number of minutes spent on the site
* peak times
* place where users came
* what explorer used, etc.
This list is simply a short list of features. See for your self by visiting,

https://www.google.com/analytics/home.

You can log in using your GMail Id and password. Then you have to add your site to analytics and it will give you a script file which you needs to put in to your site. That's all to worry then Google will do the reporting to you.
Happy analysis.

Tuesday, June 12, 2007

World's Smallest Mobile Phone - WatchPhone


Have you seen the cool gadget SMS M 500. This is a watch with basic phone functionalities. This will include facilities and features such as

* Full SMS and MMS functionality
* MP3 Support AAC/MP3 and MP4 Support Video Playing
* Touchscreen with Built-in Stylus
* Memory: 128MB Built-in Memory
* Battery: 400mAh, Talk Time 200 Minutes, Standby Time 80 Hours
* USB: For Data Transfer and Recharging
* Bluetooth 2.0
* Date/Time
* Last Number Redial
* Recent Calls
* Missed Calls
* File Manager
* 199 Contacts
* Multi Languages
* Flight Mode
* Email
Roughly this will be priced around A$ 1000 (Australian Dollar 1000).
For the full details please visit the manufacturer SMS Australia at http://www.mymobilewatch.com/watch_specification.php.
Clearing Windows History


Have anyone tried removing items in Windows history as in Run window history items, most recent documents, web browser history, most recent applications like stuff?
As usual, a bizzare requirement of deleting the Run window history came to me.

After some wondering here and there I found that there is a registry position where the Run window history is recorded. You can find that entry at

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

in the registry editor. (To open Registry Editor go to Run window and type RegEdit.)
All the history entries dropped in the Run window will be in the list. If you wants to edit or delete an entry you can edit or remove them using the registry editor.
In some scenarios this list will be empty even though there are items in the Run history. In such a case there is an option you can set so that the next restart will erase all the history items. This method is really good if you want to start fresh removing al history items. This will remove Run history, recent programs, recent documents, internet browser history, etc by one shot.
Interested, ok so to do this first open the registry editor. Then go to the following location

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer

Now you need to add a Binary Value named ClearRecentDocsOnExit (Edit -> New -> Binary Value), then make the binary value of that to 1 (Edit -> Modify Binary Data).
The next time you shutdown or restart Windows it will take little longer to shutdown because it is clearing the history items. After you start again you will be free of your history items.

If you always want to start fresh at each restart keep the setting as it is. If you just needed to clear the history at that point like me you have to either delete the value we made or have to make the binary vale 0 so it will not clear the history at each restart. If you needs to change this find the ClearRecentDocsOnExit value and modify the value to read 0 so windows will keep your activity history.
Back in Sri Lanka

Came back to home sweet home. Even though the country is having problems at the moment it feels nice to be here in my motherland.
On my way back I enjoyed Singapore little bit.
If you would like to know more please see my photo album named Singapore. I think Singapore airport is one of the best airports in the world providing great facilities to travellers. From the airports which I have been I can say Singapore is the best. Their idea of having themed parks inside the airport is a brilliant idea. Also I heard that they are building there new terminal (Terminal 3) with much more features. So I guess anyone going to Singapore won't be disappointed.

Wednesday, May 09, 2007

Watched Spider Man 3 on IMAX

Spider Man 3 was released 3rd of May 2007. I had a chance to watch it in Melbourne IMAX theater. This was my first IMAX experience. I feel great to watch Spider Man on its release day.

It was a great movie experience. The speciality in IMAX is it is having very large screen and also the sounds system is also complicated and powerful. The screen is made out of tiny holes so that sound can come through the screen. When you watch you will feel as if you are in the movie. I think the experience is worth the extra money spent.
If you would like to know more about IMAX, pay a visit to their site www.IMAX.com.

Adding and Auto Sizing the background image of a MDI Form in .NET

Some months back I faced a problem of resizing an image on one of my tablet PC device applications. The image was on a Multiple Document Interface (MDI) form. Recently only I remembered this and did some research on this, and thought that better to put an entry.
People who have tried should be knowing that we cannot simply add an image to a form and make it automatically re size when the form changes it's size.
In a normal form we can put a picture box and make it fill the entire screen and can set the image properties to always stretch the image. This will re size the background image when ever you re size the form.
But in MDI forms this is not possible. Whatever control you put on a MDI form will appear on top of all other controls, hiding even the child forms that are open. I have found two elegant methods which can be used.

Method 1 -
Insert the following code into the MDI form code. Here we are using Paint event of the MDI form.

Private Sub frmMDI_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Always the MDI form will be the last control in the control collection. The following will take the MDI forms reference so we can access the properties of it.
Dim varControl As Control = Me.Controls(Me.Controls.Count - 1)
' Loading the background image required to place on the MDI.
Dim varImage As Image = Image.FromFile("E:\Projects\Tablet\Arjuna\Images\Background-Landsc.jpg")
' Resize the image and assign it to the MDI form background.
varControl.BackgroundImage = New Bitmap(varImage, Me.Width, Me.Height)
End Sub


Method 2 -
Insert the following code into the MDI form code. Here we are using Resize event of the MDI form.

Private Sub frmMDI_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
' Loading the background image required to place on the MDI.
Dim varImage As Image = Image.FromFile("E:\Projects\Tablet\Arjuna\Images\Background-Landsc.jpg")
' If there are no space, no point of drawing so exit the sub procedure.
If Me.ClientSize.Width = 0 OrElse Me.ClientSize.Height <= Me.StatusBar1.Height Then Exit Sub
' Creating the bitmap image which is used as the background image.
Dim varBitmap As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height - Me.StatusBar1.Height, Imaging.PixelFormat.Format24bppRgb)
' Getting the drawing surface of the bitmap (varBitmap).
Dim varGraphics As Graphics = Graphics.FromImage(varBitmap)
' Sets the interpolation mode of the graphics object. Interpolation mode determines how intermediate values between two endpoints are calculated
varGraphics.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
' Draw the image on the bitmap.
varGraphics.DrawImage(varImage, 0, 0, varBitmap.Width, varBitmap.Height)
' Assign the bitmap as the background image of the MDI form.
Me.BackgroundImage = varBitmap
End Sub

If you don't have a status bar in your MDI form just remove the codes that are coloured Magenta.

Method 1 does have some problems like, it is visible when the background image re sizes and also I found that if you make the form small sometimes the background image will not be re sized.
So I prefer Method 2.

Wednesday, May 02, 2007

Silverlight is here

Microsoft has released a plug-in for delivering next generation media experiences and rich interactive applications for web. This is a cross-browser, cross-platform plug-in which facilities the WPFs' rich look and feel.
Silverlight was formerly known as WPF/E.
Besides me telling you about Silverlight go to Microsoft and see for your self, you also can find some nice samples done.

http://www.microsoft.com/silverlight

Tuesday, May 01, 2007

Debugging Stored Procedures

I know that all of you might have tried debugging Stored Procedures (SPs). But I know there are also people who are searching how to do this so I thought I needs to put an article on how to do this.

Please note that to dubug SPs you need to use an account which is a member of sysadmin role.

1.) SQL Server 2005
When you install SQL Server 2005 it will install SQL Server Business Intelliegnce Development Studio. You can use this or Visual Studio to debug SPs.

Start any prefered application from the above two and go to View menu and click on Server Explorer (or press Ctrl + Alt + S) to display the Server Explorer.

Now create a connection to the database where the SP you want to debug is located (Right click on Data Connections and click Add Connection...).

When the connection is added to the list expand the list and browse to the Stored Procedures and right click on the SP which you want to debug and select Step Into Stored Procedure. Now if the SP is requiring any parameters a dialog box will be displayed to enter the values. After entering them click Ok to run into the SP.

After you were taken into the debug mode you can use the same keys to debug SPs as if you are debugging application code (Step Into - F11, Step Over - F10, Step Out - Shift + F11).
If you like to use the Debug toolbar activate it by Clicking on View -> Toolbars -> Debug.

If you want to know what the buttons does, just hover on top of the tool so a helpful tooltip will appear. If you need more information press on the help tool which is the right most tool with a yellow question mark.

Also remember that all the additional features are also available for you to use (as if the Immediate Window) while debugging.


2.) SQL Server 2000
In SQL Server 2000 you have to use the SQL Query Analyzer to debug SPs.
Start SQL Query Analyzer and click on Tools -> Object Browser -> Show/Hide (or F8) to display the Object Browser if it is not already shown.

Now expand the database where the required SP is located and right click on the SP which you needs to debug inside Stored Procedures node.

Click on the Debug... to start the debugging, if the SP requires any values for its parameters a window will pop up to enter the values. After entering the values click on Execute.

When debugging starts you can use the available controls or shortcut keys (Step Into - F11, Step Over - F10, Step Out - Shift + F11, Run to Cursor - Ctrl + F10) to debug through the SP.



If you want to know what the buttons does, just hover on top of the tool so a helpful tool tip will appear. If you need more information press on the help tool which is the right most tool with a yellow question mark.

Sunday, April 29, 2007

Number Game - Excellent Number Trick

Did anyone visit http://www.learnenglish.org.uk/games/magic-gopher-central.swf. If you like simple but excellent tricks visit and enjoy.

If you did play the game visiting the british counsil website, some of you may have picked it up what is happening, but if you didn't then read on.

In this game what they are using is a simple number trick.
It is like this,

You first have to think of a two digit number.
For example we'll take 10,

If you add 1 and 0 then it'll be 1.
Now reduce it from 10 so the result will be 9.

To explain the process i'll take more numbers,
10 -> 1+0=1 -> 10-1 =09
13 -> 1+3=4 -> 13-4 =09
15 -> 1+5=6 -> 15-6 =09
19 -> 1+9=10 -> 19-10 =09

21 -> 2+1=3 -> 21-3 =18
25 -> 2+5=7 -> 25-7 =18
27 -> 2+7=9 -> 27-9 =18

33 -> 3+3=6 -> 33-6 =27
36 -> 3+6=9 -> 36-9 =27
38 -> 3+8=11 -> 38-11 =27

Did any one note anything?
There is always a common number coming for each 10 numbers from 0-9.
00-09 the common number is 0.
10-19 the common number is 9.
20-29 the common number is 18.
30-39 the common number is 27.
40-49 the common number is 36.
50-59 the common number is 45.
60-69 the common number is 54.
70-79 the common number is 63.
80-89 the common number is 72.
90-99 the common number is 81.

In the game what they does is they will put an image for all these numbers in there symbol board. So what ever number we guessed we will end up with one of the above numbers and all the above numbers will have the same image on them. Then the program displays the common image as our symbol saying that it read our mind.
The game ends like that but anyway I think it is better if people had the ability of reading other peoples' minds.

Wednesday, April 25, 2007

Sending EMail using SQL Server 2005

Did anyone try sending email using SQL Server?
Ok I tried and got it working, so if you would like to know more please read on. If you face problems while trying this please contact me and I will try helping you sort out the problem.

SQL Server (SQLS) provides Stored Procedure (SP) s which we can use to send mails using SQL. There are two methods in SQL Server 2005.

1.) SQL Mail - SQL Server 2000 provides SQL Mail (The SP you have to use in this method is xp_sendmail.). This method is also supported in SQL Server 2005 (SQLS 2005). But this will not be supported in the next versions of SQL Server. If you are doing a new development the best is to use the Database Mail. Do know that SQL Mail is not supported on 64 Bit versions of SQLS and also remember that SQL Mail is not installed in SQLS 2005 by default.

2.) Database Mail - SQL Server 2005 provides a new method called Database Mail (The SP you have to use in this method is sp_send_dbmail.). This is new to SQL Server 2005 so I will be discussing how to send mails using Database Mail in the following sections of this article using a SP which I wrote as an example. The following SP will read a table and will generate a HTML report according to the data and will send it as an EMail.

Please note that in this article HTML, HEAD, BODY starting and ending tags are proceeded with _ since they are not allowed to be used inside of posts.

--****************************************************************************************
-- Original Developer - Arjuna Chiththananda
-- Description - Sending EMails in SQL Server.
-------------------------------------------------------------------------------------------------------------------
CREATE PROCEDURE [OWNER].[sp_SendEMail]
(
@ReportDate DATETIME
)
AS
BEGIN
SET NOCOUNT ON;
-- Declaring main variables required.
-- HTMLReport is used to store the report (web page) generated using HTML.
DECLARE @varReferenceNumber VARCHAR(10), @varPassengerName VARCHAR(100), @varDepartment VARCHAR(30), @varTravelInformation VARCHAR(100), @HTMLReport VARCHAR(MAX), @varSubject VARCHAR(75)
-- Starting the creation of web page report.
SET @HTMLReport = '<_html><_head><_title>Ar'
+ '<_body>

SQL Server EMail System

Email Report

'
+ '
Report Date -: ' + CONVERT(VARCHAR(15), @ReportDate, 105) + '
'
+ '

'
-- Checking a view for data.
IF (SELECT COUNT (*) FROM [OWNER].[vw_ListPassengers] WHERE ReserveDate BETWEEN @ReportDate AND @ReportDate) = 0
BEGIN
SET @HTMLReport = @HTMLReport + 'There are no records to display.'
END
ELSE
BEGIN
-- Creating the table required to format the displayed data.
SET @HTMLReport = @HTMLReport + '

'
+ ' '
+ ' '
+ ' '
+ ' '
+ ' '
-- Declaring a cursor to loop through data.
DECLARE curPsngrList CURSOR
FOR SELECT [RefId], [PassengerName], [Department], [Address] FROM [OWNER].[vw_ListPassengers] WHERE ReserveDate BETWEEN @ReportDate AND @ReportDate
OPEN curPsngrList
FETCH NEXT FROM curPsngrList INTO @varReferenceNumber, @varPassengerName, @varDepartment, @varTravelInformation
WHILE @@FETCH_STATUS = 0
BEGIN
-- Adding rows to the table for the records found.
SET @HTMLReport = @HTMLReport + ' '
+ ' '
+ ' '
+ ' '
FETCH NEXT FROM curPsngrList INTO @varReferenceNumber, @varPassengerName, @varDepartment, @varTravelInformation
END
-- Closing and deallocating the cursor.
CLOSE curPsngrList
DEALLOCATE curPsngrList
END
-- We are done with the report web page. Ending the web page properly.
SET @HTMLReport = @HTMLReport + '
Reference Number
Passenger Name
Department
Travel Information
' + @varReferenceNumber + '
' + @varPassengerName + '
' + @varDepartment + '
' + @varTravelInformation + '

'
-- Enabling Database Mail.
-- With the default settings Database Mail is not enabled to increase the performance and security of the server.
-- So before using Database Mail we have to enable it on the SQL Server. This is done by setting the configuration option 'Database Mail XPs'. But because is it an advanced configuration option first we have to enable showing advanced options by running the following.
EXEC master.dbo.sp_configure 'show advanced option', '1'
-- To apply the changes run RECONFIGURE.
RECONFIGURE
EXEC master.dbo.sp_configure 'Database Mail XPs', 1
-- On both above options 1 is used to enable the option and 0 is used to disable the option.
RECONFIGURE
-- Now we have enabled Database Mail now we have to start Database Mail.
EXEC msdb.dbo.sysmail_start_sp
-- To send EMails first you have to setup Database Mail. First you have to create an account.
-- I am getting the mail account settings from a table, following are the required variables.
DECLARE @varUserName NVARCHAR(128), @varPassword NVARCHAR(128), @varEMailAddress NVARCHAR(128), @varDisplayName NVARCHAR(128), @varMailServerName NVARCHAR(128), @varPort INT
-- Filling the required variables with the table data.
SELECT TOP 1 @varUserName=EMServerUserName, @varPassword=EMServerPassword, @varEMailAddress=EMSenderAddress, @varDisplayName=EMSenderName, @varMailServerName=EMServerName, @varPort=EMServerPort FROM [OWNER].[tblEMailServer] ORDER BY EMServerOrder, EMServerName
-- Checking whether the account already exists.
-- We can check for existing accounts in the sysmail_account table in the msdb database. As the final section of this article I will list down number of tables which will come in handy while you use Database Mail. (Note my account name is accArjuna.)
IF (SELECT COUNT(*) FROM [msdb].[dbo].[sysmail_account] WHERE [name] = 'accArjuna') = 0
BEGIN
BEGIN TRY
-- If the account does not exist we have to create the account.
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'accArjuna', -- Account name.
@username = @varUserName, -- Account user name to log in to the SMTP server ('Arjuna'),
@password = @varPassword, -- Password of the above mentioned account ('123').
@description = 'Arjuna Chith on Database Mail.', -- Description of the account.
@email_address = @varEMailAddress, -- EMail address to use to send the mails ('Arjuna@Company.Au').
@display_name = @varDisplayName, -- Name to display in the messages ('Arjuna Chiththananda').
@mailserver_name = @varMailServerName, -- SMTP mail server name ('Server.My.Company').
@port = @varPort -- Port of the mail server if it is diferent from 25 (25 is the default value).
END TRY
BEGIN CATCH
END CATCH
END
-- If the account already exists we will update it, since sometimes the details might have changed.
ELSE
BEGIN
EXECUTE msdb.dbo.sysmail_update_account_sp
@account_name = 'accArjuna', -- Account name.
@username = @varUserName, -- Account name to log in to the SMTP server ('Arjuna'),
@password = @varPassword, -- Password of the above mentioned account ('123').
@description = Arjuna Chith on Database Mail.', -- Description of the account.
@email_address = @varEMailAddress, -- EMail address to use to send the mails ('Arjuna@Company.Au').
@display_name = @varDisplayName, -- Name to display in the messages ('Arjuna Chiththananda').
@mailserver_name = @varMailServerName, -- SMTP mail server name ('Server.My.Company').
@port = @varPort, -- Port of the mai,server if it is diferent to 25 (25 is the default value).
@replyto_address = NULL, -- We can put a reply to address different from above address if we needs to make all replies to the send mail directed to another mail box.
@mailserver_type = 'SMTP', -- Mail server type. Currently only SMTP is supported.
@use_default_credentials = 0, -- Credentials to be used. (1 = SQL Server credentials, 0 = users the username and password given in the above and null = anonymous authentication.)
@enable_ssl = 0 -- If your mail server needs Secure Sockets Layer (SSL) then set it to 1 or make it 0. By making this 1 Database Mail will encrypt communication using SSL.
-- Instead of updating if you want we can delete and add the account again. That part is commented here because you don't need to have both update and delete + add. But if you want you can use this method also.
-- EXECUTE msdb.dbo.sysmail_delete_account_sp
-- @account_name = 'accArjuna' -- When deleting an account we need to give the account id or the name. I prefer giving the name.
-- Now we have deleted the account we will add the modifications as a new account.
-- EXECUTE msdb.dbo.sysmail_add_account_sp
-- @account_name = 'accArjuna', -- Account name.
-- @username = @varUserName, -- Account user name to log in to the SMTP server ('Arjuna'),
-- @password = @varPassword, -- Password of the above mentioned account ('123').
-- @description = 'Arjuna Chith on Database Mail.', -- Description of the account.
-- @email_address = @varEMailAddress, -- EMail address to use to send the mails ('Arjuna@Company.Au).
-- @display_name = @varDisplayName, -- Name to display in the messages ('Arjuna Chiththananda').
-- @mailserver_name = @varMailServerName, -- SMTP mail server name ('Server.My.Company').
-- @port = @varPort -- Port of the mail server if it is diferent from 25 (25 is the default value).
END
-- Now we have to add a Profile.
-- First check whether the profile exists.
IF (SELECT COUNT(*) FROM [msdb].[dbo].[sysmail_profile] WHERE [name] = 'prfArjuna') = 0
BEGIN
BEGIN TRY
-- If not add the profile.
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'prfArjuna', -- Profile name to be used.
@description = 'Arjunas Profile' -- Profile description to be used.
END TRY
BEGIN CATCH
END CATCH
END
-- Now we have added an account and a profile we need to merge both these that is done here after checking whether it exists.
IF (SELECT COUNT(*) FROM [msdb].[dbo].[sysmail_profileaccount] WHERE [profile_id] IN (SELECT [profile_id] FROM [msdb].[dbo].[sysmail_profile] WHERE [name] = 'prfArjuna') AND [account_id] IN (SELECT [account_id] FROM [msdb].[dbo].[sysmail_account] WHERE [name] = 'accArjuna')) = 0
BEGIN
BEGIN TRY
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'prfArjuna', -- Profile to be linked.
@account_name = 'accArjuna', -- Account to be linked.
@sequence_number = 1 -- Determines the order of account usage if you have more than one account. If the first account fails it will try sending mails with the second one in the order.
END TRY
BEGIN CATCH
END CATCH
END
-- Grants the Database Mail profile access to the msdb public database role and to make the profile the default Database Mail profile.
BEGIN TRY
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'prfArjuna', -- Profile name to set.
@principal_name = 'public', -- Makes this profile a public profile.
@is_default = 1 -- Makes the profile the default profile for the principal.
END TRY
BEGIN CATCH
END CATCH
-- Fire RECONFIGURE to make the changes apply to SQL Server.
RECONFIGURE
-- The variable to hold the recipient list of our mail.
DECLARE @varRecipients VARCHAR(MAX)
-- Filling recipient list from the table (Note here I am getting the first one in the table (Which will be the last entry added).)
SELECT TOP 1 @varRecipients=EMailAddress FROM [OWNER].[tblEMail] WHERE EMailActive=1 ORDER BY EMailId DESC
-- Setting the subject of the EMail.
SET @varSubject = 'EMailing in SQL Server on ' + CONVERT(VARCHAR(15), @ReportDate, 105) + '.'
-- We have done the hard part so we will now send our mail.
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'prfArjuna', -- Profile name to be used when sending mail.
@recipients = @varRecipients, -- Recipients who will get our mail. ('Arjuna@Company.Au).
@subject = @varSubject, -- Adding the subject to the mail.
@body_format = 'HTML', -- Format of the mail, this could be Text or HTML.
@body = @HTMLReport -- Message body of the mail.
-- If you want to mail an output of a query you can give your query as follows.
--@query='SELECT RefId FROM FlightBooking.SE.Vw_Report_ListPassengers'
END
--****************************************************************************************
Now we have finished the SP remember to run this sp under a sysadmin or serveradmin role to make sure the reconfigurations will take effect.
When we do Database Mail related things like creating accounts, profiles etc everything will be stored in the msdb. If you would like to query out the statuses, following tables might be helpful.
-- Lists down all the created mail accounts.
SELECT * FROM [msdb].[dbo].[sysmail_account]
-- Lists down all the attachments sent using Database Mail.
SELECT * FROM [msdb].[dbo].[sysmail_attachments]
-- Lists down all the created attachments using Database Mail.
SELECT * FROM [msdb].[dbo].[sysmail_attachments_transfer]
-- Lists down the configuration settings of Database Mail.
SELECT * FROM [msdb].[dbo].[sysmail_configuration]
-- Lists down all the created mail servers.
SELECT * FROM [msdb].[dbo].[sysmail_server]
-- Lists down the activity log of Database Mail, if any error occurs a log entry will be created.
SELECT * FROM [msdb].[dbo].[sysmail_log]
-- Lists down the mails sent from Database Mail.
SELECT * FROM [msdb].[dbo].[sysmail_mailitems]
-- Lists down the principal accounts configured.
SELECT * FROM [msdb].[dbo].[sysmail_principalprofile]
-- Lists down all the created profiles.
SELECT * FROM [msdb].[dbo].[sysmail_profile]
-- Lists down all the created profile accounts.
SELECT * FROM [msdb].[dbo].[sysmail_profileaccount]
-- Lists down the details of results that were returned from the queries that were run using Database Mail.
SELECT * FROM [msdb].[dbo].[sysmail_query_transfer]
-- Lists down the details of retry attempts made.
SELECT * FROM [msdb].[dbo].[sysmail_send_retries]
-- Lists down all the created mail servers.
SELECT * FROM [msdb].[dbo].[sysmail_server]
-- Lists down the mail server type (SMTP) and some settings.
SELECT * FROM [msdb].[dbo].[sysmail_servertype]

Thursday, April 12, 2007


Getting Date part only from SQL DateTime Value

Even though I have taken date part only from a datetime field earlier I had to struggle for some minutes yesterday, so I thought why I shouldn't put a blog entry on this so it will help me. Also I think that this will help many of you reading my blogs.

I found two ways to accomplish this without using DATEPART. I believe it is not good practice to use DATEPART and assemble the date by ourselves because it will sometimes change the original year, month and day order and at times that will cause some unnecessary problems.

Method 1

SELECT CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)

What is happening here is CAST(GETDATE() AS FLOAT) will cast the date into a floating point number {2007-04-12 22:12:00.837 = 39182.9236936343}.
Then the FLOOR function will return the largest integer part of the parameter. In our case the result of CAST(GETDATE() AS FLOAT) {39182.9236936343}. The result of this will be 39182.
Now I will caste this value again to a DATETIME value. This time, since there is no fraction part in the value that results in the time part to return as 00:00:00.000. {Fraction part represents the time.}
The final result will be 2007-04-12 00:00:00.000.

Method 2

SELECT CONVERT(NVARCHAR(20), GETDATE(), 101)

In this second approach what I am doing is simply Converting the date into a character. The last parameter of the CONVERT function {101} is the style number which will specify the conversion. Value 101 will return the value in the format of MM/DD/YYYY. {To acquire more information about conversion styles refer CONVERT function in SQL Books Online.} The result of this will be 04/12/2007.

One thing to remember when using second method is that the result will be in the format MM/DD/YYYY. So if you are comparing this value with another date you have to be careful to make the other comparing value also in the format of MM/DD/YYYY. Otherwise it will return wrong results.

Saturday, March 17, 2007

ROM Upgrade on HP iPAQ rw6828

I flashed the ROM of my Pocket PC to version 1.01.03 from 1.00.03. I highly recommend you to upgrade your PPC ROM to the new version since this upgrade will solve many problems that this device is having with the earlier ROM. In the upgrade process I got in to problems initially but at the end I managed to succeed. So I thought of putting a post so that others can do it in one shot unlike me.

You can download the ROM upgrade from
http://h18007.www1.hp.com/support/files/handheldiPAQ/us/download/23981.html
the main software and driver page at HP is
http://h18007.www1.hp.com/support/files/handheldiPAQ/us/locate/1129_6331.html?jumpid=reg_R1002_USEN#0.

As the first thing what you needs to do is backup the data in you PPC because upgrading ROM will erase all the data. The easiest way to save your personal data is to create a ActiveSync membership and sync all the data to a Personal Computer. Then when you complete the upgrade you can sync back and restore the data.

Next make sure that you have ActiveSync 2.0, If you have newer version of ActiveSync I recommend you to uninstal that and install ActiveSync 2.0. You can get it from http://www.microsoft.com/downloads/details.aspx?familyid=7269173A-28BF-4CAC-A682-58D3233EFB4C&displaylang=en.

You should make sure that your computer will not go to standby or hibernate modes and also that your connection from PPC to the computer will be intact while the ROM upgrade is happening. Power failure or cable detach could cost you your PPC.

Remember to remove any SD cards, secondary batteries, SIM cards that you have in your PPC. Also note that it is good practice to charge your PPC above 75% before starting the upgrade.

Next double click on the file you downloaded from HP. Make sure you extract it to the default location provided (C:\iPAQ\SP34074).
Automatically it will start the upgrade process. Follow it as you follow a normal wizard.

If you are lucky the process will continue to 100% and the PPC will reset and will start as usual.

Then create a new partnership with ActiveSync and synchronize the data back to your PPC.

The upgrade process is installing things as follows,
0% - 90% - Pocket PC 2005 and related components
90% - 93% - New Boot Loader
94% - 95% - WAP Component
95% - 100% - WAN Component

If your update process stops at 90% and give a Windows error don't panic. What happens here is that the updater fails while closing the Pocket PC 2005 and opening Boot Loader.
If his happens make sure that you are running ActiveSync 4.2 then disconnect the PPC from the cable and remove the battery for about one minute. At the same time shutdown your computer and restart. Then reconnect the battery. The PPC will then come to a white screen with HP logo on it. now connect the USB cable again.

Go to the place where unzipped the files (C:\iPAQ\SP34074). Double click on hpRUU.exe to manually start the updater again. As you are in trouble already do not start any other applications while the updater is doing its work. If you have followed exactly what I have mentioned this time it should upgrade the ROM successfully. If not what you can do is try another two three times and if this fails you have to send your PPC to a HP service center to upgrade the ROM for you. Or else if you like to continue with the old ROM version you can install the older ROM which can be downloaded from http://h18007.www1.hp.com/support/files/handheldiPAQ/us/download/23966.html.

All the best for your upgrade.

Friday, March 02, 2007

Unexpected Behaviour in UltraFlowLayoutManager

Recently I faced a problem in one of my Tablet PC projects because of an unexpected behaviour of Infragistics UltraFlowLayoutManager.

My scenario is as follows, I am adding dynamically (run time) some UltraExpandableGroupBox controls to a panel which is managed by a UltraFlowLayoutManager. The problem was after the initial display the last group box added to the panel is going missing or appearing in some other location instead of the required location. You can notice this even if the Panel changes its size, normally the layout manger should automatically arrange the controls but here it will not do on the last control added.The actual problem was that the coordinates for the last control was not appropriately set and also the Z order of the control is reduced making it go behind the other controls.
I tried to set the coordinates myself but always the layout manager will override them.
I also tried changing Z order by calling each controls’ BringToFront method. But then all controls will start wondering around.

So as the solution I had to add a dummy Panel control as the last control and I made it to appear as a line to stop confusing users.
Now my application will display a line a the end at times and at times it will not. Kind of AI behavior huh :-).

Saturday, February 24, 2007

Back Again in Australia

I came again to Australia last week. This time I came through Singapore. The airport and it's facilities are wonderful. For the first time in my life I flew in Cathay Pacific and Quantas. Mmm I think even though the Airlines are cutting facilities these days these two airlines are in the list with other airlines who are not going down in their service. But Cathay Pacific are having things which needs to be corrected fast.

Friday, February 09, 2007

Newest Member of Microsoft Office - Groove

Check out the newest member of Microsoft Office product line. Microsoft Office Groove 2007. Groove is a team collaboration tool which will facilitate information sharing. This is what Microsoft is saying about Groove.

Microsoft® Office Groove® 2007 is Internet software for making direct connections with the people who are important to you. With Office Groove 2007, you can bring together team members from both inside and outside your company, with no IT assistance required and no need to waste time thinking about firewalls, servers, security, or network access. Additionally, you can enjoy the efficiency of always knowing each other's virtual location, or online presence, thus allowing for organic and quick conversation and collaboration.

If you are interested in knowing more visit http://office.microsoft.com/en-us/groove/HA101672641033.aspx. There you will be able to find an introduction animation from which you will be able to get an idea of Groove.
NetAdvantage for WPF

Infragistics have released a beta control set which is to be used for WPF (,.NET 3.0) named NetAdvantage for WPF. I think there they have created some cool control set which we'll be able to use with our development. If you are interested find more information at http://www.infragistics.com/hot/wpf.aspx#NetAdvantageforWPFBeta .