Pages

Search This Blog

Saturday, June 14, 2008

Google adsense in between blog in blogger (blogspot)

Below picture show adsense display in between blog. How to create absense in between blog in blogger?



steps:
  1. Login into blogger,
  2. Click on Layout
  3. Click on Edit HTML
  4. Click on Expand Widget Templates




Search the word "post-footer-line post-footer-line-3"

put you adsense before the tag
<div class='post-footer-line post-footer-line-3'/>

example:

..................................................
.................................................
<div>
<script type='text/javascript'>
google_ad_client = "pub-3954566333638548";
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = "468x15_0ads_al";
//2007-10-13: dotnetfish.blogspot.com
google_ad_channel = "8291285977";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0066CC";
google_color_text = "000000";
google_color_url = "0066CC";
</script>
<script src='http://pagead2.googlesyndication.com/pagead/show_ads.js' type='text/javascript'>
</script>
</div>
<div class='post-footer-line post-footer-line-3'/>
......................................
......................................

Done

Microsoft Surface SDK

Microsoft Surface team have not official release public Surface SDK but there is demo in action.


Understand from surface team that there will be two layers, that are Core & WPF. The Core layer supports any .NET UI framework. The WPF layer provides the same functionality as the Core layer and also highly consistent with WPF’s model for input & controls.

Thursday, June 12, 2008

textContent not working in IE, use innerHTML

My javascript is working fine in FireFox and Safari but when use IE (mine is IE7), it's give me problem [Undefined].

.........................
..........................
this.post[i].head = this.posts[i].getElementsByTagName('a')[0];
this.post[i].title = this.post[i].head.textContent;
.......................
......................

Spend hours to check on the issue and finally found a very simple way to solve it, use innerHTML instead of using textContent.

.........................
..........................
this.post[i].head = this.posts[i].getElementsByTagName('a')[0];
this.post[i].title = this.post[i].head.innerHTML;
.......................
......................


problem solve.

Tuesday, June 10, 2008

Result

Monday, June 9, 2008

Internet Explorer cannot open the Internet site http://mail.google.com/mail/. Operation aborted

Recently upgrade to IE7 from IE6. When i try to logon to my Gmail, error message below shown


Internet Explorer cannot open the Internet site http://mail.google.com/mail/


Operation aborted

IE7 is one of the gmail supported browser. http://mail.google.com/support/bin/answer.py?hl=en&answer=6557

I've tried to delete the browser's cookies. It work for me at least until now (2 days) but some of my friend not working. One of the way that always work for me is click on the gmail button from google toolbar.

Official solution from Google:
http://mail.google.com/support/bin/static.py?page=known_issues.cs&knownissue=gmail_issue_ie7operationaborted&topic=12778

Sunday, June 8, 2008

[Exception... "'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e

facing problem [Exception... "'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "" data: no] .


This is cause by calling AJAX file different domain from my current site.Check my previous post

http://dotnetfish.blogspot.com/2007/11/jquery-exception-permission-denied-to.html


Tuesday, May 27, 2008

Searching word in Stored Procedure

Sometime it's very useful if we can search word in Stored Procedure for debugging purposes or etc. Use below script to search with stored procedure using table called "tblLookup"

SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%tblLookup%'
AND ROUTINE_TYPE='PROCEDURE'
ORDER BY ROUTINE_NAME ASC

Friday, May 2, 2008

64-bit or 32-bit / x64 or x84

It's always come to the point that we need to know our system is 64-bit or 32-bit / x64 or x84 when we download some installer or choose installation option.

Below is how we determine 64-bit or 32-bit / x64 or x84 for different windows OS.

Windows Vista

Method 1
1.Click Start, type system in the Start Search box, and then click system in the Programs list.
2.The operating system appears as follows:
• For a 64-bit version operating system: 64-bit Operating System appears for the System type under System.
• For a 32-bit version operating system: 32-bit Operating System appears for the System type under System.

Method 2
1.Click Start, type system in the Start Search box, and then click System Information in the Programs list.
2.The operating system appears as follows:
• For a 64-bit version operating system: x64-based PC appears for the System type under Item.
• For a 32-bit version operating system: x86-based PC appears for the System type under Item.

Microsoft Windows XP Professional

Method 1
1.Click Start, click Run, type sysdm.cpl, and then click OK.
2.Click the General tab. The operating system appears as follows:
• For a 64-bit version operating system: Microsoft Windows XP Professional x64 Edition Version <year> appears under System.
• For a 32-bit version operating system: Microsoft Windows XP Professional Version <year> appears under System. Note is a placeholder for a year.

Method 2
1.Click Start, click Run, type winmsd.exe, and then click OK.
2.In the details pane, locate Processor under Item. Note the value.
• If the value that corresponds to Processor starts with x86, the computer is running a 32-bit version of the Windows operating system.
• If the value that corresponds to Processor starts with ia64 or AMD64, the computer is running a 64-bit version of the Windows operating system.

Microsoft Windows Server 2003

Method 1
Click Start, click Run, type sysdm.cpl, and then click OK.
Click the General tab. The operating system appears as follows:
• For a 64-bit version operating system: Microsoft Windows Server 2003 Enterprise x64 Edition appears under System.
• For a 32-bit version operating system: Microsoft Windows Server 2003 Enterprise Edition appears under System.

Method 2
1.Click Start, click Run, type winmsd.exe, and then click OK.
2.In the details pane, locate Processor under Item. Note the value.
• If the value that corresponds to Processor starts with x86, the computer is running a 32-bit version of the Windows operating system.
• If the value that corresponds to Processor starts with EM64T or ia64, the computer is running a 64-bit version of the Windows operating system.

reference: http://support.microsoft.com/kb/827218

Thursday, May 1, 2008

Invalid use of 'EXECUTE' within a function

I've tried to create a MSSQL "User Defined Functions" with execution of dynamic query (return a final value) and hit error message: "Invalid use of 'EXECUTE' within a function"

The reason is MSSQL not allow execution of dynamic query in "User Defined Functions". Because of this, i need to change from user "User Defined Functions" to "stored procedure" SP by using sp_executesql.

Below show example the Stored Procedure that i use to overcome my problem.

I need my SP to return a calculated value.

CREATE PROCEDURE dbo.psp_GetOCPrice
(
@strSKUNo VARCHAR(50),
@BOMT NUMERIC(9,2),
@OtherCharges NUMERIC(9,2) OUTPUT
)
AS
BEGIN

DECLARE @Count INT,
@Max INT,
@Cost NUMERIC(9,2),
@SQL NVARCHAR(4000),
@Formula NVARCHAR(1000),
@othMainIdn INT,
@othIdn INT


DECLARE @tblOthCharges TABLE
(
ID INT IDENTITY(1,1),
SKUNo VARCHAR(50),
othIdn INT,
othMainIdn INT,
Formula VARCHAR(1000),
Cost NUMERIC(9,2)
)

INSERT INTO @tblOthCharges(SKUNo, othIdn, othMainIdn, Formula)
SELECT sm.SKUNo, sm.pid, sm.ItemGroup,ISNULL(sm.Formula,0) Formula
FROM tblSKUMat sm
WHERE SKUNo = @strSKUNo
AND sm.othCharFlag = 1 ORDER BY sm.seqID ASC

SET @BOMT = ISNULL(@BOMT,0)

SET @Max = (SELECT COUNT(ID) FROM @tblOthCharges)

SET @Count = 1
SET @Cost = 0

SET @SQL = ''

SET @SQL = @SQL + ' DECLARE @BOM NUMERIC(9,2), ' + char(13)
SET @SQL = @SQL + ' @Cost NUMERIC(9,2) ' + char(13)
SET @SQL = @SQL + ' SET @BOM = ' + CONVERT(VARCHAR,@BOMT) + ' ' + char(13)
SET @SQL = @SQL + ' SET @rOtherCharges = 0 ' + char(13)

WHILE @Count <= @Max BEGIN SELECT @Formula = Formula, @othMainIdn = othMainIdn, @othIdn = othIdn FROM @tblOthCharges WHERE ID = @Count

SET @SQL = @SQL + ' SELECT @Cost = ' + CONVERT(VARCHAR,@Formula) + char(13)

SET @SQL = @SQL + ' DECLARE @v' + CONVERT(VARCHAR,@othMainIdn) + '_value NUMERIC(9,2) '


SET @SQL = @SQL
+ char(13)

SET @SQL = @SQL + ' SET @v' + CONVERT(VARCHAR,@othMainIdn) + '_value = ISNULL(@Cost,0) '

SET @SQL = @SQL
+ char(13)

SET @SQL = @SQL + ' SET @rOtherCharges = @rOtherCharges + ISNULL(@Cost,0) ' + char(13)

SET @Count = @Count + 1
END

DECLARE @ParmDefinition NVARCHAR(500);

SET @ParmDefinition = N'@rOtherCharges NUMERIC(9,2) OUTPUT';

EXECUTE sp_executesql
@SQL,
@ParmDefinition,
@rOtherCharges = @OtherCharges OUTPUT;

END

GO

i need to use dynamic query because the field "
Formula" is mathematics expression where involve calculation using value from parameter.
By using
sp_executesql, the value for @rOtherCharges will be assigned to @OtherCharges OUTPUT.

To call this SP, simply call execution

Declare
@OtherCharges
Execute dbo.psp_GetOCPrice 'XIN200805010001', 2000.20, @OtherCharges NUMERIC(9,2)

Done!



Wednesday, April 23, 2008

Create View using Stored Procedure dynamically

We can create view using stored procedure dynamically.

Please find my sample below:

I want to create a view name v_rpt + @Type and @Type as parameter. If the view already exists, it will be drop and recreate a new one.

We will need to execute @SQL twice

  • execution 1: check whether the view exists, drop it if exists
  • execution 2: create a new view
if we put both in the same query, it will hit error "'CREATE VIEW' must be the first statement in a query batch."


CREATE PROCEDURE [dbo].psp_Generate_view
(
@Type VARCHAR(255)
)
AS

BEGIN

SET NOCOUNT ON

DECLARE @SQL VARCHAR(8000)

SET @SQL = ''
SET @SQL = @SQL + 'IF EXISTS (SELECT * FROM dbo.sysobjects WHERE ID = OBJECT_ID(N''[dbo].[v_rpt' + CONVERT( VARCHAR, @Type) + ']'') AND OBJECTPROPERTY(id, N''IsView'') = 1) ' + char(13)
SET @SQL = @SQL + 'DROP VIEW [dbo].[v_rpt' + CONVERT( VARCHAR, @Type) + '] ' + char(13)

EXECUTE (@SQL)

SET @SQL = ''
SET @SQL = @SQL + 'CREATE VIEW dbo.v_rpt' + CONVERT( VARCHAR, @Type) + ' AS ' + char(13)
SET @SQL = @SQL + 'SELECT DISTINCT '
SET @SQL = @SQL + 's.SKUNo, '
SET @SQL = @SQL + 's.Model, '
SET @SQL = @SQL + 'lk1.LookupDesc [Region], '
SET @SQL = @SQL + 'lk2.LookupDesc [Country], '
SET @SQL = @SQL + 'CASE s.Status '
SET @SQL = @SQL + ' WHEN 1 THEN ''Saved'' '
SET @SQL = @SQL + ' WHEN 2 THEN ''Rejected'''
SET @SQL = @SQL + ' WHEN 3 THEN ''Approved'''
SET @SQL = @SQL + 'END AS Status, '
SET @SQL = @SQL + 's.Remark, '
SET @SQL = @SQL + 'u1.FullName [Creator], '
SET @SQL = @SQL + 's.CreDte [Date of Creation], '
SET @SQL = @SQL + 'u2.FullName [UpdatedBy], '
SET @SQL = @SQL + 's.LastUpdDte [Updated On], '
SET @SQL = @SQL + 'FROM tblSKU s '
SET @SQL = @SQL + 'LEFT OUTER JOIN tblUser u1 ON s.OwnerID = u1.UserID '
SET @SQL = @SQL + 'LEFT OUTER JOIN tblUser u2 ON s.LastUserID = u2.UserID '
SET @SQL = @SQL + 'LEFT OUTER JOIN tblLookup lk1 ON s.Region = lk1.RefIdn AND lk1.GroupIdn = 1 '
SET @SQL = @SQL + 'LEFT OUTER JOIN tblLookup lk2 ON s.CTY = lk2.RefIdn AND lk2.GroupIdn = 2 '
SET @SQL = @SQL + 'WHERE '
SET @SQL = @SQL + 's.Type= ' + CONVERT( VARCHAR, @Type) + ' AND '

EXECUTE (@SQL)


SET NOCOUNT OFF
END


Please let me know if you have any comment.