11 November 2011

This is for my notes only... yeaah. really..

Google Maps V3:
http://code.google.com/apis/maps/documentation/javascript/tutorial.html#LatLng

GeoCoding:
http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding

Get Langitude and Latitude:
http://itouchmap.com/latlong.html

10 September 2011

How To Format String to Double

String format for double
 
// just two decimal places
 String.Format("{0:0.00}", 123.4567);      // "123.46"
 
// max. two decimal places 
 String.Format("{0:0.##}", 123.4567);      // "123.46" 

// Digits before decimal point 
String.Format("{0:00.0}", 123.4567);      // "123.5"
 
// thousand separator 
String.Format("{0:0,0.0}", 12345.67);     // "12,345.7" 

// Align numbers with Spaces
String.Format("{0,10:0.0}", 123.4567);    // "     123.5"
String.Format("{0,-10:0.0}", 123.4567);   // "123.5     "
String.Format("{0,10:0.0}", -123.4567);   // "    -123.5"
String.Format("{0,-10:0.0}", -123.4567);  // "-123.5    "
 
//  Align numbers with spaces
String.Format("{0:0.00;minus 0.00;zero}", 123.4567);   // "123.46"
String.Format("{0:0.00;minus 0.00;zero}", -123.4567);  // "minus 123.46"
String.Format("{0:0.00;minus 0.00;zero}", 0.0);        // "zero"
String.Format("{0:my number is 0.0}", 12.3);   // "my number is 12.3"
String.Format("{0:0aaa.bbb0}", 12.3);          // "12aaa.bbb3"
 


thank you to csharp-examples.net
takken from : http://www.csharp-examples.net/string-format-double/

23 August 2011

Password expired on SQL2008

This really shocking me when i open my website, it displayed an error with reason "The password of the account has expired"

Hastily i open my SQL database using 'sa' and check the login with that account.
It turn out that i check 'Enforce password expiration' on its properties.
And when the time reach the limit, the account cannot login to database.

The solution was just un-check the password expiration on the properties & write again the password.
i refresh the website and wheeuuh...that solved the problem.

:)

30 June 2011

Backup all Databases using cursor

nice article...
this article was takken from http://www.mssqltips.com
thank you..

DECLARE
@name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name

SET @path = 'C:\Backup\'

SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)

DECLARE db_cursor CURSOR FOR
SELECT
name
FROM MASTER.dbo.sysdatabases
WHERE name NOT IN ('master','model','msdb','tempdb')

OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name

WHILE @@FETCH_STATUS = 0
BEGIN
SET
@fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName

FETCH NEXT FROM db_cursor INTO @name
END

CLOSE
db_cursor
DEALLOCATE db_cursor

24 June 2011

Set clr enable on SQL 2008

This is how to enabling clr on sql2008

Type this to your query on related database

exec sp_configure 'clr_enable','1'

RECONFIGURE


25 May 2011

To get string at position

We can use this.. hopefully this help

example we have a variable 'temp' with content like 'XX-YY-ZZ'

string[] variable = temp.Split('-');

we can use this to retrieve each element:
temp[index]

temp[0] = XX
temp[1] = YY
temp[2] = ZZ

24 May 2011

Linq Samples

see here
http://msdn.microsoft.com/en-us/vcsharp/aa336746

Error when opening linq DBML

This surprise me when the error comes up..

It is written : "The operation could not be completed. Unspecified error" & it happened when i open Linq DBML

what's wrong with my project...??
After a little search in google I found that the problem was simple and it was not the fault of the program code too..

You know what..
the solution is just clear all application & system event log on event viewer...

whoalla.. that cure the error

16 May 2011

How to generate increasing record number automatically in sql

When you want to do line/record numbering automatically on your query, simply use 'ROW_NUMBER()' . example:

SELECT ROW_NUMBER() OVER (ORDER BY [field1] asc/desc) as Row_Number, [Otherfields]
FROM [database].[dbo].[table]


that should do it...

21 April 2011

How to delete all stored procedure in your SQL

This might come in handy one day.
especially when too many sp in our database and we want to drop them all.

Create Procedure dbo.DeleteAllProcedures
As
declare @procName varchar(500)
declare cur cursor
for select [name] from sys.objects where type = 'p'
open cur
fetch next from cur into @procName
while @@fetch_status = 0
begin
if @procName <> 'DeleteAllProcedures'
exec('drop procedure ' + @procName)
fetch next from cur into @procName
end
close cur
deallocate cur
Go

25 March 2011

Error on enabling CLR in SQL2005

It happens when i simulate with my new production server. after i move my source web application to the new server, this error show up. the cause of this error that i read is this:
The CLR integration is not enabled by default when we create a stored procedure project in VS 2005,and you deployed in SQL 2005
To enable execution of .Net Code in SQL 2005, this is the script you need, run it in the running instance of SQL 2005; it will enable .net CLR code.

EXEC sp_configure 'clr enabled', 1;

RECONFIGURE WITH OVERRIDE;

GO

To disable execution of .Net Code in SQL 2005, this is the script you need, run it in the running instance of SQL 2005; it will enable .net CLR code.

EXEC sp_configure 'clr enabled', 0;

RECONFIGURE WITH OVERRIDE;

GO

The second way to enable .Net code in SQL 2005 stored procedures, is to use SQL Server Surface Area Configuration.

From Start-> programs -> SQL 2005->Configuration tools ->SQL Surface Area Configuration.

Click with Surface area configuration for features.
Just click on Enable CLR integration and click apply and ok.

taken from http://www.c-sharpcorner.com/UploadFile/dsdaf/CLRSQL20507292006084224AM/CLRSQL205.aspx

Error when login windows 2003 server: Generic host process for win32 services has encountered a problem and needed to close

Once upon the time... I don't know how & why it happens.. suddenly this error show up.













after a few search on google, i found the solution.
follow this steps and this error will disappear.
1. open your notepad.
2. just copy paste this text into your notepad
@ECHO off
ECHO Generic Host Error Removal Tool By Trouble Fixers (www.troublefixers.com)
REM script created by: www.troublefixers.com
reg add HKLM\SYSTEM\CurrentControlSet\Services\netbt\parameters /v TransportBindName /t REG_SZ /d "" /f
reg add HKLM\Software\Microsoft\OLE /v EnableDCOM /t REG_SZ /d "N" /f

REM Following commands can be used to reset the above modified registry values to their default value
REM reg add HKLM\SYSTEM\CurrentControlSet\Services\netbt\parameters /v TransportBindName /t REG_SZ /d "\Device\" /f
REM reg add HKLM\Software\Microsoft\OLE /v EnableDCOM /t REG_SZ /d "Y" /f

ECHO Visit Www.troublefixers.com for more help
Echo Problem Fixed, press any key to continue
pause

3. save it anywhere on your drive.
4. run it. but first, close the error windows that show up earlier.
5. restart your computer. solve the error.

this source was taken from http://www.troublefixers.com/fixed-generic-host-process-for-win32-services-encountered-a-problem-and-needs-to-close-svchostexe-error/
Thanks..

01 March 2011

Error on RSA key container could not be opened

i got this error after i run encrypt-decrypt that i posted earlier in this blog..

After successfully encrypt the web configuration, it seems that everything was fine.
but when i reload/refresh the web page, this error show up.
This error occurs if the user does not have the right to access the key container.

after a few search, i found the solution. this is how to solve it...
1. go to folder 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG' on windows explorer
2. find file 'machine.config' and open it
3. search for key : 'keyContainerName'. the value in my machine : 'NetFrameworkConfigurationKey'
4. Back to windows explore, go to folder: 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727'
5. Give permission to ASPNET by writing this : aspnet_regiis -pa "[KeyContainerNameValue]" "ASPNET"
6. Give permission to Users by writing this : aspnet_regiis -pa "[KeyContainerNameValue]" "Users"

that should do it...

thanks to mr. Sanjay
On this page: http://sanjaysainitech.blogspot.com/2007/06/error-rsa-key-container-could-not-be.html

Best Regards,

Fedrik

10 February 2011

SQL Server 2008 Setup - Failed on Consistency validation for SQL Server registry keys

After running Setup Support Rules on SQL Server 2008, I got this kind of error / failure :
'Failed on Consistency validation for SQL Server registry keys'

After a few search on google, i found this steps that finally was the solution of my problem.
step 1:
- Clean up from SQL things in your computer. Check on 'Add or Remove programs' in your control panel

step 2:
- Open your regedit
- Open : "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009".
       There are 3 Name in it(default, Counter & Help). Copy or memorize the values in it (i write it on notepad).
- Create new key on : "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib" named '00A'
       Add New Multi String Value with name Counter and Help

And that is it. Problem solved
thanks to MauroPreg on http://social.msdn.microsoft.com/Forums/en/sqlsetupandupgrade/thread/5bd40650-1169-47fb-b846-00757477732b
--
Best Regards,

Fedrik J

18 January 2011

Encrypt - Decrypt Web Configuration in .NET application was this easy...WOW. COOL

as follow are the steps to encrypt & decrypt web configuration. using aspnet_regiis.exe, which supports RSA encryption in webfarm scenario

1. Open command prompt
2. From command prompt, You must go to folder: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
3. Write this code to Encrypt : aspnet_regiis.exe -pef "appSettings" "C:\temp".
4. Write this code to Decrypt : aspnet_regiis.exe -pdf "appSettings" "C:\temp".
Note:
- '-pef' means to encrypt; '-pdf' means to decrypt
- 'appSettings' is the section that want to be encrypted
- that folder 'temp' in drive C is the physical location where the web configuration file should exist
5. whoaalaaa... there you go. it was encrypted or decrypted.

phfeww... i thought that it was encrypt/decrypted on other planet...
thanks to http://odetocode.com/blogs/scott/archive/2006/01/08/encrypting-custom-configuration-sections.aspx

Warning: This encrypt can only be decrypt in the same computer and cannot be share to other computer to decrypt.

if you want to share or use other computer to decrypt, you must use custom keys and the RSA provider, for more details klik here: http://msdn2.microsoft.com/en-us/library/68ze1hb2(en-US,VS.80).aspx
or http://www.c-sharpcorner.com/blogs/BlogDetail.aspx?BlogId=229


Best Regards,

Fedrik

08 January 2011

Cannot open list of databases on remote sql2008. The server principal [db_user_name] is not able to access the database "index" under the current security context. (Microsoft SQL Server, Error: 916)

This actually happens on my sql2008 remote server on my web server hosting.
Suddenly i cannot open my database with error like this:
" The server principal [db_user_name] is not able to access the database "index" under the current security context. (Microsoft SQL Server, Error: 916) "

After a short searching & browsing on the net, i found something that help solved the problem (thanks to my.re-invent.com for their knowledgebased).
The cause of this error is because we try to access database that we do not own. This is caused by SQL 2008 Management Studio attempting to query certain system settings that we do not have access to.

Solving problem steps are:
1. Open SQL Management Studio 2008 on your local Computer
2. In the Object Explorer, click "Databases"
3. On Menu, select View | Object Explorer Details
4. Right click on the column headers
5. uncheck the following items:
-Size (MB)
-Database Space Used (KB)
-Index Space Used (KB)
-Space Available (KB)
-Default File Group
-Mail Host
-Collation
6. Right click on databases and select refresh

That will fix the problem.

Twiit.. Twiit... Gulp