Web application Sharing including ASP, ASP.NET 1.0 (C#) AND ASP.NET 2.0 (C#) MS SQL 2005 Server, Life, Travelling
Wednesday, December 31, 2008
Wednesday, December 24, 2008
Tuesday, December 16, 2008
Lock Windows XP
Here are few steps we can do to lock out computer.
- Go to Desktop, use your mouse right click on your desktop and select "New/Shortcut" from the list
- Once done, copy and paste the command rundll32.exe user32.dll, LockWorkStation and click "Next"
- Give a name to your shortcut before choosing the "Finish" option
Done.
Monday, December 15, 2008
Local Folders have xx new messages
After check on MozillaZine Knowledge Base. I found out that there is one setting that i left out and cause this issue:
My scenarion: I'm using pop mail.
To solve it, go to Tools --> Account Settings ...
Expend the account. Click on Server Settings. Checked/Select Automatically download new messages.
Now i can see my email after receive alert that "Local Folders has 1 new message".
Problem solved!
Sunday, December 14, 2008
SQL Server 2005 Developer Edition at USD49.95
Yes, this is true. Only USD49.95!
Overview for SQL Server 2005 Developer Edition: SQL Server 2005 Developer Edition provides a complete set of enterprise data management and business intelligence features. Because—like Enterprise Edition—it is optimized to run on x64 and Itanium-based servers, it is the most scalable and available edition of SQL Server 2005.
Check out in microsoft store.
Friday, December 12, 2008
AJAX PHP CAPTCHA
Now, we are using the same method to implement in PHP. By reuse the same javascript code with jquery, there is only a small changes in PHP part. Within 20 minutes, the code done and tested working. The files available for download here.
Happy programming. Please let me know if you have any problem.
Sunday, November 30, 2008
Dell Latitude E6400
I have been DELL Latitude fans since i work in DELL early 2004. My first test out was DELL Latitude D600, the following DELL notebook was DELL Latitude D800 and DELL Latitude D620. You may wonder why DELL specifically Latitude
I can give you some reasons:
- The price: it's not too expensive, it's slightly higher than getting a DELL Vostro or DELL Studio. Normally my machine cost is about RM4K - 6K (USD 1.3K - 1.8K)
- The outlook: it's always have cool looking (I'm mention DELL Latitude series, not Inspiron or Vostro). It looks quite elegant with this price.
- The performance: it perform very well, i heavyly use my notebook for programming (.NET, MSSQL, C++), debugging and etc. It still can meet my requirement. My battery can last for 4 hours without charging. This is important for me when meeting customer in cafe and etc.
- The warranty services: this is what i love most but it depend on your warranty that you purchase. I've my next business day warranty service. I call it today, the next day i'll get the warranty parts and the engineer with come to change the part for you without any further questions. Remember to get your warranty service whenever you purchase your notebook. It's important.
My new DELL Latitude E6400 specs:
- Intel(R) Core(TM)2 Duo Processor P8400
- 3 Yrs Next Business Day Onsite Service
- 3Yr CompleteCover
- Dell Wireless 370 Bluetooth(R) 2.1
- Intel WiFi Link 5300 (802.11 a/g/n 3X3) MiniCard
- 4GB (2x2GB) 800MHz DDR2 SDRAM
- 250GB SATA (5400RPM) Hard Drive
- Genuine Windows(R) XP Professional SP3 -Downgrade Vista Business Basic(EMRP)
- 14.1" Widescreen WXGA (1280x800) Display
- Integrated 10/100/1000 Ethernet
- High Definition Audio Codec
- 5-in-1 Media Card Reader
- 8X DVD+/-RW Drive
- Mobile Intel(R) Graphics Media Accelerator X4500HD With Express Card
- Power DVD Software and Media CD
- 56k Internal Modem
- 6-Cell Li-Ion Primary Battery
- 90W AC Adapter
Dell latitude E6400 come with a very cool notebook messenger bag. Light and slim. I bet you will love it.
Tuesday, November 18, 2008
Classic ASP CAPTCHA with JQuery Cross domain AJAX
I downloaded the code and modify the code so that the security checking is before the asp postback. The solution i could thought of is AJAX. When i thought of javascript, the coolest javascript framework will be JQuery.
The decision is go for JQuery in order to perform Ajax with ASP.
There is one concern, the application will need to perform cross domain ajax. If use normal jquery ajax (code below), it will work if all the file reside in the same domain but not when cross domain. Error : Exception... "'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "" data: no] will be displayed.
var html = $.ajax({
url: "/captcha.asp?validateCaptchaCode=" + $("#captchacode").val(),
async: false
}).responseText;
In our case, the file put in different domain. The technics will be use is Cross-Domain getJSON (using JSONP). Sample code below
$.getJSON("captcha.asp?validateCaptchaCode=" + $("#captchacode").val() + "&format=json&jsoncallback=?", function(data)
{
if (data.status == "1")
{ alert("verified and submit.");
$("#form").submit();
result = true;
}
else
{
if (data.session == "0")
RefreshImage("imgCaptcha");
alert("Please key in the security key correctly!");
$("#captchacode").focus();
result = false;
}
});
The Cross-Domain getJSON will espect the data return in Json format. So, my ajax handler file (in my case is captcha.asp) will need to return Json format data for processing.
After develop and tested. It's work. You can download my sample file here and test on it. Please let me know if it's help.
Sunday, November 16, 2008
screnc.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
"screnc.exe has encountered a problem and needs to close. We are sorry for the inconvenience."
In my old machine, everything is working fine (xp pro sp2) but when come to new machine (xp pro sp3), problem occur. Acording to this article, there is no way can be done in xp sp3 unless we install a virtual machine to run it. So, i give up on running this in my new machine.
End up, i run it in my dedicated server which give me cool output file.
IE 7 hang when close the browser
- XP pro SP3
- Intel Core 2 Duo P8400 @ 2.26GHz 791 MHz
- 4GB RAM
- Open IE
- Click on Tools, click on Manage Add-ons -> Enable or Disable Add-ons asd
- Manage Add-ons windows will be pop up.
- Select the add-ons you want to disable.
- Click OK to close the windows
- Close all the IE and start again.
Tuesday, November 11, 2008
Database diagram support objects cannot be installed because this database does not have a valid owner.
Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects.
ALTER AUTHORIZATION ON DATABASE: Database_name TO valid_login
I use SSMS to solve my problem.
In SQL Server Management Studio do the following:
- Right Click on your database, choose properties
- Go to the Options
- In the Dropdown at right labeled "Compatibility Level" choose "SQL Server 2005(90)"
- Go to Files
- Type "sa" in the owner textbox
- Click OK
Alternatively, we can solve it using TSQL:
- My database name: avlDB
- MY Login: sa
EXEC sp_dbcmptlevel 'avlDB', '90';
GO
ALTER AUTHORIZATION ON DATABASE::avlDB TO "sa"
GO
USE [avlDB]
GO
EXECUTE AS USER = N'dbo' REVERT
GO
Monday, November 10, 2008
The memory could not be written
"The instruction at "0×62e2cc0f" referenced memory at "000000000". The memory could not be written. "
Try to work around and suft here and there but not able to find any solution.
Finally System Restore work for me.
To use System Restore to restore Windows XP to a previous state, follow these steps:
- Log on to Windows as Administrator.
- Click Start, point to All Programs, point to Accessories, point to System Tools, and then click System Restore. System Restore starts.
- On the Welcome to System Restore page, click Restore my computer to an earlier time (if it is not already selected), and then click Next.
- On the Select a Restore Point page, click the most recent system restore point in the On this list, click a restore point list, and then click Next.
Note A System Restore message may appear that lists configuration changes that System Restore will make. Click OK. - On the Confirm Restore Point Selection page, click Next. System Restore restores the previous Windows XP configuration, and then restarts the computer.
- Log on to the computer as Administrator. The System Restore Restoration Complete page is displayed.
- Click OK.
Friday, November 7, 2008
SQL Server Setup failed to obtain system account information for the ASPNET
Trying to setup MSSQL 2005 Developer version in my new machine OS Windows XP Profesional SP3, when come to installation point, error message below appear:
"SQL Server Setup failed to obtain system account information for the ASPNET account. To proceed, reinstall the .NET framework, and then run SQL Server Setup again"
Under Add/Remove Programs, i have Framework 1.1, 2.0 and 3.0 installed.
What next? After surf around, here is the solution:
Steps:
1. Click on Start -> Run
2. Type in cmd and click OK
3. Command prompt screen will appear. go to"C:\Windows\Microsoft.NET\Framework\v1.1.4322" folder by using command cd C:\Windows\Microsoft.NET\Framework\v1.1.4322 and hit enter. Please refer screen below:
4. Type in aspnet_regiis -i and hit enter.
5. Screen below will be shown and dotnet user installed.
Try to install MSSQL 2005 again. It's work.
Problem solved.
Wednesday, October 8, 2008
SQL server remap user - blank Login name
finally, i found out that we can use sp_change_users_login to map with login name.
for my case, my database name is HHotel, user login will be 'lam' and password 'l!a2m#'
USE HHotel;
GO
EXEC sp_change_users_login 'Auto_Fix', 'lam', NULL, 'l!a2m#';
GO
It's fixed after run above script.
For more example: http://msdn.microsoft.com/en-us/library/ms174378.aspx
Saturday, September 27, 2008
Change stored proc owner in MSSQL 2000 & 2005
http://dotnetfish.blogspot.com/2008/04/change-table-and-stored-procedure.html
Friday, September 19, 2008
Remove Messenger (MSN or Yahoo) advertisement
My MSN Messenger is Version 2008 (Build 8.5.xxxxx). Go to http://apatch.org/downloads.php and download A-Patch for Windows Live Messenger 8.5. Extract the zip file and run the .exe file. No worry, it's safe. This is a cool patch with preview feature during the selection of unwanted feature. Try it.
Wednesday, September 17, 2008
DllRegisterServer failed with error code 0x80004005 ...
finally i found out that is because of security issue. To solve this,
Go to Start --> All Programs --> Accessories, right-click Command Prompt, and then click Run as Administrator
It's work.
Tuesday, September 16, 2008
Automate SQL 2005 Express Database backup
Sunday, September 14, 2008
osticket - admin login error "Authentication Required"
After browse and google around, i found one solution to enable me to login but i'm not sure what is the effact for this change.
go to scp/staff.inc.php, and find the line below
//1) is the user Logged in for real && is staff.
if(!is_object($thisuser) !$thisuser->getId() !$thisuser->isValid()){
comment out !$thisuser->isValid() and now become
if(!is_object($thisuser) !$thisuser->getId() /* !$thisuser->isValid()*/){
go to try again. it's working. Perhap, someone can tell me what is the issue and i'm not php expert. Not working on 15 Sep 2008
Update: 15 Sep 2008
No Luck. It only work for one day. Not sure what happen and now not working. I'll keep updating this post until get some solution or work around. I have to un comment previous changes.
Solution:
line 41 in scp\login.php, comment out @header("Location: $dest"); and try again.
// @header("Location: $dest");
it's work for me, at least for now.
Update: 21 Sep 2008
It's working fine since changes on 15 Sep 2008. SOLVED!
The user instance login flag is not supported on this version of SQL Server. The connection will be closed.
The reason is my installed database is full version of mssql 2005 and not express version. In order to make it run in my development machine, i have change the connectionstring in tag
<connectionstrings> from
<add name="TDConnectionString" connectionString="data source=.\SQLExpress;Integrated Security=SSPI;AttachDBFilename=DataDirectoryTD.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
to
<add name="TDConnectionString"
connectionString="server=.\SQLSERVER2005;database=TD;uid=xxx;pwd=xxxxx"
providerName="System.Data.SqlClient" />
where ".\SQLSERVER2005" is my database server.
It's works now.
Monday, September 8, 2008
Call VBScript in Javascript
Try this,
<HTML>
<HEAD>
<SCRIPT LANGUAGE=vbscript>
Function vbFunc()
Msgbox("VBScript: Vb function")
End Function
</SCRIPT>
<SCRIPT LANGUAGE=javascript>
function jsFunc()
{
alert("Javascript: jsFunc function");
vbFunc();
}
</SCRIPT>
</HEAD>
<BODY onload="jsFunc()" >
</BODY>
</HTML>
Sunday, September 7, 2008
Streamyx with D-Link 2640T Wireless ADSL Router
For streamyx setting:
- Open your internet browser and go to http://192.168.1.1/, default user name/password: admin/admin
- Click on wizard to run the setting. Click next to begin.
- 1st setting will be "Choose Time Zone", select the one relavent to your time zone. For me, i select [(GMT+08:00) Hong Kong,Perth,Singapore,Taipei] since there is no Kuala Lumpur. Click on Next.
- 2nd setting will be "Select Internet Connection Type (WAN)". For streamyx i select PPPoE/PPPoA and click next.
- 3rd setting is "Set PPPoE / PPPoA". For steamyx user, keyin your user name and password.
User Name: xxx@streamyx
Password: xxxxxxxx
VPI: 0 ---- 8 wont work for me, the status is waiting for response if i choose VPI: 8
VCI: 35
Connection Type: PPPOE LLC - 4th setting is "Set Wireless LAN Connection". This is up to user to set on it. Read the menu correctly.
- Save and restart your router. The status should be "connected" if you check the status tab.
Happy surfing!
Sunday, August 17, 2008
TextArea Newline
and /n but both doestn't work for me. But this &#10; work for me. Forget to mention, i'm using IE7 when do the testing. I'm not sure whether this is browser dependent.
Tuesday, August 12, 2008
ASP.NET: colon in querystring cause error "is not a valid virtual path."
'~/Search.aspx?pageidx=1&Id=:' is not a valid virtual path.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: '~/Search.aspx?pageidx=1&Id=:' is not a valid virtual path.
Understand that in asp.net, virtual path in the URL with colon (:) is not allowed. To solve this problem, i replace the colon (:) with ASCII value for colon &#58; (please check http://www.asciitable.com/) and HttpUtility.UrlEncode on the search key before pass into search.aspx as querystring.
In Search.aspx.cs, do HttpUtility.UrlDecode and pass to DB for searching purposes. Problem solve. Bear in mind that you might need to disable the ValidateRequest (ValidateRequest="false") which may open for dangerous hijack/request.
Monday, August 11, 2008
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Server Error in '/xxxxx' Application.
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the
error and where it originated in the code.
Exception Details: System.InvalidOperationException: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Source Error:Line 89: <%# if (Eval("UserId").ToString().Length != 0) {%>
googling around and not able to find a solution. What i do is i put the if/else condition into a function and pass in UserId as parameter and output the desire output string.
now my line 89: become <%# FormatRatedDisplay(Eval("UserId").ToString())%> and new function FormatRatedDisplay will return a string. I issue solved.
Thursday, August 7, 2008
Microsoft .Net Framework TPM - Virus
Service name: bjvhrz
Display name: bjvhrz
Description: Microsoft .NET Framework TPM
Path to executable: C:\WINDOWS\system32\svchost.exe -k bjvhrz
I'm not able to stop and to disabled it.
To solve it,
- Disable System Restore
- Back up registry
- Restart in Safe Mode
- Open Registry Editor. Click Start>Run, type REGEDIT, then press Enter.
- In the left panel, double-click the following:
HKEY_LOCAL_MACHINE>SYSTEM>CurrentControlSet>Services - Still in the left panel, locate and delete the key:
bjvhrz - Close Registry Editor.
Thursday, July 24, 2008
'HTTP 405 - Resource Not Allowed' in asp
Wednesday, July 9, 2008
Javascript: Shorten for if/else
<html>
<head>
<script language="JavaScript">
function foo()
{
var myGender = "female";
alert((myGender == "male") ? "i am male" : "I am female");
}
</script>
</head>
<body onload="javascript:foo();">
</body>
</html>
Monday, July 7, 2008
Retrieve data from DataTable
for (int i = 0; i < MyDataTable.Rows.Count; i++)
{
string score = MyDataTable.Rows[i]["score"].ToString();
xxxxxx
xxxxxx
}
Thursday, July 3, 2008
W3SVC Restart when changing ASP.NET version in ASP.NET tab (IIS)
If anyone face the same or similar issue, maybe can share your solution.
Zip & FTP database for backup purposes
i need to backup, zip and FTP my database to another server for safety purposes.
My MSSQL database run a daily backup job at 12:00AM to backup folder (E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\) with name: MyDB_backup_200806010000.bak
where 2008 = YYYY, 06 = MM, 01 = DD and 0000 is fixed
my part is zip MyDB_backup_200806010000.bak to MyDB_backup_200806010000.zip and FTP to folder myapp/db in the remote site.
Software: 7zip, core ftp LE (both are free), both can be downloaded free only, google it online and you can get the file downloaded.
Steps:
1. Install Core Ftp LE in the server (my installation folder: c:"\program files\coreftp\coreftp.exe")
2. Open Core Ftp LE and create my FTP site and enter FTP username and password. I name my site mybacksite.
3. Install 7zip in the server. Copy 7z.exe from the installation folder (mine is in C:\Program Files\7-Zip\7z.exe) to database backup folder (mine is in E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\).
4. Write a windows batch script (batch) to perform the zip and ftp process. I name it appDBbackup.bat and put it in (mine is in E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\)
appDBbackup.bat:
@echo Off
for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
for /f "tokens=1" %%u in ('time /t') do set t=%%u
if "%t:~1,1%"==":" set t=0%t%
rem set timestr=%d:~6,4%%d:~3,2%%d:~0,2%%t:~0,2%%t:~3,2%
set datestr=%d:~6,4%%d:~0,2%%d:~3,2%
set timestr=%t:~0,2%%t:~3,2%
7z a -tzip MyDB_backup_%datestr00.zip MyDB_backup_%datestr00.bak
setlocal
c:"\program files\coreftp\coreftp.exe" -s -O -u "E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\MyDB_backup_%datestr00.zip" -site mybacksite -p /myapp/db/
5. Create a windows scheduler to run the job. Point the task to appDBbackup.bat. In my case, i point to E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\appDBbackup.bat and i schedule it at 12:30AM, 30 minutes after the backup started.
to know more on how to create windows scheduler. read this
Done.
Monday, June 30, 2008
C# String.Format - Input string was not in a correct format Error
below are the code that have problem
info = string.Format("{\"name\":\"{0}\",\"img\":\"{1}\",\"href\":\"{2}\"}", Username, PhotoUrl, UserId);
try to figure out here and there and finally found the problem and solution. It's caused by both { and }.
To solve this problem, change { to {{ and } to }}. It will become
info = string.Format("{{\"name\":\"{0}\",\"img\":\"{1}\",\"href\":\"{2}\"}}", Username, PhotoUrl, UserId);
problem solved!
Friday, June 27, 2008
JQuery document ready
You can use
- $(document).ready(function() {
- // put all jQuery code in here.
- });
- $(function() {
- // put all jQuery code in here.
- });
Thursday, June 19, 2008
Google Toolbar for Firefox 3
Saturday, June 14, 2008
Google adsense in between blog in blogger (blogspot)
steps:
- Login into blogger,
- Click on Layout
- Click on Edit HTML
- 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
.........................
..........................
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
Monday, June 9, 2008
Internet Explorer cannot open the Internet site http://mail.google.com/mail/. Operation aborted
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.
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: "
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
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
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
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
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
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.
Tuesday, April 22, 2008
The worst wireless modem router that have ever used
Trust me, don't go to get Aztech modem. You will regrets if you have one.
Aztech DSL600EW ADSL2/2+ Ready Wireless LAN 802.11g is the worst modem that i ever had. The wireless line simply disconnected and need to restart the router, the ADSL frequently disconnected with the service provider, the stupid un-userfriendly interface (even a simple port forwarding takes me hour to configure and yet cannot be done). I bet you will definately throw it out from your house or office.
Saturday, April 19, 2008
VBScript: Open new windows (IE)
use open "url", "target", "options"
example:
Sub fnOpenUrl(url)
open url ,"newWindow", "toolbar=no, menubar=no, status=no, width=830, height=660 titlebar=no, scrollbars=yes, resizable=yes, top=5, left=5 "
End Sub
to call the function
fnOpenUrl("http://www.xincrm.com")
Done.
Thursday, April 17, 2008
DefaultButton for ImageButton not working in firefox
I've been trying to look around and work on the code but it's not working. Don't waste your time for simple problem unless you have plenty of them.
The easiest way is change the ImageButton control to Button control as stated in the article. Put in some css will give the same effect/result in term of display like in ImageButton.
Below is the css that i use for this purposes.
.buttoncss
{
width:98px;
height:43px;
background-color:#FFFFFF;
background-image:url(http://xincrm.com/img/Button.gif);
border-style:none;
cursor:pointer;
}
Try this http://www.pagetutor.com/button_designer/index.html if you want to customize your button css. Very useful for me.
Remember set UseSubmitBehavior for Button control to False in Properties window.
UseSubmitBehavior="False"
it's work for me. My problem solved.
Tuesday, April 15, 2008
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
A generic error occurred in GDI+.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
Source Error:
Line 469: MemoryStream mem = new MemoryStream();
Line 470: resizedImage.Save(mem, jpegICI, encoderParams);
Line 471: resizedImage.Save(filePath + "\\" + fileName, ImageFormat.Jpeg);
Line 472:
Source File: c:\Inetpub\wwwroot\BlogA\Account.aspx.cs Line: 471
Stack Trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +397778
System.Drawing.Image.Save(String filename, ImageFormat format) +69
Account.WarpImageDimensions(String filePath, String fileName, Bitmap imageToSave) in c:\Inetpub\wwwroot\BlogarateNewLayout\Account.aspx.cs:471
Account.ImageButton1_Click(Object sender, ImageClickEventArgs e) in c:\Inetpub\wwwroot\BlogA\Account.aspx.cs:392
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +86
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
in my case:
It's caused by 2 thing:
1. Upload path - i put the wrong path
2. Folder permission - set the correct permission. In my case, i allow write permission for internet user (IUSR_xxxxx).
Problem solved.
Manage/Delete IIS log files using scheduler
Steps:
1. download and install Windows Server 2003 Resource Kit Tools
2. write a bat script
3. create a scheduler
Let look at the details
1. download and install Windows Server 2003 Resource Kit Tools
In order to us it, you need to install it in your server first. Go to microsoft website "Windows Server 2003 Resource Kit Tools" and download it. After finish downloading, you can start to install it.
After finish installation, you can find Forfiles in C:\WINDOWS\system32\forfiles.exe
2. write a bat script
Syntax for forfiles
forfiles [/p Path] [/m SearchMask] [/s] [/c Command] [/d[{+ -}] [{MM/DD/YYYY DD}]]
the details syntax you can get it from technet.
For me, i want to delete the log files date 14 days before. Below are some of the details
- log file location = C:\WINDOWS\system32\LogFiles\W3SVC1
- file type = *.log
- Date to delete = -d -14 (14 days before)
Below is the command that i'm able to come out and save it as .bat format. Say, "managelog.bat"
Forfiles -p C:\WINDOWS\system32\LogFiles\W3SVC1 -s -m *.log -d -14 -c "Cmd /C DEL @File"
copy forfiles.exe from C:\WINDOWS\system32\forfiles.exe and managelog.bat to the same location which you prefer.
3. create a scheduler
You need to create a scheduler to run the job automatically. For me, i run my job weekly at mid night 12:30AM.
To know how to create a window scheduler job, please find reference here.
Please test it before make it run automatically. I suggest that you use below command line to test. I change the DEL to ECHO so that i work safely.
Forfiles -p C:\WINDOWS\system32\LogFiles\W3SVC1 -s -m *.log -d -14 -c "Cmd /C ECHO @File"
Done. Good luck.
Sunday, April 13, 2008
Shrink Database MSSQL
Thursday, April 10, 2008
Forbidden: Execute access is denied
You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed.
Please try the following:
- Contact the Web site administrator if you believe this directory should allow execute access.
HTTP Error 403.1 - Forbidden: Execute access is denied.
Internet Information Services (IIS)
During the application setting up, i miss out one step. That is Executive Permissions. To solve the problem, Select "Scripts Only" or "Scripts and Executables" under Executive Permissions option. Problem solved.
CS0101: The namespace '<global namespace>' already contains a definition for 'xxxxx'
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0101: The namespace '<global namespace>' already contains a definition for 'xxxx'
check whether you have a copy of the file with different name but using the same class (duplicate file). In My case, i have a backup copy for a aspx file. Delete the file or exclude from the project will solve the problem.
Thursday, April 3, 2008
Change Table and Stored Procedure Ownership From xxx to DBO
Script for change table ownership
DECLARE @old sysname, @new sysname, @sql varchar(1000)
SET @old = 'oldOwner'
SET @new = 'dbo'
SET @sql = ' IF EXISTS (SELECT NULL FROM INFORMATION_SCHEMA.TABLES
WHERE
QUOTENAME(TABLE_SCHEMA)+''.''+QUOTENAME(TABLE_NAME) = ''?''
AND TABLE_SCHEMA = ''' + @old + ''' )
EXECUTE sp_changeobjectowner ''?'', ''' + @new + ''''
EXECUTE sp_MSforeachtable @sql
Credit should give to Scott Forsyth
change ownership for stored procedure
DECLARE
@OldOwner sysname,
@NewOwner sysname
SET @OldOwner = 'oldOwner'
SET @NewOwner = 'dbo'
DECLARE CURS CURSOR FOR
SELECT
name
FROM sysobjects
WHERE type = 'p'
AND
uid = (SELECT uid FROM sysusers WHERE name = @OldOwner)
AND
NOT name LIKE 'dt%' FOR READ ONLY
DECLARE @ProcName sysname
OPEN CURS
FETCH CURS INTO @ProcName
WHILE @@FETCH_STATUS = 0
BEGIN
IF @@VERSION >= 'Microsoft SQL Server 2005'
BEGIN
EXEC('alter schema ' + @NewOwner + ' transfer ' + @OldOwner + '.' + @ProcName)
exec('alter authorization on ' + @NewOwner + '.' + @ProcName + ' to schema owner')
END
ELSE
EXEC('sp_changeobjectowner ''' + @OldOwner + '.' + @ProcName + ''', ''' + @NewOwner + '''')
FETCH CURS INTO @ProcName
END
CLOSE CURS
DEALLOCATE CURS
Credit should give to Greg Duffield
Tuesday, April 1, 2008
Ping an IP through a specific port in cmd prompt or telnet
For example:
Go to open command prompt, if we want to check whether port 21 is working for IP 203.166.87.9 what we need to do is
> telnet 203.166.87.9 21
please tell me it's work. thanks
Sunday, March 16, 2008
Visual Studio .NET has detected that the specified Web Server is not running ASP.NET version 1.1. You will be unable to run ASP.NET Web applications o
Visual Studio .NET has detected that the specified Web server is not running ASP.NET version 1.1. You will be unable to run ASP.NET Web applications or services
I suspect some of my newly installed application cause the webserver port change from 80 to others. My case is easy to solve, i uninstall my newly install app called: "Raysource" and it's work and running.
For more information on this error, please check in
http://support.microsoft.com/kb/817267
http://www.dotnetspider.com/kb/Article2476.aspx
Sunday, March 9, 2008
Exclusive access could not be obtained because the database is in use.
Restore Failed For Server 'xxxx' (Microsoft.SqlServer.Smo)
Additional information:
System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use. (Microsoft.SqlServer.Smo)
This is mostly caused by others user/session is using the database at the same time. To check whether got others user accessing the same database, execute SP_WHO will show who is using the database. Execute KILL to kill the process. In my case, i want to kill process with spid = 53
execute SP_WHO -- See which process in running
Execute KILL 53 -- 53 is the process id spid that i want to kill before restore.
In my case, i restore the database using script instead of using the SSMS.
Below is the script that i use to restore without any issue.
RESTORE DATABASE RateMyPosts
FROM DISK = 'C:\Documents and Settings\DEV1\Desktop\RatePosts.bak' WITH REPLACE,
MOVE 'RatePosts' TO
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\RatePosts.mdf',
MOVE 'RatePosts_Log' TO
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\RatePosts_log.ldf'
Saturday, March 1, 2008
VBScript: disabled and enabled button
<head>
<title>VBScript Example: disabled and enabled button</title>
<SCRIPT Language="VBScript">
sub enableButton()
if frm.chkbox_1.checked = true then
frm.btn_1.disabled = false
else
frm.btn_1.disabled = true
end if
end sub
</SCRIPT>
</head>
<body>
<form name=frm>
<input type="checkbox" name="chkbox_1" value="ON" onclick="enableButton()"></input>
<input type="submit" value="I Agree" name="btn_1" disabled></input>
</form>
</body>
</html>
Friday, February 29, 2008
ASP.NET ATOM Feed auto-discovery
Safari:
IE7:
Firefox:
How to do that?
add below code to your rss feed after <?xml version="1.0" ?>
<link rel="alternate" type="application/rss+xml" title="Top new 20 posts rated" href="http://www.xxxx.com/rss" />
or
for ATOM feed
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xxxx="http://www.xxxx.com/">
where http://www.xxxx.com/rss is the feed url
Let me know if you need more info.
Thursday, February 28, 2008
Visual Studio 2005: publish website error - target folder empty
Do you have experience that after you have successfully published your application but the target folder is empty?
- Click "Publish Web Site", enter "Target Location", and click OK
- Site builds successfully
- files in destination directory are deleted
- IDE shows "publish succeeded"
- Go to check target directory, it's empty.
In my case, it caused by mispell an HTML tag. Fix the tag help to fix the published problems.
If this not work for you, try this alternative suggested by other developers.
Fix IIS mappings for ASP.NET, run the Aspnet_regiis.exe utility:
- Click Start, and then click Run.
- In the Open text box, type cmd, and then press ENTER.
- At the command prompt, type the following, and then press ENTER:
"%windir%\Microsoft.NET\Framework\version\aspnet_regiis.exe" -i
In this path, version represents the version number of the .NET Framework that installed on server. Must replace this placeholder with the actual version number when type the command.