Posts

Showing posts from 2008

Virtual PC setting - resetting MAC address.

In the case where you would want to change the IP address by forcing the DHCP to re-assign a new IP to you Virtual PC. (or in the case you are using the same *.vmc file and you don’t bother to recreate a new one) Stop your virtual machine. Then, in your *.vmc, look for <ethernet_card_address type="bytes">0003FFxxxxxx</ethernet_card_address> Remove the number so the line appears as follows: <ethernet_card_address type="bytes"></ethernet_card_address> After you remove the number, Virtual PC will create a new MAC address the next time you start the virtual machine. And in turn, DHCP will assign u a new IP address for your virtual machine.

SQL server IDENTITY and seed

One can make a column to be auto increment by setting it as identity. CREATE TABLE dbo.MyTable ( MyID int identity(1,1), MyName nvarchar(20) ) One can make it start from certain number by setting the seed identity(1000, 1) So, the first row would have id 1001 One can also increase the seed even with some data in the table say already the record run up to 102. If set seed to 200, the next record id would be 201. (one catch is if seed is 1, it will start with 1. But if seed as 11, it will start at 12.) Also one note is that the seed can not be smaller than the existing one as it would not make any changes. (the existing seed number can be check in the property of the column) For reseting the identity seed. The DBCC command is needed like DBCC CHECKIDENT('MyTable', RESEED, 1) It will attempt to start over from 1 and if found some ID with the same number exist, it will skip that ID and use next number. (This is done by the MSSQL in best effort mode. It is not predictable and guaran

Getting started powershell

After installing powershell 1.0. The $profile will not be added. The $profile is equivalent to .profile in ksh where it initialized when it started. So, to add it. You need to specify permission first (like below), then, create the $profile. (you can echo $profile to see where the file resides in the windows) Set-ExecutionPolicy RemoteSigned new-item -path $profile -itemtype file -force

Fix login of restored DB (SQL server 2005)

After when restored Database from *.bak file. The associated login will not be restored into the MSSQL. And when trying to create the same login in the security tab in managemement studio. It will prompt Error 15023: User already exists in current database. The off hand workaround that normally one would do would be drop the user in the database user login and recreate again. like USE YourDB GO EXEC sp_dropuser 'YourRestoredDBLogin' GO The better way would be run command below to check the orphan logins. USE YourDB GO EXEC sp_change_users_login 'Report' GO then below to restored the login with command below. It will retain the settings that you have. USE YourDB GO EXEC sp_change_users_login 'Auto_Fix', 'YourRestoredDBLogin', NULL, 'YourRestoredDBLoginPassword' GO Reference: http://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/

Winmerge - To be able to see non English characters in compare windows

Firstly, Change your windows Language for non-unicode program to the language you want.(In Regional and Language Option in control. refer Windows Help file) Then, In winmerge – Edit – Options – Codepage (tab) Tick ‘According to WinMerge User Interface’ Then, In View – Select Font – choose the font which has needed font script. E.g. CHINESE_GB2312 for simplified chinese Then In winmerge – Edit - Refresh Selected (if you are already viewing something.) and no restart required to see the changes.

Win32 SendMessage equivalent in Javascript

Problem Statement: Custom control written in Javascript can't immediate trigger the onchange event if the textbox control are updated using the code. e.g. ctrl.value = "123"; It will only trigger the onchange when move focus to another control. Solution: Win32 SendMessage equivalent in Javascript IE: element.fireEvent('onchange'); And via DOM2 Events (for Gecko): var evt = document.createEvent('HTMLEvents'); evt.initEvent('change', true, true); element.dispatchEvent(evt);