viralpatel.info
News: www.viralpatel.info >> blog <new> !
Blog


Twitt this! Email this!
Using boolean logic instead of CASE in WHERE clause of query in MS-SQL
Benefits :
  • Faster Performance
  • Improved Code Readability

Examples :
  • Replace "IF A THEN B " with "(NOT A)or B "
  • Replace "IF A THEN B ELSE C " with "((NOT A)or B) AND (A OR C) "

source : SQL WHERE clauses: Avoid CASE, use Boolean logic








Twitt this! Email this!
Dynamically added contents in hidden "iframe" was surrounded by <pre> tags in Chrome & Firefox.
innerHTML
: fetched added contents with "<pre>" tags

innerText
: fetched the original string ( in Chrome )
: fetched blank string ( in Firefox)

textContent
: fetched the original string ( in Chrome & Firefox)


source : How to remove HTML Tags from a string in Javascript








Twitt this! Email this!
Are you stuck with this error of mysql ?


Mysql #1130 - Host 'localhost' is not allowed to connect to this MySQL server




Cause : trying to set password of mysql.user manually.


mysql>update user set Password='newpwd' where user='root'





Reason:
mysql.user table stores Password in encrypted format.

So, if one attempts to set the Password manually using UPDATE statement, it updates the record as plain text password instead of encrypted password.

When user connects, the server reads the Password value from the user table and decrypts it to match creditials that were sent from the client.




Solution::
Step 1 : Stop the mysql service if it's already running
Step 2 : Create a text file 'mysql-init.txt' with following contents.


UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
FLUSH PRIVILEGES;



  • UPDATE statement updates the mysql.user table with encrypted Password for user 'root'

  • FLUSH statement tells the server to reload the grant tables into memory.


Step 3 : Go to command promt (cmd)


C:\> C:\mysql\bin\mysqld-nt --init-file=C:\mysql-init.txt


The server executes the contents of the file named by the --init-file option at startup, changing each root account password.



reference : dev.mysql.com