the marked safe for scripting which means some activeX control have been authenticated by Microsoft, therefor
Microsoft marked it as a safe script and you can use it less risk.
How to disable message prompt to you
in Internet Explorer menu
1. Tools -> Internet Options
2. Security Tab
3. Select a zone to Internet
4. Custom level
5. ActiveX controls and plug-ins
Script ActiveX controls marked safe for scripting
Wednesday, December 15, 2010
Saturday, December 11, 2010
Convert List or Array to String
// Sample 1 StringBuilder builder = new StringBuilder(); foreach (string value in array) { builder.Append(value); builder.Append(','); }
// Sample 2
string result = string.Join(",", array);
Saturday, November 27, 2010
List all the columns in the database which are used as identity key
-- List all columns which are used as identity key
-- sample1
SELECT SCHEMA_NAME(schema_id) AS schema_name,
t.name AS table_name,
c.name AS column_name
FROM sys.tables AS t
JOIN sys.identity_columns c ON t.OBJECT_ID = c.OBJECT_ID
ORDER BY schema_name, table_name;
....
SET IDENTITY_INSERT [MyTableName] OFF;
source from: http://blog.sqlauthority.com/2008/03/29/sql-server-2005-list-all-column-with-indentity-key-in-specific-database/
-- sample1
SELECT SCHEMA_NAME(schema_id) AS schema_name,
t.name AS table_name,
c.name AS column_name
FROM sys.tables AS t
JOIN sys.identity_columns c ON t.OBJECT_ID = c.OBJECT_ID
ORDER BY schema_name, table_name;
-- On/Off to disable identity key constrain
SET IDENTITY_INSERT [MyTableName] ON;....
SET IDENTITY_INSERT [MyTableName] OFF;
source from: http://blog.sqlauthority.com/2008/03/29/sql-server-2005-list-all-column-with-indentity-key-in-specific-database/
Thursday, November 25, 2010
Query Data Type, Length and other information of table columns
--Query Data Type, Length and other information of table columns
SELECT
OBJECT_NAME(c.OBJECT_ID) TableName
,c.name AS ColumnName
,SCHEMA_NAME(t.schema_id) AS SchemaName
,t.name AS TypeName
,t.is_user_defined
,t.is_assembly_type
,c.max_length
,c.PRECISION
,c.scale
FROM sys.columns AS c
JOIN sys.types AS t ON c.user_type_id=t.user_type_id
WHERE OBJECT_NAME(c.OBJECT_ID) = 'myTableName'
ORDER BY c.OBJECT_ID;
-- Check Table Row Size and Sort by maximum size
-- SQL Server 2000 the Maximum Row Size limit is 8060 Bytes
SELECT OBJECT_NAME (sc.[id]) tablename
, COUNT (1) nr_columns
, SUM (sc.length) maxrowlength
FROM syscolumns sc join sysobjects so on sc.[id] = so.[id]
WHERE so.xtype = 'U'
GROUP BY OBJECT_NAME (sc.[id])
ORDER BY SUM (sc.length) desc
Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database
Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database
From: http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/
-- Query foreign keys from a table
SELECT CONS.CONSTRAINT_CATALOG AS DB
, CONS.CONSTRAINT_SCHEMA AS [SCHEMA]
, CONS.TABLE_NAME AS [TABLE]
, CONS.CONSTRAINT_TYPE AS [TYPE]
, CONS.CONSTRAINT_NAME AS CONST_NAME
, COLS.COLUMN_NAME AS [COLUMN]
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS CONS
LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE COLS
ON CONS.TABLE_NAME=COLS.TABLE_NAME
AND CONS.CONSTRAINT_SCHEMA=COLS.CONSTRAINT_SCHEMA
AND CONS.CONSTRAINT_NAME=COLS.CONSTRAINT_NAME
WHERE CONS.TABLE_NAME='MyTableName'
--This sample have some issue so that some tables is missing in the query result when they without a foreign key.
SELECT
CONSTRAINT_NAME = REF_CONST.CONSTRAINT_NAME,
TABLE_CATALOG = FK.TABLE_CATALOG,
TABLE_SCHEMA = FK.TABLE_SCHEMA,
TABLE_NAME = FK.TABLE_NAME,
COLUMN_NAME = FK_COLS.COLUMN_NAME,
REFERENCED_TABLE_CATALOG = PK.TABLE_CATALOG,
REFERENCED_TABLE_SCHEMA = PK.TABLE_SCHEMA,
REFERENCED_TABLE_NAME = PK.TABLE_NAME,
REFERENCED_COLUMN_NAME = PK_COLS.COLUMN_NAME
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS REF_CONST
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK
ON REF_CONST.CONSTRAINT_CATALOG = FK.CONSTRAINT_CATALOG
AND REF_CONST.CONSTRAINT_SCHEMA = FK.CONSTRAINT_SCHEMA
AND REF_CONST.CONSTRAINT_NAME = FK.CONSTRAINT_NAME
AND FK.CONSTRAINT_TYPE = 'FOREIGN KEY'
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK ON REF_CONST.UNIQUE_CONSTRAINT_CATALOG = PK.CONSTRAINT_CATALOG
AND REF_CONST.UNIQUE_CONSTRAINT_SCHEMA = PK.CONSTRAINT_SCHEMA
AND REF_CONST.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME
AND PK.CONSTRAINT_TYPE = 'PRIMARY KEY'
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE FK_COLS ON REF_CONST.CONSTRAINT_NAME = FK_COLS.CONSTRAINT_NAME
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE PK_COLS ON PK.CONSTRAINT_NAME = PK_COLS.CONSTRAINT_NAME
---- optional:
ORDER BY
1,2,3,4
WHERE PK.TABLE_NAME='something' WHERE FK.TABLE_NAME='something'
WHERE PK.TABLE_NAME IN ('one_thing', 'another')
WHERE FK.TABLE_NAME IN ('one_thing', 'another')
--Sample 2 this sample will list all tables with constrain keys name.
SELECT OBJECT_NAME(parent_obj) table_name, name as key_name
FROM sysobjects WHERE xtype in('F', 'PK')
From: http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/
-- Query foreign keys from a table
SELECT CONS.CONSTRAINT_CATALOG AS DB
, CONS.CONSTRAINT_SCHEMA AS [SCHEMA]
, CONS.TABLE_NAME AS [TABLE]
, CONS.CONSTRAINT_TYPE AS [TYPE]
, CONS.CONSTRAINT_NAME AS CONST_NAME
, COLS.COLUMN_NAME AS [COLUMN]
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS CONS
LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE COLS
ON CONS.TABLE_NAME=COLS.TABLE_NAME
AND CONS.CONSTRAINT_SCHEMA=COLS.CONSTRAINT_SCHEMA
AND CONS.CONSTRAINT_NAME=COLS.CONSTRAINT_NAME
WHERE CONS.TABLE_NAME='MyTableName'
--This sample have some issue so that some tables is missing in the query result when they without a foreign key.
SELECT
CONSTRAINT_NAME = REF_CONST.CONSTRAINT_NAME,
TABLE_CATALOG = FK.TABLE_CATALOG,
TABLE_SCHEMA = FK.TABLE_SCHEMA,
TABLE_NAME = FK.TABLE_NAME,
COLUMN_NAME = FK_COLS.COLUMN_NAME,
REFERENCED_TABLE_CATALOG = PK.TABLE_CATALOG,
REFERENCED_TABLE_SCHEMA = PK.TABLE_SCHEMA,
REFERENCED_TABLE_NAME = PK.TABLE_NAME,
REFERENCED_COLUMN_NAME = PK_COLS.COLUMN_NAME
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS REF_CONST
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK
ON REF_CONST.CONSTRAINT_CATALOG = FK.CONSTRAINT_CATALOG
AND REF_CONST.CONSTRAINT_SCHEMA = FK.CONSTRAINT_SCHEMA
AND REF_CONST.CONSTRAINT_NAME = FK.CONSTRAINT_NAME
AND FK.CONSTRAINT_TYPE = 'FOREIGN KEY'
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK ON REF_CONST.UNIQUE_CONSTRAINT_CATALOG = PK.CONSTRAINT_CATALOG
AND REF_CONST.UNIQUE_CONSTRAINT_SCHEMA = PK.CONSTRAINT_SCHEMA
AND REF_CONST.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME
AND PK.CONSTRAINT_TYPE = 'PRIMARY KEY'
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE FK_COLS ON REF_CONST.CONSTRAINT_NAME = FK_COLS.CONSTRAINT_NAME
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE PK_COLS ON PK.CONSTRAINT_NAME = PK_COLS.CONSTRAINT_NAME
---- optional:
ORDER BY
1,2,3,4
WHERE PK.TABLE_NAME='something' WHERE FK.TABLE_NAME='something'
WHERE PK.TABLE_NAME IN ('one_thing', 'another')
WHERE FK.TABLE_NAME IN ('one_thing', 'another')
--Sample 2 this sample will list all tables with constrain keys name.
SELECT OBJECT_NAME(parent_obj) table_name, name as key_name
FROM sysobjects WHERE xtype in('F', 'PK')
Thursday, November 18, 2010
XML DOM
XMLHttpRequest
http://www.w3.org/TR/XMLHttpRequest/
success: function(data, textStatus, XMLHttpRequest)...
XMLDocument
http://www.w3schools.com/Xml/xml_parser.asp
Convert iframe content to XMLDocument
// for Firefox
var parser = new DOMParser();
var xmlString = (new XMLSerializer()).serializeToString(iframe1.contentDocument.documentElement);
var xDoc = parser.parseFromString(xmlString, "text/xml");
http://www.w3.org/TR/XMLHttpRequest/
// Sample about XMLHttpRequest
jQuery.ajax(...,success: function(data, textStatus, XMLHttpRequest)...
XMLDocument
http://www.w3schools.com/Xml/xml_parser.asp
Convert iframe content to XMLDocument
// for IE
var xDoc = iframe1.contentWindow.document.XMLDocument;// for Firefox
var parser = new DOMParser();
var xmlString = (new XMLSerializer()).serializeToString(iframe1.contentDocument.documentElement);
var xDoc = parser.parseFromString(xmlString, "text/xml");
Thursday, November 4, 2010
Manipulate XML string from iFrame
// get iframe
var iframe = document.getElementById("myIframeId");
var xDoc = null;
// get XmlDocument
// for IE
xDoc = iframe.contentWindow.document.XMLDocument;
// for firefox, chrome, safari,
xDoc = iframe.contentDocument.documentElement;
// Manipulation XmlDocument or XML element node
xDoc.getElementById("elmId");
xDoc.getElementsByTagName("div")[0];
xDoc.getAttribute("name");
xDoc.innerHtml;
xDoc.getElementById("inputTxtId").value;
// for IE
xDoc.innerText;
// for firefox, chrome...
xDoc.textContent;
var iframe = document.getElementById("myIframeId");
var xDoc = null;
// get XmlDocument
// for IE
xDoc = iframe.contentWindow.document.XMLDocument;
// for firefox, chrome, safari,
xDoc = iframe.contentDocument.documentElement;
// Manipulation XmlDocument or XML element node
xDoc.getElementById("elmId");
xDoc.getElementsByTagName("div")[0];
xDoc.getAttribute("name");
xDoc.innerHtml;
xDoc.getElementById("inputTxtId").value;
// for IE
xDoc.innerText;
// for firefox, chrome...
xDoc.textContent;
Friday, October 22, 2010
Solaris Commands Reference
to check mem
mdb -k
::memstat
Samba
to check is the Samba service is running
mdb -k
::memstat
Samba
to check is the Samba service is running
# svcs | grep samba
View state of samba
# svcs samba wins
Stop samba
# svcadm disable svc:/network/samba # svcadm disable svc:/network/wins
Start samba
# svcadm enable svc:/network/samba # svcadm enable svc:/network/wins
Monday, October 18, 2010
Server Application Unavailable in XP IIS
Server Application Unavailable in XP IIS
I google this problem for a while and find out that answers can be variable.
so i list some solution found in net.
if you interest to have a quick view about skeleton and how is app pool works in iis
go here.
When this issue were happen take look to iis log may found some clue.
some solutions that people who finally solved they problems here:
Reinstall dot net for iis
c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe
IIS had not been granted write permissions on the log directory in C:\Windows\System32\Logfiles! I gave IUSR_, IWAM_ and ASPNET write permissions on that directory.
I used aspnet_regiis -ga domain\processusername
This resolved the issue listed above by authorising the ASP.NET process defined in the Machine.config to the IIS Metadata.
Virtual dir Files copy may cause a permission problem, make sure files in virtual dir haveproper proper permission in this two accounts IUSR_xxxx and IWAM_xxxx
I google this problem for a while and find out that answers can be variable.
so i list some solution found in net.
if you interest to have a quick view about skeleton and how is app pool works in iis
go here.
When this issue were happen take look to iis log may found some clue.
some solutions that people who finally solved they problems here:
Reinstall dot net for iis
c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe
- Open a command prompt
- Stop IIS: iisreset /stop
- Change to the .NET Framework 2.0 root directory: C:\winnt\Microsoft.Net\Framework\v2.0.50727\
- Reinstall ASP.NET 2.0 : aspnet_regiis -i .
- Start IIS again after it has been run: iisreset /start
IIS had not been granted write permissions on the log directory in C:\Windows\System32\Logfiles! I gave IUSR_, IWAM_ and ASPNET write permissions on that directory.
I used aspnet_regiis -ga domain\processusername
This resolved the issue listed above by authorising the ASP.NET process defined in the Machine.config to the IIS Metadata.
Virtual dir Files copy may cause a permission problem, make sure files in virtual dir haveproper proper permission in this two accounts IUSR_xxxx and IWAM_xxxx
Wednesday, October 13, 2010
GPRS and MMS Setup for Android
從目錄進入"設定"=>網際網路設定=>選擇WAP(GPRS)設定或者是MMS(多媒體訊息設定)
台哥大GPRS
設定組名稱:TCC
IP地址:010.001.001.002
首頁:http://ewap
連結埠:9201
電路提示:停止
連結網路類型LGPRS
GPRS設定:APN:mms
帳號:wap
密碼:wap
延遲時間:300秒
CSD設定:
電話號碼:+886935120120
連結類型:ISDN
帳號:wap
密碼:wap
延遲時間:300秒
台哥大MMS
設定組名稱:TCCMMS
IP地址:010.001.001.002
訊息伺服器位址:http://mms
連接埠:9201
連結網路類型:GPRS
GPRS設定:APN:mms
帳號:wap
密碼:wap
延遲時間:300秒
CSD:
電話類型:+886935120120
連結類型:ISDN
帳號:mms
密碼:mms
延遲時間:300秒
中華GPRS
設定組名稱:emome
IP地址:010.001.001.001
首頁:http://wap.emome.net
連接埠:9201
電路提示:停止
連結網路類型:GPRS
GPRS設定:APN:emome
帳號/密碼:空白
延遲時間:180秒
CSD設定:跳過不設
中華MMS
設定組名稱:CHTMMS
IP地址:010.001.001.001
訊息伺服器位址:
http://mms.emome.net:8002
連接埠:9201
連接網路類型:GPRS
GPRS設定:APN:emome
帳號密碼:空白
延遲時間:180秒
CSD:跳過不設
記得設定完之後要儲存,
儲存之後要記的啟動,才可以正常運作
還有要記得打去中華或者是台哥大的客服人員說要開通GPRS喔
台哥大GPRS
設定組名稱:TCC
IP地址:010.001.001.002
首頁:http://ewap
連結埠:9201
電路提示:停止
連結網路類型LGPRS
GPRS設定:APN:mms
帳號:wap
密碼:wap
延遲時間:300秒
CSD設定:
電話號碼:+886935120120
連結類型:ISDN
帳號:wap
密碼:wap
延遲時間:300秒
台哥大MMS
設定組名稱:TCCMMS
IP地址:010.001.001.002
訊息伺服器位址:http://mms
連接埠:9201
連結網路類型:GPRS
GPRS設定:APN:mms
帳號:wap
密碼:wap
延遲時間:300秒
CSD:
電話類型:+886935120120
連結類型:ISDN
帳號:mms
密碼:mms
延遲時間:300秒
中華GPRS
設定組名稱:emome
IP地址:010.001.001.001
首頁:http://wap.emome.net
連接埠:9201
電路提示:停止
連結網路類型:GPRS
GPRS設定:APN:emome
帳號/密碼:空白
延遲時間:180秒
CSD設定:跳過不設
中華MMS
設定組名稱:CHTMMS
IP地址:010.001.001.001
訊息伺服器位址:
http://mms.emome.net:8002
連接埠:9201
連接網路類型:GPRS
GPRS設定:APN:emome
帳號密碼:空白
延遲時間:180秒
CSD:跳過不設
記得設定完之後要儲存,
儲存之後要記的啟動,才可以正常運作
還有要記得打去中華或者是台哥大的客服人員說要開通GPRS喔
Monday, October 4, 2010
DateTime and Number Format in C#
int intNum = 13;
String.Format("{0:d4}", intNum); // "0013"
intNum.ToString("D4"); // "0013"
Decimal
// fixed two decimal part
String.Format("{0:0.00}", 123.4567); // "123.46"String.Format("{0:0.00}", 123.4); // "123.40"
String.Format("{0:0.00}", 123.0); // "123.00"
// maximum two decimal part
String.Format("{0:0.##}", 123.4567); // "123.46"
String.Format("{0:0.##}", 123.4); // "123.4"
String.Format("{0:0.##}", 123.0); // "123"
// at least two digits at integer part
String.Format("{0:00.0}", 123.4567); // "123.5"
String.Format("{0:00.0}", 1.4567); // "01.5"
String.Format("{0:00.0}", -1.4456); // "-03.4"
// Align numbers with spaces
// To align numbers to the left use negative number of 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 "
Currency
123.456 ("C3", en-US) -> ($123.456)
-123.456 ("C3", fr-FR) -> -123,456 €
-123.456 ("C3", ja-JP) -> -¥123.456
Decimal
1234 ("D") -> 1234
-1234 ("D6") -> -001234
Fixed-point
1234 ("F1", en-US) -> 1234.0
1234 ("F1", en-US) -> 1234.0
General
-123.456 ("G", en-US) -> -123.456
-1.234567890e-25 ("G", sv-SE) -> -1,23456789E-25
Number
1234.567 ("N", en-US) -> 1,234.57
1234 ("N", en-US) -> 1,234.0
Percent
1 ("P", en-US) -> 100.00 %
-0.39678 ("P1", en-US) -> -39.7 %
Round-trip
123456789.12345678 ("R") -> 123456789.12345678
-1234567890.12345678 ("R") -> -1234567890.1234567
Hexadecimal
255 ("X") -> FF
-1 ("x") -> ff
255 ("x4") -> 00ff
-1 ("X4") -> 00FF
DateTime.ToString() Patterns
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GM
dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK 2006-08-22T06:30:07.7199222-04:00
// create date time 2008-03-09 16:05:07.123 DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);
String.Format("{0:y yy yyy yyyy}", dt); // "8 08 008 2008" year String.Format("{0:M MM MMM MMMM}", dt); // "3 03 Mar March" month String.Format("{0:d dd ddd dddd}", dt); // "9 09 Sun Sunday" day String.Format("{0:h hh H HH}", dt); // "4 04 16 16" hour 12/24 String.Format("{0:m mm}", dt); // "5 05" minute String.Format("{0:s ss}", dt); // "7 07" second String.Format("{0:f ff fff ffff}", dt); // "1 12 123 1230" sec.fraction String.Format("{0:F FF FFF FFFF}", dt); // "1 12 123 123" without zeroes String.Format("{0:t tt}", dt); // "P PM" A.M. or P.M. String.Format("{0:z zz zzz}", dt); // "-6 -06 -06:00" time zone
String.Format("{0:d/M/yyyy HH:mm:ss}", dt); // "9/3/2008 16:05:07" - english (en-US) String.Format("{0:d/M/yyyy HH:mm:ss}", dt); // "9.3.2008 16:05:07" - german (de-DE) // month/day numbers without/with leading zeroes String.Format("{0:M/d/yyyy}", dt); // "3/9/2008" String.Format("{0:MM/dd/yyyy}", dt); // "03/09/2008" // day/month names String.Format("{0:ddd, MMM d, yyyy}", dt); // "Sun, Mar 9, 2008" String.Format("{0:dddd, MMMM d, yyyy}", dt); // "Sunday, March 9, 2008" // two/four digit year String.Format("{0:MM/dd/yy}", dt); // "03/09/08" String.Format("{0:MM/dd/yyyy}", dt); // "03/09/2008"
String.Format("{0:t}", dt); // "4:05 PM" ShortTime String.Format("{0:d}", dt); // "3/9/2008" ShortDate String.Format("{0:T}", dt); // "4:05:07 PM" LongTime String.Format("{0:D}", dt); // "Sunday, March 09, 2008" LongDate String.Format("{0:f}", dt); // "Sunday, March 09, 2008 4:05 PM" LongDate+ShortTime String.Format("{0:F}", dt); // "Sunday, March 09, 2008 4:05:07 PM" FullDateTime String.Format("{0:g}", dt); // "3/9/2008 4:05 PM" ShortDate+ShortTime String.Format("{0:G}", dt); // "3/9/2008 4:05:07 PM" ShortDate+LongTime String.Format("{0:m}", dt); // "March 09" MonthDay String.Format("{0:y}", dt); // "March, 2008" YearMonth String.Format("{0:r}", dt); // "Sun, 09 Mar 2008 16:05:07 GMT" RFC1123 String.Format("{0:s}", dt); // "2008-03-09T16:05:07" SortableDateTime String.Format("{0:u}", dt); // "2008-03-09 16:05:07Z" UniversalSortableDateTime
d | Represents the day of the month as a number from 1 through 31. A single-digit day is formatted without a leading zero |
dd | Represents the day of the month as a number from 01 through 31. A single-digit day is formatted with a leading zero |
ddd | Represents the abbreviated name of the day of the week (Mon, Tues, Wed etc) |
dddd | Represents the full name of the day of the week (Monday, Tuesday etc) |
h | 12-hour clock hour (e.g. 7) |
hh | 12-hour clock, with a leading 0 (e.g. 07) |
H | 24-hour clock hour (e.g. 19) |
HH | 24-hour clock hour, with a leading 0 (e.g. 19) |
m | Minutes |
mm | Minutes with a leading zero |
M | Month number |
MM | Month number with leading zero |
MMM | Abbreviated Month Name (e.g. Dec) |
MMMM | Full month name (e.g. December) |
s | Seconds |
ss | Seconds with leading zero |
t | Abbreviated AM / PM (e.g. A or P) |
tt | AM / PM (e.g. AM or PM |
y | Year, no leading zero (e.g. 2001 would be 1) |
yy | Year, leadin zero (e.g. 2001 would be 01) |
yyy | Year, (e.g. 2001 would be 2001) |
yyyy | Year, (e.g. 2001 would be 2001) |
K | Represents the time zone information of a date and time value (e.g. +05:00) |
z | With DateTime values, represents the signed offset of the local operating system's time zone from Coordinated Universal Time (UTC), measured in hours. (e.g. +6) |
zz | As z but with leadin zero (e.g. +06) |
zzz | With DateTime values, represents the signed offset of the local operating system's time zone from UTC, measured in hours and minutes. (e.g. +06:00) |
f | Represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. |
ff | Represents the two most significant digits of the seconds fraction; that is, it represents the hundredths of a second in a date and time value. |
fff | Represents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value. |
ffff | Represents the four most significant digits of the seconds fraction; that is, it represents the ten thousandths of a second in a date and time value. While it is possible to display the ten thousandths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds. |
fffff | Represents the five most significant digits of the seconds fraction; that is, it represents the hundred thousandths of a second in a date and time value. While it is possible to display the hundred thousandths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds. |
ffffff | Represents the six most significant digits of the seconds fraction; that is, it represents the millionths of a second in a date and time value. While it is possible to display the millionths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds. |
fffffff | Represents the seven most significant digits of the seconds fraction; that is, it represents the ten millionths of a second in a date and time value. While it is possible to display the ten millionths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds. |
F | Represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. Nothing is displayed if the digit is zero. |
: | Represents the time separator defined in the current DateTimeFormatInfo..::.TimeSeparator property. This separator is used to differentiate hours, minutes, and seconds. |
/ | Represents the date separator defined in the current DateTimeFormatInfo..::.DateSeparator property. This separator is used to differentiate years, months, and days. |
" | Represents a quoted string (quotation mark). Displays the literal value of any string between two quotation marks ("). Your application should precede each quotation mark with an escape character (\). |
' | Represents a quoted string (apostrophe). Displays the literal value of any string between two apostrophe (') characters. |
%c | Represents the result associated with a c custom format specifier, when the custom date and time format string consists solely of that custom format specifier. That is, to use the d, f, F, h, m, s, t, y, z, H, or M custom format specifier by itself, the application should specify %d, %f, %F, %h, %m, %s, %t, %y, %z, %H, or %M. For more information about using a single format specifier, see Using Single Custom Format Specifiers. |
Related Link
http://www.csharp-examples.net/string-format-double/
Tuesday, August 17, 2010
How to remove GRUB and restore the Windows bootloader
1. Boot computer from bootable Windows XP CD
2. when the first screen stop and prompt options, press R to repair an existing installation.
3. In the console type commands as below:
C:\> FIXBOOT C:
C:\> FIXMBR
C:\> BOOTCFG /rebuild
Enter Load Identifier: Windows Server 2003, Enterprise
Enter OS Load Options: /fastdetect
4. reboot done!
Related
http://support.microsoft.com/kb/317521/en-us?fr=1
2. when the first screen stop and prompt options, press R to repair an existing installation.
3. In the console type commands as below:
C:\> FIXBOOT C:
C:\> FIXMBR
C:\> BOOTCFG /rebuild
Enter Load Identifier: Windows Server 2003, Enterprise
Enter OS Load Options: /fastdetect
4. reboot done!
Related
http://support.microsoft.com/kb/317521/en-us?fr=1
Monday, July 19, 2010
How to resotre MS SQL backup and fixed user incorect associate to login
When you restore a DB to a new create Database or Users has changed after backup the database, you may notice that user name in the restored database not correctly associate to user in logins.
the SQL Command as below will restore database name call myDb and fix the User user1 associate to user name in Logins.
-- Full backup database , WITH FORMAT says overwrite the bak file if it is already existed.
BACKUP DATABASE myDb
TO DISK = 'd:\backup\myDb.bak'
WITH FORMAT;
GO
-- Restore Sample 1
USE master
RESTORE DATABASE myDb
FROM DISK = 'd:\myDb.bak'
WITH REPLACE
GO
RESTORE HEADERONLY
FROM DISK = 'd:\myDb.bak'
GO
-- 2. List Logical Name from particular file set position in backup file
RESTORE FILELISTONLY
FROM DISK = 'd:\myDb.bak'
WITH FILE = 2
GO
-- MyDB.mdf is data store, MyDB_log.ldf is DB log file
RESTORE DATABASE myDb
FROM DISK = 'd:\myDb.bak'
WITH MOVE 'MyDB' TO 'd:\DB\MyDB.mdf'
,MOVE 'MyDB_log' TO 'D:\DB\MyDB_log.ldf'
,FILE = 2, REPLACE
--
USE myDb
-- the following statement say if login 'test_user' not exist just create it with password.
IF NOT EXISTS(SELECT name FROM master.dbo.syslogins WHERE name = 'test_user')
BEGIN
CREATE LOGIN test_user WITH PASSWORD = 'Password123', CHECK_POLICY = OFF
END
GO
-- Create new user for login
-- for sql server 2005/2008
USE myDb
CREATE USER user1 FOR LOGIN test_user WITH DEFAULT_SCHEMA = dbo
-- for SQL Server 2000
EXEC sp_adduser 'login1', 'user1'
-----------------------------------------------------------------
-- the Syntax of sp_adduser
sp_adduser [ @loginame = ] 'login'
[ , [ @name_in_db = ] 'user' ]
[ , [ @grpname = ] 'group' ]
-- Set default schema to user
USE myDb
ALTER USER user1 WITH DEFAULT_SCHEMA = dbo;
-- Add db_owner role to the user
EXEC sp_addrolemember 'db_owner', 'user1'
------------------------------------------------------------------- the Syntax of sp_change_users_login
sp_change_users_login [ @Action= ] 'action'
-- find out which user connecting the db and kill the spid
-- Show all the users connection include spid.
EXEC sp_who
-- Kill the users who is connecting the db, 52 is spid.
KILL 52
-- Change DB Logic Name
-- display current using DB logic name
select * from sysfiles
See MSDN
the SQL Command as below will restore database name call myDb and fix the User user1 associate to user name in Logins.
-- Full backup database , WITH FORMAT says overwrite the bak file if it is already existed.
BACKUP DATABASE myDb
TO DISK = 'd:\backup\myDb.bak'
WITH FORMAT;
GO
-- Restore Sample 1
USE master
RESTORE DATABASE myDb
FROM DISK = 'd:\myDb.bak'
WITH REPLACE
GO
-- Restore Sample 2
-- 1. List File Set position in backup fileRESTORE HEADERONLY
FROM DISK = 'd:\myDb.bak'
GO
-- 2. List Logical Name from particular file set position in backup file
RESTORE FILELISTONLY
FROM DISK = 'd:\myDb.bak'
WITH FILE = 2
GO
-- 3. Restore data from particular file set position and move backup data to specify location
-- 'MyDB' and 'MyDB_log' is Logical name from step 2. -- MyDB.mdf is data store, MyDB_log.ldf is DB log file
RESTORE DATABASE myDb
FROM DISK = 'd:\myDb.bak'
WITH MOVE 'MyDB' TO 'd:\DB\MyDB.mdf'
,MOVE 'MyDB_log' TO 'D:\DB\MyDB_log.ldf'
,FILE = 2, REPLACE
--
USE myDb
-- the following statement say if login 'test_user' not exist just create it with password.
IF NOT EXISTS(SELECT name FROM master.dbo.syslogins WHERE name = 'test_user')
BEGIN
CREATE LOGIN test_user WITH PASSWORD = 'Password123', CHECK_POLICY = OFF
END
GO
-- Create new user for login
-- for sql server 2005/2008
USE myDb
CREATE USER user1 FOR LOGIN test_user WITH DEFAULT_SCHEMA = dbo
-- for SQL Server 2000
EXEC sp_adduser 'login1', 'user1'
-----------------------------------------------------------------
-- the Syntax of sp_adduser
sp_adduser [ @loginame = ] 'login'
[ , [ @name_in_db = ] 'user' ]
[ , [ @grpname = ] 'group' ]
-- Set default schema to user
USE myDb
ALTER USER user1 WITH DEFAULT_SCHEMA = dbo;
-- Add db_owner role to the user
EXEC sp_addrolemember 'db_owner', 'user1'
-- the 'update_one' is the parameter value of @action in sp_change_users_login
-- the 'test_user' is user name in myDb
-- the 'user1' is login name
-- the third parameter password no require if you specific the first param @action='update_one'
EXEC sp_change_users_login 'update_one', 'test_user', 'user1';------------------------------------------------------------------- the Syntax of sp_change_users_login
sp_change_users_login [ @Action= ] 'action'
[ , [ @UserNamePattern= ] 'user' ]
[ , [ @LoginName= ] 'login' ]
[ , [ @Password= ] 'password' ]
[;]
-- If you got a error while restore db: Exclusive access could not be obtained because the database is in use.-- find out which user connecting the db and kill the spid
-- Show all the users connection include spid.
EXEC sp_who
-- Kill the users who is connecting the db, 52 is spid.
KILL 52
-- Change DB Logic Name
-- display current using DB logic name
select * from sysfiles
-- change logic name
ALTER DATABASE MyDB
MODIFY FILE (NAME =
'MyDB_log' , NEWNAME = 'MyDB2_log');
See MSDN
Sunday, July 11, 2010
How To call a Web service in javascript
By Using jQuery
var params = "{'id':'123','name':'josh'}";
$(document).ready(function()
{
$.ajax({
type: "POST",
url: "/WebService/aspnet_service.asmx/getUserInfoFunc",
data: params,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg)
{
alert(msg.d);
}
,
error: function(result)
{
alert(result.status + ":" + result.statusText);
}
});
});
var params = "{'id':'123','name':'josh'}";
$(document).ready(function()
{
$.ajax({
type: "POST",
url: "/WebService/aspnet_service.asmx/getUserInfoFunc",
data: params,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg)
{
alert(msg.d);
}
,
error: function(result)
{
alert(result.status + ":" + result.statusText);
}
});
});
Microsoft Ajax
<script type="text/javascript" src="/script/MicrosoftAjax.js"></script>
<script type="text/javascript">
function onclickBtn1()
{
var wRequest = new Sys.Net.WebRequest();
wRequest.set_url("/test.aspx?id=3");
wRequest.add_completed(
function(executor, eventArgs)
{
alert(executor.get_responseData());
});
wRequest.invoke();
}
</script>
<script type="text/javascript">
function onclickBtn1()
{
var wRequest = new Sys.Net.WebRequest();
wRequest.set_url("/test.aspx?id=3");
wRequest.add_completed(
function(executor, eventArgs)
{
alert(executor.get_responseData());
});
wRequest.invoke();
}
</script>
How to request URL with login credential in C#
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Credentials = new NetworkCredential(user, password);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Saturday, July 10, 2010
How To Create XML Object in C#
XmlDocument xDoc = new XmlDocument();
XmlElement root = null;
XmlElement node = null;
XmlAttribute att = null;
// Create XML declaration
XmlNode declaration = xDoc.CreateNode(XmlNodeType.XmlDeclaration, null, null);
declaration.Value = "version=\"1.0\" encoding=\"utf-8\"";
xDoc.AppendChild(declaration);
// Create Child Element with two attributes id and name
node = xDoc.CreateElement("node");
att = xDoc.CreateAttribute("id");
att.Value = "100";
node.Attributes.Append(att);
att = xDoc.CreateAttribute("name");
att.Value = "data_100";
node.Attributes.Append(att);
// Create data content which encapesole in <![CDATA[[ ]]> section.
XmlCDataSection CData = xDoc.CreateCDataSection("This text contains some xml escape characters & < > ' \" which encapsolete in CDATA.");
node.AppendChild(CData);
// Create root Element
root = xDoc.CreateElement("root");
root.AppendChild(node);
xDoc.AppendChild(root);
// Get XML string from XmlDocument
string xmlStr = xDoc.outerXml;the result of xmlStr will be like this:
<?xml version="1.0" encoding="utf-8"?>
<root>
<node id="100" name="data_100" >
<![CDATA [This text contains some xml escape characters & < > ' " which encapsolete in CDATA.]]>
</node>
</root>
Thursday, July 8, 2010
Wednesday, July 7, 2010
Regex Samples
// Filter images file name
var regExp = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF|.png|.PNG|.bmp|.BMP)$/;
// Check number format in integer and float, the symbol +, - or
// thousandsprate like(123,456,78.001) is no acceptable.
^((((\d+(\.)?)|(\d*\.\d+))(\d+)?))$
// Check XSS Meta-characters insid the input string. This
// characters and string in the pattern is forbidden in input string.
[\r\n\\'"<>&\u0085]|(?i:\bjavascript|jscript)
var regExp = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF|.png|.PNG|.bmp|.BMP)$/;
// Check number format in integer and float, the symbol +, - or
// thousandsprate like(123,456,78.001) is no acceptable.
^((((\d+(\.)?)|(\d*\.\d+))(\d+)?))$
// Check XSS Meta-characters insid the input string. This
// characters and string in the pattern is forbidden in input string.
[\r\n\\'"<>&\u0085]|(?i:\bjavascript|jscript)
Using command line for Windows Disk Defragmenter
Windows Disk Defragmenter
Copyright (c) 2003 Microsoft Corp. and Executive Software International, Inc.
Usage:
defrag <volume> [-a] [-f] [-v] [-?]
volume drive letter or mount point (d: or d:\vol\mountpoint)
-a Analyze only
-f Force defragmentation even if free space is low
-v Verbose output
-? Display this help text
for example if you want to defrag Dirve D: and analyze onlydefrag D: -a
result is show below:
Windows Disk Defragmenter
Copyright (c) 2003 Microsoft Corp. and Executive Software International, Inc.
Analysis Report
51.16 GB Total, 14.92 GB (29%) Free, 5% Fragmented (10% file fragmentation)
You do not need to defragment this volume.
Copyright (c) 2003 Microsoft Corp. and Executive Software International, Inc.
Usage:
defrag <volume> [-a] [-f] [-v] [-?]
volume drive letter or mount point (d: or d:\vol\mountpoint)
-a Analyze only
-f Force defragmentation even if free space is low
-v Verbose output
-? Display this help text
for example if you want to defrag Dirve D: and analyze onlydefrag D: -a
result is show below:
Windows Disk Defragmenter
Copyright (c) 2003 Microsoft Corp. and Executive Software International, Inc.
Analysis Report
51.16 GB Total, 14.92 GB (29%) Free, 5% Fragmented (10% file fragmentation)
You do not need to defragment this volume.
Friday, July 2, 2010
How To Handdle XSL output HTML charset
Some times we transfrom xsl to html will get a wrong html chartset.
In C# we usually using TextWriter or XmlTextWriter to output a stream from xsl transformation, but the default encoding of the TextWriter and XmlTextWriter have a potential pitfall makes you difficult to fine out the real reason cause the wrong html charset automatically reander by xsl transform.
By defaul TextWriter and XmlTextWriter using UTF-16 encoding, it cause XSL Trasformation automatically generate html charset to UTF-16, What if you already defined html chartset in your xsl you will find out there a duplicated content-type defined in your output html head like this:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-16" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
.....
.....
Solution:
no more best guidance than a real sample code....
string xmlUrl = "http://www.w3schools.com/xsl/cdcatalog.xml";string xslUrl = "http://www.w3schools.com/xsl/cdcatalog.xsl";XmlDocument xDoc = new XmlDocument();
xDoc.Load(new Uri(Request.Url, xmlUrl).ToString());XslCompiledTransform xTrans = new XslCompiledTransform();xTrans.Load(new Uri(Request.Url, xslUrl).ToString());StringBuilder sb = new StringBuilder();
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings()
{
Encoding = Encoding.UTF8
,
// if you don't want any xml declaration output such as <?xml ... ?>
OmitXmlDeclaration = true};
XmlWriter xWriter = XmlTextWriter.Create(sb, xmlWriterSettings);
xTrans.Transform(xDoc, null, xWriter);
// get result there
System.Console.Write(sb.ToString());
xWriter.Close();
xTrans.Transform(xDoc, null, xWriter);
// get result there
System.Console.Write(sb.ToString());
xWriter.Close();
// if you want directly write to response
XmlTextWriter xTxtWriter = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
xTxtWriter.Close();
Tuesday, June 8, 2010
Email raw data format
x-sender: admin@mail.test.com
x-receiver: friend1@mail.test.com
From: <admin@mail.test.com>
To: <friend1@mail.test.com>
Subject: Test mail raw data send
Date: Tue, 7 Jul 1998 13:38:12 +0100
This is a test message
x-receiver: friend1@mail.test.com
From: <admin@mail.test.com>
To: <friend1@mail.test.com>
Subject: Test mail raw data send
Date: Tue, 7 Jul 1998 13:38:12 +0100
This is a test message
This content can seve to a text file and drop it into the \Inetpub\mailroot\Pickup\ folder of the mail server , it will send by the mail server automatically.
Sunday, June 6, 2010
Efficient Data Paging for MS SQL
MS SQL seems missing an pageable functions allows you to query data in a range, for sample if you wanna query 10 data between index of row from 25 to 35 theres no way you can setting a start row and end row just like Mysql.
Fortunately MS SQL geving some tricky way do the same effect by using ROW_NUMBER() function in SQL Server 2005 and later version.
-- First index of row in the page you go.
DECLARE @startRowIndex INT
-- How many rows in a page
-- How many rows in a page
DECLARE @maximumRows INT
-- If you goto page 1 and each page have 10 rows, the index row of page 1 is 1, the index row of page 2 is 21 and so forth.
-- If you goto page 1 and each page have 10 rows, the index row of page 1 is 1, the index row of page 2 is 21 and so forth.
SET @startRowIndex = 1
SET @maximumRows = 10
SET @maximumRows = 10
-- This SQL statement returns 10 of rows data between the rows from @startRowIndex to (@startRowIndex + @maximumRows)-1
SELECT *
FROM
(SELECT *,
ROW_NUMBER() OVER(ORDER BY OrderDate DESC) as RowNum
FROM Northwind.dbo.Orders
) as DerivedTableName
WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @maximumRows) - 1
FROM
(SELECT *,
ROW_NUMBER() OVER(ORDER BY OrderDate DESC) as RowNum
FROM Northwind.dbo.Orders
) as DerivedTableName
WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @maximumRows) - 1
related link:
Friday, June 4, 2010
How to changing Fedora GRUB boot order
to boot the 3rd menu entry as default
modify /boot/grub/menu.lst
change the "default 0" option to "default 2"
Please note the first title entry is 0 and then 1,2,3 etc
default=2
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz ?
hiddenmenu
title Fedora Core (2.6.10-1.741_FC3)
root (hd0,1)
kernel /vmlinuz-2.6.10-1.741_FC3 ro root=LABEL=/
initrd /initrd-2.6.10-1.741_FC3.img
title Fedora Core (2.6.9-1.667)
root (hd0,1)
kernel /vmlinuz-2.6.9-1.667 ro root=LABEL=/
initrd /initrd-2.6.9-1.667.img
title windows xp
rootnoverify (hd0,0)
chainloader +1
modify /boot/grub/menu.lst
change the "default 0" option to "default 2"
Please note the first title entry is 0 and then 1,2,3 etc
default=2
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz ?
hiddenmenu
title Fedora Core (2.6.10-1.741_FC3)
root (hd0,1)
kernel /vmlinuz-2.6.10-1.741_FC3 ro root=LABEL=/
initrd /initrd-2.6.10-1.741_FC3.img
title Fedora Core (2.6.9-1.667)
root (hd0,1)
kernel /vmlinuz-2.6.9-1.667 ro root=LABEL=/
initrd /initrd-2.6.9-1.667.img
title windows xp
rootnoverify (hd0,0)
chainloader +1
How to use TIMESTAMP for Oracle
CURRENT_TIMESTAMP
SELECT CURRENT_TIMESTAMP FROM dual;
SELECT DUMP(SYSTIMESTAMP) FROM dual;
SELECT EXTRACT(YEAR FROM DATE '2007-04-01') FROM dual;
SELECT FROM_TZ(TIMESTAMP '2007-11-20 08:00:00', '3:00') FROM dual;
SELECT FROM_TZ(TIMESTAMP '2007-11-20 19:30:00', '3:00') FROM dual;
SELECT FROM_TZ(TIMESTAMP '2007-11-20 19:30:00', '3:00') FROM dual;
ALTER SESSION SET TIME_ZONE = '-5:00';
SELECT CURRENT_TIMESTAMP, LOCALTIMESTAMP FROM dual;
ALTER SESSION SET TIME_ZONE = '-8:00';
SELECT CURRENT_TIMESTAMP, LOCALTIMESTAMP FROM dual;
CREATE TABLE local_test (col1 TIMESTAMP WITH LOCAL TIME ZONE);
-- The following statement fails because the mask does not include
-- the TIME ZONE portion of the return type of the function:
INSERT INTO local_test VALUES
(TO_TIMESTAMP(LOCALTIMESTAMP, 'DD-MON-RR HH.MI.SSXFF'));
-- The following statement uses the correct format mask
-- to match the return type of LOCALTIMESTAMP:
INSERT INTO local_test VALUES
(TO_TIMESTAMP(LOCALTIMESTAMP, 'DD-MON-RR HH.MI.SSXFF PM'));
SELECT * FROM local_test;
SELECT CURRENT_TIMESTAMP, LOCALTIMESTAMP FROM dual;
ALTER SESSION SET TIME_ZONE = '-8:00';
SELECT CURRENT_TIMESTAMP, LOCALTIMESTAMP FROM dual;
CREATE TABLE local_test (col1 TIMESTAMP WITH LOCAL TIME ZONE);
-- The following statement fails because the mask does not include
-- the TIME ZONE portion of the return type of the function:
INSERT INTO local_test VALUES
(TO_TIMESTAMP(LOCALTIMESTAMP, 'DD-MON-RR HH.MI.SSXFF'));
-- The following statement uses the correct format mask
-- to match the return type of LOCALTIMESTAMP:
INSERT INTO local_test VALUES
(TO_TIMESTAMP(LOCALTIMESTAMP, 'DD-MON-RR HH.MI.SSXFF PM'));
SELECT * FROM local_test;
Thursday, June 3, 2010
How To Resize an IFrame to the Size of Its Contents Without Displaying Scroll Bars
be careful to get the body of iframe from document.getElementById() in ie7.
I span a lot of time in this part, in the first begining i retrive iframe body by document.getElementById("iframe1").document.body
but it always get a fixed size value about 600 from the scrollHeight of body attribute, this is confuse me for a long while, after many researched i realized the reason why scrollHeight get a wrong size.
I span a lot of time in this part, in the first begining i retrive iframe body by document.getElementById("iframe1").document.body
but it always get a fixed size value about 600 from the scrollHeight of body attribute, this is confuse me for a long while, after many researched i realized the reason why scrollHeight get a wrong size.
If you retrive the body in iframe by using document.getElementById("iframe1").document.body, you will get the wrong body reference in ie7, because this reference isn't point to the body of the iframe, it's point to the parent's body of iframe, I wonder is it the bug in ie7?
so how do i get the correct iframe's body the answer is window.iframes["iframe1"].document.body or window.iframes[0].document.body.
the conclusion that is document.getElementById("iframe1") and window.iframes["iframe1"] is not the same object in ie7, if you wanna get iframe object it self you can use document.getElementById("iframe1"), if you want to get the document inside the iframe you should use window.iframes["iframe1"] .
yeha it's quit weird, but it solved the real world problem.
<script type="text/javascript">
var ifrm = null, adjustHeight = 100;
var ifrm = null, adjustHeight = 100;
// Invoke initIfrm() where the page contains iframe element, usually invoke by window.onload event.
function initIfrm()
{
ifrm = document.getElementById(iframeId);
// firefox
if(ifrm.addEventListener)
{
ifrm.addEventListener("load", resizeHeightEvent, false);
}
// IE
else if(ifrm.attachEvent)
{
ifrm.detachEvent("onload", resizeHeightEvent);
ifrm.attachEvent("onload", resizeHeightEvent);
}
}
function resizeHeightEvent()
{
var ifrmBody = null;
function initIfrm()
{
ifrm = document.getElementById(iframeId);
// firefox
if(ifrm.addEventListener)
{
ifrm.addEventListener("load", resizeHeightEvent, false);
}
// IE
else if(ifrm.attachEvent)
{
ifrm.detachEvent("onload", resizeHeightEvent);
ifrm.attachEvent("onload", resizeHeightEvent);
}
}
function resizeHeightEvent()
{
var ifrmBody = null;
// Firefox
if(typeof (ifrm.contentDocument) == "object")
{
ifrmBody = ifrm.contentDocument.body;
}
// IE
else if(typeof (ifrm.document) == "object")
{
ifrmBody = window.frames[ifrm.id].document.body;
}
if(ifrmBody == null)
{
throw "the body not found in the page content, ifrmBody is null.";
}
// Firefox
if(ifrm.contentDocument && ifrmBody.offsetHeight)
{
ifrm.style.height = (ifrm.contentDocument.body.offsetHeight + adjustHeight) + "px";
}
// IE
else if(ifrm.document && ifrmBody.scrollHeight)
{
ifrm.style.height = "100px";
ifrm.style.height = (ifrmBody.scrollHeight + (ifrmBody.offsetHeight - ifrmBody.clientHeight) + adjustHeight) + "px";
}
}
if(typeof (ifrm.contentDocument) == "object")
{
ifrmBody = ifrm.contentDocument.body;
}
// IE
else if(typeof (ifrm.document) == "object")
{
ifrmBody = window.frames[ifrm.id].document.body;
}
if(ifrmBody == null)
{
throw "the body not found in the page content, ifrmBody is null.";
}
// Firefox
if(ifrm.contentDocument && ifrmBody.offsetHeight)
{
ifrm.style.height = (ifrm.contentDocument.body.offsetHeight + adjustHeight) + "px";
}
// IE
else if(ifrm.document && ifrmBody.scrollHeight)
{
ifrm.style.height = "100px";
ifrm.style.height = (ifrmBody.scrollHeight + (ifrmBody.offsetHeight - ifrmBody.clientHeight) + adjustHeight) + "px";
}
}
</script>
In the page declare the iframe like this
<iframe id="iframe1" name="iframe1" scrolling="no" marginwidth="0" marginheight="0"
frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; height:100%;"></iframe>
frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; height:100%;"></iframe>
URL Encoding Reference
URL Encoding Reference
ASCII Character | URL-encoding |
---|---|
space | %20 |
! | %21 |
" | %22 |
# | %23 |
$ | %24 |
% | %25 |
& | %26 |
' | %27 |
( | %28 |
) | %29 |
* | %2A |
+ | %2B |
, | %2C |
- | %2D |
. | %2E |
/ | %2F |
0 | %30 |
1 | %31 |
2 | %32 |
3 | %33 |
4 | %34 |
5 | %35 |
6 | %36 |
7 | %37 |
8 | %38 |
9 | %39 |
: | %3A |
; | %3B |
< | %3C |
= | %3D |
> | %3E |
? | %3F |
@ | %40 |
A | %41 |
B | %42 |
C | %43 |
D | %44 |
E | %45 |
F | %46 |
G | %47 |
H | %48 |
I | %49 |
J | %4A |
K | %4B |
L | %4C |
M | %4D |
N | %4E |
O | %4F |
P | %50 |
Q | %51 |
R | %52 |
S | %53 |
T | %54 |
U | %55 |
V | %56 |
W | %57 |
X | %58 |
Y | %59 |
Z | %5A |
[ | %5B |
\ | %5C |
] | %5D |
^ | %5E |
_ | %5F |
` | %60 |
a | %61 |
b | %62 |
c | %63 |
d | %64 |
e | %65 |
f | %66 |
g | %67 |
h | %68 |
i | %69 |
j | %6A |
k | %6B |
l | %6C |
m | %6D |
n | %6E |
o | %6F |
p | %70 |
q | %71 |
r | %72 |
s | %73 |
t | %74 |
u | %75 |
v | %76 |
w | %77 |
x | %78 |
y | %79 |
z | %7A |
{ | %7B |
| | %7C |
} | %7D |
~ | %7E |
%7F | |
€ | %80 |
%81 | |
‚ | %82 |
ƒ | %83 |
„ | %84 |
… | %85 |
† | %86 |
‡ | %87 |
ˆ | %88 |
‰ | %89 |
Š | %8A |
‹ | %8B |
Œ | %8C |
%8D | |
Ž | %8E |
%8F | |
%90 | |
‘ | %91 |
’ | %92 |
“ | %93 |
” | %94 |
• | %95 |
– | %96 |
— | %97 |
˜ | %98 |
™ | %99 |
š | %9A |
› | %9B |
œ | %9C |
%9D | |
ž | %9E |
Ÿ | %9F |
%A0 | |
¡ | %A1 |
¢ | %A2 |
£ | %A3 |
%A4 | |
¥ | %A5 |
| | %A6 |
§ | %A7 |
¨ | %A8 |
© | %A9 |
ª | %AA |
« | %AB |
¬ | %AC |
¯ | %AD |
® | %AE |
¯ | %AF |
° | %B0 |
± | %B1 |
² | %B2 |
³ | %B3 |
´ | %B4 |
µ | %B5 |
¶ | %B6 |
· | %B7 |
¸ | %B8 |
¹ | %B9 |
º | %BA |
» | %BB |
¼ | %BC |
½ | %BD |
¾ | %BE |
¿ | %BF |
À | %C0 |
Á | %C1 |
 | %C2 |
à | %C3 |
Ä | %C4 |
Å | %C5 |
Æ | %C6 |
Ç | %C7 |
È | %C8 |
É | %C9 |
Ê | %CA |
Ë | %CB |
Ì | %CC |
Í | %CD |
Î | %CE |
Ï | %CF |
Ð | %D0 |
Ñ | %D1 |
Ò | %D2 |
Ó | %D3 |
Ô | %D4 |
Õ | %D5 |
Ö | %D6 |
%D7 | |
Ø | %D8 |
Ù | %D9 |
Ú | %DA |
Û | %DB |
Ü | %DC |
Ý | %DD |
Þ | %DE |
ß | %DF |
à | %E0 |
á | %E1 |
â | %E2 |
ã | %E3 |
ä | %E4 |
å | %E5 |
æ | %E6 |
ç | %E7 |
è | %E8 |
é | %E9 |
ê | %EA |
ë | %EB |
ì | %EC |
í | %ED |
î | %EE |
ï | %EF |
ð | %F0 |
ñ | %F1 |
ò | %F2 |
ó | %F3 |
ô | %F4 |
õ | %F5 |
ö | %F6 |
÷ | %F7 |
ø | %F8 |
ù | %F9 |
ú | %FA |
û | %FB |
ü | %FC |
ý | %FD |
þ | %FE |
ÿ | %FF |
URL Encoding Reference
The ASCII device control characters -%1f were originally designed to control hardware devices. Control characters have nothing to do inside a URL.ASCII Character | Description | URL-encoding |
---|---|---|
NUL | null character | |
SOH | start of header | %01 |
STX | start of text | %02 |
ETX | end of text | %03 |
EOT | end of transmission | %04 |
ENQ | enquiry | %05 |
ACK | acknowledge | %06 |
BEL | bell (ring) | %07 |
BS | backspace | %08 |
HT | horizontal tab | %09 |
LF | line feed | %0A |
VT | vertical tab | %0B |
FF | form feed | %0C |
CR | carriage return | %0D |
SO | shift out | %0E |
SI | shift in | %0F |
DLE | data link escape | %10 |
DC1 | device control 1 | %11 |
DC2 | device control 2 | %12 |
DC3 | device control 3 | %13 |
DC4 | device control 4 | %14 |
NAK | negative acknowledge | %15 |
SYN | synchronize | %16 |
ETB | end transmission block | %17 |
CAN | cancel | %18 |
EM | end of medium | %19 |
SUB | substitute | %1A |
ESC | escape | %1B |
FS | file separator | %1C |
GS | group separator | %1D |
RS | record separator | %1E |
US | unit separator | %1F |
Sunday, May 23, 2010
Deadlock or Stop may happen when Using ServerXMLHTTP or XMLDocument Requests and Load Page to the Same Server
If you are failed to using ServerXMLHTTP send the request or using XMLDocument load a page in the same Server, you have to take look this below...
Using ServerXMLHTTP or WinHTTP objects to make recursive Hypertext Transfer Protocol (HTTP) requests to the same Internet Information Server (IIS) server is not recommended.
If the ServerXMLHTTP or WinHTTP component must send a request to another ASP on the same server, the target ASP must be located in a different virtual directory and set to run in high isolation. Avoid using ServerXMLHTTP or WinHTTP to send a request to an ASP that is located in the same virtual directory.
If all of the ASP worker threads send HTTP requests back to the same Inetinfo.exe or Dllhost.exe process on the server from which the requests are sent, the Inetinfo.exe or Dllhost.exe process may deadlock or stop responding (hang)
for more information see (Do Not Send ServerXMLHTTP or WinHTTP Requests to the Same Server)
How Resolve This Problem
For IIS 6.0 you can create a new application pool, put all the request pages in a virtual directory and set the Application Pool to the new pool.
Saturday, May 15, 2010
XSLT Samples
<List>
<Item name="xslt sample1">
<fieldName>sTitle</fieldName>
<Value>This is Sample fo xslt</Value>
</Item>
<Item name="xslt sample2">
<fieldName>PostDate</fieldName>
<Value>This is Sample fo xslt</Value>
</Item>
</List>
<xsl:value-of select="."/>
<xsl:value-of select="List/Item/@name"/>
<xsl:value-of select=""List/Item[@name='xslt sample2']" />
<xsl:value-of select=""List/Item[fieldName='PostDate']/Value" />
<xsl:value-of select="parent::Item/@srId" />
<xsl:if test="string(number(rssCount))!='NaN'"> .... </xsl:if>
................................................................................................
<xsl:template match="Item/Value">
<xsl:value-of select="text()"/>
</xsl:template>
<!--Get TagName -->
<xsl:value-of select="name()"/>
<xsl:if test="count(Item) < 3"> The Item has less than 3 elements. </xsl:if>
<xsl:if test="count(Item) > 3"> The Item has more than 3 elements. </xsl:if>
<Item name="xslt sample1">
<fieldName>sTitle</fieldName>
<Value>This is Sample fo xslt</Value>
</Item>
<Item name="xslt sample2">
<fieldName>PostDate</fieldName>
<Value>This is Sample fo xslt</Value>
</Item>
</List>
<xsl:value-of select="."/>
<xsl:value-of select="List/Item/@name"/>
<xsl:value-of select=""List/Item[@name='xslt sample2']" />
<xsl:value-of select=""List/Item[fieldName='PostDate']/Value" />
<xsl:value-of select="parent::Item/@srId" />
<xsl:if test="string(number(rssCount))!='NaN'"> .... </xsl:if>
................................................................................................
<xsl:template match="Item/Value">
<xsl:value-of select="text()"/>
</xsl:template>
<!-- HTML textarea closed tag issue-->
<textarea><xsl:text>
</xsl:text></textarea><!--Get TagName -->
<xsl:value-of select="name()"/>
<xsl:if test="count(Item) < 3"> The Item has less than 3 elements. </xsl:if>
<xsl:if test="count(Item) > 3"> The Item has more than 3 elements. </xsl:if>
About Using <!CDATA[[ ... ]]>
If you want to output a text wrapped by <!CDATA[[]]> to another xml, you can do this as below. Some times you want to output it to an HTML through xsl transformer, the transformer will not to proccess the CDATA been output in a text as below.
<script type="text/javascript">
// the transformer result should look like:
// <!--
// Some scripting code here...
// -->
<xsl:text disable-output-escaping="yes"><!--><![CDATA[//><!--</xsl:text>
Some scripting code here...
<xsl:text disable-output-escaping="yes">//-->]]></xsl:text>
// this trans result same as above but more simple and clear
<xsl:comment><![CDATA[
Some scripting code here...
]]> </xsl:comment>
</script>
If you want the xsl output wrapped by <!CDATA[[ ... ]]>, Only one way i knew can do it that is cdata-section-elements.
You can add cdata-section-elements in xsl:output, each cdata-section-elements could contains one valu, but you can
add more than one xsl:output, see the sample.
<xsl:output method="html" cdata-section-elements="title" />
<xsl:output cdata-section-elements="content" />
.....
<xsl:template match="content">
your content here....
</xsl:template>
....
<xsl:apply-templates select="content" />
xsl output is:
<!CDATA[[your content here....]]>
Related http://www.w3schools.com/xsl/default.asp http://msdn.microsoft.com/en-us/library/ms256086%28VS.85%29.aspx http://www.dpawson.co.uk/xsl/sect2/N8413.html http://www.xml.com/pub/a/2003/04/02/trxml.html http://www.brics.dk/~amoeller/XML/transformation/examples.html
Saturday, April 17, 2010
Microsoft SQL Server Management Studio 2008: Error 916
When using Microsoft SQL Server Management Studio 2008 to connect and manage a database
if you clicked the “Database” node within “Object Explorer” may received the message:
The server principal “username” is not able to access the database “databasename” under the current security context. (Microsoft SQL Server, Error: 916)
The server principal “username” is not able to access the database “databasename” under the current security context. (Microsoft SQL Server, Error: 916)
When you clicked the “Database” node in the Object Explorer Panel in the background SQL Server Management Studio 2008 execute an T-SQL query to retrieve a list of databases along with additional information about those databases, one of those information is collation, which didn’t have a permission to do for scan every database.
Fix:
- In Object Explorer, click Databases
- Display “Object Explorer Details” (F7) or “View –> Object Explorer Details”
- Right click the column headers and deselect “collation”
- Refresh Databases.
Tuesday, February 2, 2010
Windows Media Player PARAM Elements
PARAM Elements in an OBJECT Element
Windows Media Player uses the PARAM element to define specific startup conditions for the control. The PARAM element is embedded inside the OBJECT element.
For example, if you want to define whether the autoStart property is True, you would embed the PARAM element inside the OBJECT element.
You can have as many PARAM elements in an OBJECT element as you want. PARAM has two attributes, name and value. Both attributes must be set.
The supported PARAM attributes vary slightly among browsers and mime types. The following table shows the attributes supported by the Internet Explorer and Firefox browsers. The preferred mime type for the Firefox browser is application/x-ms-wmp, however, there are several other mime types that you can use to embed the Player control in a Web page hosted by the Firefox browser. The fourth column of the table shows the attributes that are supported when you use a mime type other than application/x-ms-wmp.
Note The fileName and SRC PARAM elements are supported by the Firefox plug-in, but not by Internet Explorer. They both perform the same function as the URL PARAM element.
See the Object Model Reference for Scripting for more details about the values for each name attribute.
For example, if you want to define whether the autoStart property is True, you would embed the PARAM element inside the OBJECT element.
<OBJECT ID="Player"
CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<PARAM name="autoStart" value="True">
</OBJECT>
The supported PARAM attributes vary slightly among browsers and mime types. The following table shows the attributes supported by the Internet Explorer and Firefox browsers. The preferred mime type for the Firefox browser is application/x-ms-wmp, however, there are several other mime types that you can use to embed the Player control in a Web page hosted by the Firefox browser. The fourth column of the table shows the attributes that are supported when you use a mime type other than application/x-ms-wmp.
PARAM name | Type | Internet Explorer | Firefox with mime type application/x-ms-wmp | Firefox with any other mime type |
autoStart | Boolean, | yes | yes | yes |
balance | Long, -100 to 100, default 0. | yes | yes | yes |
baseURL | String , | yes | yes | yes |
captioningID | String | yes | yes | yes |
currentMarker | Long, default 0 | yes | yes | yes |
currentPosition | Double, default 0 | yes | yes | yes |
defaultFrame | String | yes | no | no |
enableContextMenu | Boolean | yes | yes | yes |
enabled | Boolean | yes | yes | yes |
enableErrorDialogs | Boolean | yes | yes | no |
fileName | String | no | yes | yes |
fullScreen | Boolean | yes | no | no |
invokeURLs | Boolean, default true | yes | no | no |
mute | Boolean | yes | yes | yes |
playCount | Long, 0 to ..n | yes | yes | no |
rate | Double, default 1.0 | yes | yes | yes |
SAMIFileName | String | yes | yes | yes |
SAMILang | String | yes | yes | yes |
SAMIStyle | String | yes | yes | yes |
SRC | String | no | yes | yes |
stretchToFit | Boolean, default false | yes | yes | no |
URL | String | yes | yes | yes |
volume | Long, 0 to ..n | yes | yes | yes |
windowlessVideo | Boolean, default false | yes | yes | yes |
Note The fileName and SRC PARAM elements are supported by the Firefox plug-in, but not by Internet Explorer. They both perform the same function as the URL PARAM element.
See the Object Model Reference for Scripting for more details about the values for each name attribute.
See Also
Thursday, January 28, 2010
Configure Windows XP to Automatically Login
1. At a command prompt, type "control userpasswords2" and press Enter to open the Windows User Accounts application.
2. On the Users tab, clear the Users Must Enter A User Name And Password To Use This Computer check box and then click OK.
3. In the Automatically Log On dialog box that appears, type the user name and password for the account you want to be logged on each time you start your computer.
2. On the Users tab, clear the Users Must Enter A User Name And Password To Use This Computer check box and then click OK.
3. In the Automatically Log On dialog box that appears, type the user name and password for the account you want to be logged on each time you start your computer.
Saturday, January 16, 2010
How to remote connect to SQL Server 2005 by Specific TCP Port
SQL Server 2005 is not configured to accept remote connections. By default.
To allow remote connections, you have to complete all the following steps:
Enable remote connections on the instance of SQL Server that you want to connect to from a remote computer.
To open a port in Windows Firewall
To allow remote connections, you have to complete all the following steps:
- Enable remote connections on the instance of SQL Server that you want to connect to from a remote computer.
- Configure SQL Server to Listen on a Specific TCP Port.
- To open a port in Windows Firewall.
- Connect to SQL Server 2005 by using MS SQL Server Management Studio with port number.
Enable remote connections on the instance of SQL Server that you want to connect to from a remote computer.
- Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
- On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.
- On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply.
Note Click OK when you receive the following message:Changes to Connection Settings will not take effect until you restart the Database Engine service. - On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Service, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.
- In SQL Server Configuration Manager, in the console pane, expand SQL Server 2005 Network Configuration, expand Protocols for <instance name>, and then double-click TCP/IP.
- In the TCP/IP Properties dialog box, on the IP Addresses tab, all the IP addresses available in your computer is listed in here ... IP1, IP2, up to IPAll. Right-click one of address, and then click Properties to identify the IP address that you wish to configure.
- The TCP Dynamic Ports dialog box contains 0, indicating the Database Engine is listening on dynamic ports. Which means they select an available port when the SQL Server service is started. To disable listening dynamic port you can delete the 0 and left the blank.
- In the IPn Properties area box, in the TCP Port box, type the port number you wish this IP address to listen on, and then click OK.
- In the console pane, click SQL Server 2005 Services.
- In the details pane, right-click SQL Server (<instance name>) and then click restart, to stop and restart SQL Server.
To open a port in Windows Firewall
- On the Start menu, click Control Panel.
- In Control Panel, click Network and Internet Connections, and then open Windows Firewall.
- In Windows Firewall, click the Exceptions tab, and then click Add Port.
- In the Add a Port dialog box, in the Name box, type SQL Server <instanceName>.
- In the Port number box, type the port number of the Database Engine instance. Use 1433 for the default instance. Type 1500 if you are configuring a named instance and configured a fixed port to 1500 . Verify that TCP is selected, and then click OK
- Open SQL Server Management Studio, In the Connect to Server dialog box, in the Server Name box type xxx.xxx.xxx.xxx\SQLEXPRESS,1500.
- type user name and password to connect to server.
Subscribe to:
Posts (Atom)