Wednesday, 2 December 2009

VS 2003 Find in Files

As anyone running Windows Vista will probably have noticed, the Find in Files feature hangs when running Visual Studio 2003 on Vista.

To resolve this issue:

  • Right-click the shortcut you use to launch Visual Studio .NET 2003
  • Select the Compatibility tab.
  • Check “Disable Visual Styles”
  • Click OK
  • Launch VS 2003 – the Find in Files feature will work.

Tuesday, 1 December 2009

Load SQL Server Client Network Utility

The SQL Server Client Network Utility for managing protocols, aliases and network libraries can be launched by either enter cliconfg in the Start menu search box (Vista and Windows 7), by entering cliconfg in the Start>Run box (XP) or launching it directly from system32: C:\Window\System32\cliconfg.exe

DHtmlEd.ocx control for Windows Vista

Microsoft removed the DHtmlEd control from Vista as clearly no-one was still using it!

Download it from Microsoft here:

http://www.microsoft.com/downloads/details.aspx?FamilyId=B769A4B8-48ED-41A1-8095-5A086D1937CB&displaylang=en

Reorganize files before releasing unused space

OK, what does it actually mean!

When shrinking a database in SQL you are presented with the option “Reorganize files before releasing unused space. Selecting this option may affect performance.”

If ticked it is the equivalent of running DBCC SHRINKDATABASE with a target_percent set, if it is unticked it is the equivalent of DBCC SHRINKDATABASE with the TRUNCATEONLY option.

Ticking the box may affect performance while shrinking the database so it may take longer BUT it will not affect the performance of the database once shrunk.

Improve SQL Server delete performance with views

The SQL Server development customer advisory team met with the MySpace database to team to tackle any pain points with their use of SQL Server. Fortunately one of the key points was an issue I am currently battling with: efficient ordered deletes on large quantities of data. They have identified a potential improvement creating a view and then deleting from within that view rather than deleting directly from the table. As MySpace are dealing with huge volumes of data and it works for them it has to be worth incorporating into any deletion plan.
This approach also provides an excellent way for deleting the top x records from a table.
Essentially:
create view v1 as (select top (10000) * from t1 order by a)
delete from v1
drop view v1

Full details from LuborK here >>

It is also worth considering disabling any indexes related to the table you are deleting from as described here.

How to enable and disable indexes

Whilst working to speed up a delete statement on a table of 6000000+ records it proved efficient to disable the table indexes, run the delete statement then enable the indexes again. If the indexes are left enabled there is a large overhead in rebuilding the indexes for each record that is deleted from the target table.

Disable an index:

alter index <<index name>> on <<table name>> disable

Enable an index:

alter index <<index name>> on <<table name>> rebuild

Please be aware the ALTER INDEX command is only available in SQL Server 2005 and above.

Also, SQL Server Management Studio doesn’t show the disabled status of an index within the main view so it is possible to disable an index and leave it disabled without realising.

More details on this from Decipher Info Sys

Acrobat.com Features

Features
Acrobat.com includes an online PDF converter so you can easily create Adobe® PDF documents from your existing files in Microsoft® Word, Excel®, PowerPoint®, and many other applications.

View and print PDF files across platforms that look exactly like the original documents regardless of the application used to create them.

Individuals, businesses and government agencies around the world trust and rely on PDF to communicate their ideas and vision.

https://acrobat.com/

Saturday, 21 November 2009

Friday, 20 November 2009

AJAX Wait Image Generator

I had been searching for an AJAX wait graphic. This site offers a simple tool for generator wait graphics in a number of different styles and any colour: http://www.ajaxload.info/

Friday, 13 November 2009

T-SQL month name from month index

How to display a month name from an input of a month index (i.e. 1-12).

The script below will return the month name for a given month index.

DECLARE @MonthID int

SET @MonthID = 5

SELECT DateName(month, convert(datetime, '2009-' + cast(@MonthID as varchar) + '-01', 120))

@MonthID could be any integer I have only declared a new variable here for completeness.

Wednesday, 11 November 2009

SQL Server Set Identity Seed

DBCC CHECKIDENT (table_name, RESEED, new_reseed_value)

E.g.
DBCC CHECKIDENT (Customers, RESEED, 2000)

From Microsoft: Checks the current identity value for the specified table and, if it is needed, changes the identity value. You can also use DBCC CHECKIDENT to manually set a new current identity value for the identity column.

Full article: http://technet.microsoft.com/en-us/library/ms176057.aspx

IIS Change the key length for an SSL renewal

*** IIS 6 ***

When applying for an SSL certificate renewal and the old certificate uses a 512 bit key length you may receive the following error: "The CSR you submitted has a 512 bit key size. We do not allow SSL Web Server certificate issued with a CSR less than 1024 bits."

There is no way within IIS to change the key length but the workaround is as follows:

1. Create a new website under IIS. Make sure the website is stopped.
2. Edit the new site.
3. Select the "Directory Security" tab.
4. Click "Server Certificate"
5. Click "Next"
6. Select "Create a new certificate"
7. Click "Next"
8. Select "Prepare the request now, but send it later".
9. Click "Next"
10. Enter a name for the new request and select a bit length of 1024.
11. Click "Next".
12. Enter the organisation name and organisational unit for the website you are attempting to renew.
13. Click "Next".
14. Enter the exact domain name for the website you are attempting to renew.
15. Click "Next".
16. Enter the business country, state and city.
17. Click "Next".
18. Select a save location for the CSR.
19. Complete the wizard.
20. Submit the new CSR with your renewal request - this should be accepted.
21. When you receive the new certificate complete the renewal on the temporary site created in step 1.
22. Edit the main site that requires the renewed certificate.
23. Select the "Directory Security" tab.
24. Click "Server Certificate"
25. Click "Next".
26. Select "Replace the current certificate".
27. Click "Next".
28. Select the new certificate completed in step 21.
29. Click "Next" and complete the wizard.
30. Click "OK".
31. Delete the temporary site created in step 1.

Tuesday, 10 November 2009

Serving FLV video files from an MS server

When serving .flv files off of a Windows Server 2003 (or any other Windows server I would imagine) requires setting up the MIME type on the server first (it isn't one of the native MIME types on MS servers).

1) Select the site to configure in IIS, right click and select "Properties"
2) Under the "HTTP Headers" Tab, click "MIME Types" under the MIME types section
3) Click "New."
4) Type ".flv" as the associated extension and "video/x-flv" as the content type.
5) Click "OK"
6) Click "OK"

Thursday, 5 November 2009

CF tag to force page charset character set

If you need to force a ColdFusion page to return a specific character set use the following tag:

<cfcontent type="text/html; charset=iso-8859-1">

and substitute the type attribute accordingly.

Wednesday, 16 September 2009

SQL Express 2008 Install Consistency Rule Failed



Oh happy days - SQL Express 2008 has failed to install with the following error:

"Rule 'Consistency validation for SQL Server registry keys' failed". The SQL Server registry keys from a prior installation cannot be modified. To continue, see SQL Server Setup documentation about how to fix registry keys.

The most likely cause is registry permissions, DO NOT try some users advice of uninstalling all copies of SQL Server, at least not until you have checked the registry permissions.

You will find the installation log in Program Files\Microsoft SQL Server\100\Setup Bootstrap\LOG folder. Open the log and check for any errors in the steps relating to registry key checks/updates. If the errors relate to security or access permissions this is your problem. Open registry editor, locate the key indicated in the install log, right-click and select Permissions, change the permissions at the very least local administrators have full access. After doing this for each affected key try the install again.

Monday, 14 September 2009

IE Cross Browser Compatibility Testing

Microsoft really have got into the spirit of free software lately. If you aren't already using Expression Studio 3 then Microsoft have provided a free version of their SuperPreview tool that allows quick comparisons of site designs between different browser versions.

More details from Mike Ormond:

http://blogs.msdn.com/mikeormond/archive/2009/09/11/simplifying-cross-browser-compatibility-testing.aspx

Wednesday, 9 September 2009

MSDN FREE Firestarter Events

image

MSDN are hosting a couple of free events in the next few weeks to enhance developers skills. The events are in the US (OK so not very practical to attend in person) but will also be web cast so you can dip in and out whenever you wish.

All times below are PST.

Silverlight – Thursday 17/09/2009

8:45 am - 9:00 am
Event Kick Off
Mithun Dhar

9:00 am - 10:00 am
Keynote
Scott Guthrie

10:00 am - 11:00 am
Key Silverlight Scenarios
Tim Heuer

11:00 am - 11:15 am
Break

11:15 am - 12:15 pm
Expression 3 Overview
(Includes Behaviors)
Adam Kinney

12:15 pm - 1:00 pm
Lunch Break

1:00 pm - 1:30 pm
Sketch Flow
Janete Perez

1:30 pm - 2:30 pm
Toolkit & Controls
Justin Angel/
Shawn Oster

2:30 pm - 3:30 pm
RIA Services
Brad Abrams

3:30 pm - 3:45 pm
Break

3:45 pm - 4:30 pm
Building Silverlight UIs with XAML Power toys
Karl Shifflett

4:30 pm - 5:00 pm
Q&A Panel
All Speakers

 

ASP.NET MVC – Saturday 03/10/2009

8:30 am - 9:00 am
Check-in/ Breakfast

9:00 am - 9:10 am
Kick-Off

9:10 am - 10:45 am
Intro to ASP.NET MVC & the MVC Design Pattern

10:45 am - 11:00 am
Break

11:00 am - 11:45 am
Framework Fundamentals & Practices

11:45 am - 12:30 pm
Routing & Controllers

12:30 - 1:15 pm
Lunch

1:15 pm - 2:00 pm
Rendering Markup

2:00 pm - 3:15 pm
Working with Data

3:15 pm - 3:30 pm
Break

3:45 pm - 5:00 pm
ASP.NET MVC and AJAX

5:00 pm - 5:15 pm
Wrap-up & Giveaways

Full details: http://www.msdnevents.com/firestarter/index.html

Tuesday, 8 September 2009

String.PadLeft() Total Length Clarification



Very quick note on String.PadLeft() to clear up some confusion. The specified total length is actually the minimum total length for the string.

E.g.

"5".PadLeft(2, Convert.ToChar("0"))
Output = 05

"55".PadLeft(2, Convert.ToChar("0"))
Output = 55

"555".PadLeft(2, Convert.ToChar("0"))
Output = 555

Microsoft documentation: http://msdn.microsoft.com/en-us/library/system.string.padleft.aspx

Tuesday, 18 August 2009

Tuesday, 28 July 2009

New Silverlight Toolkit v3

There's a new toolkit to go with Silverlight 3, essential if you are thinking of any serious development.

Full details from Mike Taulty: http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/07/27/the-silverlight-3-toolkit.aspx

Or download the toolkit straight from CodePlex: http://www.codeplex.com/Silverlight

Thursday, 16 July 2009

Windows Azure Pricing

This just dropped in. Courtesy of http://geekswithblogs.net/iupdateable/archive/2009/07/15/azure-pricing-and-sla-announcements-plus-details-on-the-two.aspx

Full pricing details: http://www.microsoft.com/azure/pricing.mspx

Prices:
Windows Azure:

* Compute = $0.12 / hour
* Storage = $0.15 / GB stored / month
* Storage Transactions = $0.01 / 10K
* Bandwidth = $0.10 in / $0.15 out / GB

SQL Azure:

* Web Edition Up to 1 GB relational database = $9.99
* Business Edition Up to 10 GB relational database = $99.99
* Bandwidth = $0.10 in / $0.15 out / GB

.Net Services:

* Messages = $0.15/100K message operations , including Service Bus messages and Access Control tokens
* Bandwidth = $0.10 in / $0.15 out / GB

Friday, 3 July 2009

Shipping an application with SQL Server Express 2008 - Rights

Shipping an application with SQL Server Express 2008? Don't forget to register for free redistribution rights: http://www.microsoft.com/sqlserver/2008/en/us/express/redistregister.aspx

Quoted from Microsoft:

This redistribution license agreement grants you the right to redistribute with your software application the following components:

*SQL Server 2008 Express
*SQL Server 2008 Express with Advanced Services
*SQL Server 2008 Express with Tools

Helpful download links for SQL Server Express 2008 Prerequisites

Windows Installer 4.5: http://www.microsoft.com/downloads/details.aspx?FamilyID=5a58b56f-60b6-4412-95b9-54d056d6f9f4&displaylang=en

.NET 3.5 SP1: http://download.microsoft.com/download/2/0/e/20e90413-712f-438c-988e-fdaa79a8ac3d/dotnetfx35.exe
SQL Server Express 2008 Redistributable: http://www.microsoft.com/downloads/details.aspx?FamilyID=58ce885d-508b-45c8-9fd3-118edd8e6fff&DisplayLang=en

Enable Samesite for the .NET Framework 3.5 SP1 bootstrapper package

Lifted from the full VS 2008 SP1 http://download.microsoft.com/download/A/2/8/A2807F78-C861-4B66-9B31-9205C3F22252/VS2008SP1Readme.htm#General%20Issues as I have seen quite a few people run into this.

If the .NET Framework 3.5 SP1 bootstrapper package is selected in the Prerequisite dialog box for a Setup project or in ClickOnce publishing, and also the "Download prerequisites from the same location as my application" option is selected, the following build error is shown:

The install location for prerequisites has not been set to 'component vendor's web site' and the file 'dotNetFx35setup.exe' in item 'Microsoft.Net.Framework.3.5.SP1' cannot be located on disk.

To resolve this issue:

Update the Package Data
  1. Open the [Program Files]\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 folder or %ProgramFiles(x86)%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 on x64 operating systems
  2. Edit the Product.xml file in Notepad.
  3. Paste the following into the < PackageFiles > element:
    < PackageFile Name="TOOLS\clwireg.exe" />
    < PackageFile Name="TOOLS\clwireg_x64.exe" />
    < PackageFile Name="TOOLS\clwireg_ia64.exe" />
  4. Find the element for < PackageFile Name="dotNetFX30\XPSEPSC-x86-en-US.exe" and change the PublicKey value to: 3082010A0282010100A2DB0A8DCFC2C1499BCDAA3A34AD23596BDB6CBE2122B794C8EAAEBFC6D526C232118BBCDA5D2CFB36561E152BAE8F0DDD14A36E284C7F163F41AC8D40B146880DD98194AD9706D05744765CEAF1FC0EE27F74A333CB74E5EFE361A17E03B745FFD53E12D5B0CA5E0DD07BF2B7130DFC606A2885758CB7ADBC85E817B490BEF516B6625DED11DF3AEE215B8BAF8073C345E3958977609BE7AD77C1378D33142F13DB62C9AE1AA94F9867ADD420393071E08D6746E2C61CF40D5074412FE805246A216B49B092C4B239C742A56D5C184AAB8FD78E833E780A47D8A4B28423C3E2F27B66B14A74BD26414B9C6114604E30C882F3D00B707CEE554D77D2085576810203010001
  5. Find the element for < PackageFile Name="dotNetFX30\XPSEPSC-amd64-en-US.exe" and change the PublicKey value to the same as in step 4 above
  6. Save the product.xml file



Download and Extract the Core Installation Files
  1. Navigate to the following URL: http://go.microsoft.com/fwlink?LinkID=118080
  2. Download the dotNetFx35.exe file to your local disk.
  3. Open a Command Prompt window and change to the directory to which you downloaded dotNetFx35.exe.
  4. At the command prompt, type:
    dotNetFx35.exe /x:.
    This will extract the Framework files to a folder named “WCU” in the current directory.
  5. Copy the contents of the WCU\dotNetFramework folder and paste them in the %Program Files%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 folder (%ProgramFiles(x86)%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 on x64 operating systems). Note: Do not copy the WCU\dotNetFramework folder itself. There should be 5 folders under the WCU folder, and each of these should now appear in the DotNetFx35SP1 folder. The folder structure should resemble the following:
    o DotNetFx35SP1 (folder)


    • dotNetFX20 (folder
    • dotNetFX30 (folder)
    • dotNetFX35 (folder)
    • dotNetMSP (folder)
    • TOOLS folder)
    • en (or some other localized folder)
    • dotNetFx35setup.exe (file)


You may now delete the files and folders you downloaded and extracted in steps 2 and 4.

Visual Studio 2005 Bootstrapper - Using Packages from VS 2008

Visual Studio 2005 bootstrapper packages folder: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages

The later, VS 2008, packages can be used in VS 2005 by installing the latest Windows SDK then copying the packages from C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages into the folder listed above for Visual Studio 2005. Launch a new setup project in VS 2005 and the packages will be available as prerequisites.

Monday, 22 June 2009

WSE 2 configuration error

If you have received an error similar to the one below, just make sure you have installed WSE 2 on the target server!!!

Download WSE 2 from here: http://www.microsoft.com/Downloads/details.aspx?familyid=1BA1F631-C3E7-420A-BC1E-EF18BAB66122&displaylang=en

Configuration Error
Description: An error occurred during the processing of a configuration file
required to service this request. Please review the specific error details
below and modify your configuration file appropriately.

Parser Error Message: The 'type' attribute must be set to a valid type name.

Source Error:

Line 79:
Line 80:
Line 81:
Line 82:

Line 83:

VS 2005 CS0030: Cannot convert type Login

If you are getting an error like the one below then ASP.NET then checkout http://www.groupsrv.com/dotnet/about147910.html

If the site has been published and has been marked as updateable and you have a class in the application named login then it can result in the error below, the simplest resolution is to rename your class.

Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'

Event Type: Warning Event Source: ASP.NET 2.0.50727.0 Event Category: Web Event Event ID: 1310 Date: 11/7/2005 Time: 10:43:16 AM User: N/A Computer: DEVPC01 Description: Event code: 3007 Event message: A compilation error has occurred. Event time: 11/7/2005 10:43:16 AM Event time (UTC): 11/7/2005 4:43:16 PM Event ID: 6c82372492fa42dbbbd4a0f5b794ed8d Event sequence: 40 Event occurrence: 7 Event detail code: 0

Exception information: Exception type: HttpCompileException Exception message: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\deleted\3ee2c232\4383868\App_Web_login.aspx.cdcab7d2.pfd6ysg8.0.cs(118): error CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'

Tuesday, 9 June 2009

Google Maps - IE 8 - Click Position


The position (point) returned by the click event on Google Maps in Internet Explorer 8 is incorrect - at least in some configurations.

The recommendations I have found so far are to remove the DOCTYPE tag or to add in the compatibility meta tag for IE, to be honest I'm not sure which is worse!!

Discussed here:
http://groups.google.com/group/Google-Maps-API/browse_thread/thread/9946215e23a3bdf2

Microsoft explanation of the new compatibility meta tag:
http://msdn.microsoft.com/en-gb/library/cc817574.aspx

Monday, 8 June 2009

Open a form in C# without focus

From .NET 2.0 onwards, to show a new form without the form taking focus:


protected override bool ShowWithoutActivation
{
get
{
return true;
}
}

Override this property in your form code and it should do the trick for you.

Thursday, 28 May 2009

Preventing XSS in ColdFusion

How to prevent cross site scripting in ColdFusion. Useful page from The Dev Shack:
http://www.thedevshack.com/preventing-xss-cross-site-scripting-attacks-in-coldfusion/

Essentially:
  1. Enable Global Script Protection in your application. You can accomplish this by using the scriptProtect attribute in your application.cfc.
  2. You can also globally enable script protection at the server level via the ColdFusion Administrator. Under settings check Enable Global Script Protection.
  3. Use HTMLEditFormat around ANY variables that contain user submitted input.
  4. Search and replace any maliciuous data. Replace script tags, etc… with nothing.
  5. Validate user submitted input on the server side. Check data types and lengths.

Cross site scripting (XSS) links to information

Useful resources explaining Cross Site Scripting (XSS) and how to code/guard against it.

CERT® Advisory CA-2000-02 Malicious HTML Tags Embedded in Client Web Requests
http://www.cert.org/advisories/CA-2000-02.html

Cross-site Scripting (XSS)
http://www.owasp.org/index.php/Cross-site_scripting

Data Validation
http://www.owasp.org/index.php/Data_Validation

Reviewing Code for Cross-site scripting
http://www.owasp.org/index.php/Review_Code_for_Cross-site_scripting

XSS (Cross Site Scripting) Prevention Cheat Sheet
http://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet

OWASP Enterprise Security API
"OWASP Enterprise Security API Toolkits help software developers guard against security-related design and implementation flaws. Just as web applications and web services can be Public Key Infrastructure (PKI) enabled (PK-enabled) to perform for example certificate-based authentication, applications and services can be OWASP ESAPI-enabled (ES-enabled) to enable applications and services to protect themselves from attackers. "
http://www.owasp.org/index.php/ESAPI

MS AntiXSS
"AntiXSS 3.0 helps you to protect your current applications from cross-site scripting attacks, at the same time helping you to protect your legacy application with its Security Runtime Engine. Working with customer and partner feedback, AntiXSS 3.0 incorporates radically and innovatively rethought features, offering you a newer, more powerful weapon against the often employed cross-site scripting (XSS) attack."
http://www.codeplex.com/AntiXSS

PCI Compliance - ColdFusion Debug Information

It should be blocked anyway but it is a common problem when undergoing PCI Compliance that ColdFusion debug information may be displayed by appending mode=debug to any CF URL. To prevent this limit the IPs that can access the debug information, preferably limit this to 127.0.0.1:

  • Open CF administrator

  • Select "Debugging Ips"

  • Add 127.0.0.1

  • Remove all other IPs

Friday, 22 May 2009

Mouse position on screen .NET

Use:

System.Windows.Forms.Cursor.Position

Thursday, 21 May 2009

Very helpful network utilities including SuperScan port scanner

More a note to myself! Free tools from FoundStone (a McAffee company) including port scanning, vulnerability scanning and stress testing:

http://www.foundstone.com/us/resources-free-tools.asp

Wednesday, 20 May 2009

SQL Server Network Utility Path

As I can never remember. Path to the SQL Server network utility:

C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SVRNETCN.exe

Monday, 18 May 2009

Too many backup devices specified for backup or restore; only 64 are allowed



When you try to restore a database backup, the restore operation may fail. You may receive an error message that is similar to the following:

Server: Msg 3205, Level 16, State 2, Line 1
Too many backup devices specified for backup or restore; only 64 are allowed.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

The message doesn't necessarily mean what it says. The following are possible causes:

  • You want to restore a database backup that spans across multiple backup devices, and you have not specified more than 64 backup devices.

  • You created the database backup on a computer that is running SQL Server 2000 Service Pack 3 (SP3) (Build 2000.80.869.0) or a later build of SQL Server 2000 SP3.

  • You try to restore the database backup on a computer that is running a build of SQL Server 2000 SP3 that is earlier than 2000.80.869.0.

  • You are trying to restore a database created in SQL Server 2005 or SQL Server 2008 to an instance of SQL Server 2000 - not mentioned on Microsoft's support site but this was my problem!!

Change IDENTITY SEED using T-SQL


DBCC CHECKIDENT ({{TABLENAME}}, RESEED, {{NEW SEED}})

Be VERY careful to check the results of this command, it is possible to set the seed lower than the current maximum value of the identity column. If this is not checked and more records are inserted then you can run into serious trouble!

Converting Excel date format into System.DateTime



public static DateTime ConvertToDateTime(double excelDate)
{
if (excelDate < 1)
{
throw new ArgumentException("Excel dates cannot be smaller than 0.");
}
DateTime dateOfReference = new DateTime(1900, 1, 1);
if (excelDate > 60d)
{
excelDate = excelDate - 2;
}
else
{
excelDate = excelDate - 1;
}
return dateOfReference.AddDays(excelDate);
}


http://www.clear-lines.com/blog/post/Converting-Excel-date-format-to-SystemDateTime.aspx

Friday, 15 May 2009

SAGE Line 50 2009 Install Problems With 'manager' login



A few of our clients have experienced problems with fresh installs of SAGE Line 50 where they have completed a clean install and they cannot login to the application using the default user "manager" and a blank password - this applies to both the new company data and the demo data. In each case the problem has been caused by either denied access on the MS MachineKeys folder and/or a corrupt company setup file.

First try the following:
1. Browse to C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA
2. Right-click the MachineKeys folder and select Properties.
3. Select the Security tab
4. Ensure your user has at least Modify permissions on the folder.
5. Click Advanced
6. Tick the box for "Replace permission entries on all child objects…"
7. Select the Owner tab.
8. Ensure the owner is either your user or a group your user belongs to.
9. Click OK
10. Try to login to SAGE.

If the above fails:
1. Browse to C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys
2. Locate a key file with a name beginning 333
3. Right-click the file and select Properties.
4. Select the Security tab.
5. Ensure your user has at least Modify permissions on the file.
6. Click Advanced
7. Select the Owner tab.
8. Ensure the owner is either your user or a group your user belongs to.
9. Click OK
10. Try to login to SAGE

We have seen a case where before attempting the above steps there is a long delay whilst SAGE checks the login details but after completing the above steps SAGE almost immediately returns with a denied access message. If this happens it is likely you have resolved the permissions issues but now have a corrupt company setup file. If this is the case and if (ONLY IF!) you have not entered any information in the company file that you would like to keep:

1. Browse to C:\Documents and Settings\All Users\Application Data\Sage\Accounts\2009\Company.000
2. Rename the AccData folder as old_AccData
3. Create a new folder named AccData
4. Launch SAGE
5. The application will start with the option to setup a new company. Complete the wizard.
6. You will now be presented with a login prompt. Login with username "manager" and a blank password, you should be able to access the application.

Friday, 1 May 2009

How to loop through all files in a folder or directory tree

The code is fairly self explanatory:

/// sourceDir = directory to scan, scanLvl = current scan level, maxLvl = how deep to scan, searchPattern files to match

public static void ProcessFiles(string sourceDir, int scanLvl, int maxLvl, string searchPattern)
{
if (scanLvl<=maxLvl)
{
string [] fileEntries = Directory.GetFiles(sourceDir, searchPattern);
foreach(string fileName in fileEntries)
{
// do something with file
}


// Recurse into subdirectories
string [] subdirEntries = Directory.GetDirectories(sourceDir);
foreach(string subdir in subdirEntries)
if ((File.GetAttributes(subdir) &
FileAttributes.ReparsePoint) !=
FileAttributes.ReparsePoint)


ProcessDir(subdir, scanLvl+1, maxLvl, searchPattern);
}

}

Thanks to Ohad for the starting point for this one.

Thursday, 16 April 2009

SWFObject

Excellent little JS file for detecting Flash support and embedding Flash files.

http://code.google.com/p/swfobject/

Monday, 30 March 2009

No files were found to look in Visual Studio 2003

"No files were found to look in.Find was stopped in progress." message in Visual Studio 2003

Microsoft deserve a prize for the most random fix for this. If you get the above message press Ctrl + Scroll Lock

Friday, 20 March 2009

Internet Explorer 8 - Oh Dear!

Well, having had the final release of IE 8 installed for approximately 20 hours it has so far hung countless times and crashed completely on 5 occasions.

I am a fairly intensive user constantly opening and closing tabs but I'm not viewing particularly intensive sites - how can the browser have been in development so long and still be this bad!!

Thursday, 19 March 2009

Google StreetView for UK goes live

Google has launched the UK version of it's Street View service, the new service covers:
  • Aberdeen
  • Belfast
  • Birmingham
  • Bradford
  • Bristol
  • Cambridge
  • Cardiff
  • Coventry
  • Derby
  • Dundee
  • Edinburgh
  • Glasgow
  • Leeds
  • Liverpool
  • London
  • Oxford
  • Manchester
  • Newcastle
  • Norwich
  • Nottingham
  • Scunthorpe
  • Sheffield
  • Southampton
  • Swansea
  • York

The major issue for street view is privacy. Google has had agreement from the information commissioner because they have automatically blurred the faces of individuals and vehicle numer plates in all images, the only problem is that their software isn't perfect... you'd better hope this isn't your car.

Friday, 6 March 2009

Dynamically loading CSS in Safari and Google Chrome

Having developed a new AJAX enabled content viewer for a client's website I found that it would not load correctly in Google Chrome or Safari. The content being loaded into the viewer DIV included the CSS styles for the content and the HTML content itself, by loading the CSS into the container DIV it was being loaded outside of the document header - this is not valid in Safari as all style definitions must be placed in the head section - as a result the content loads without any CSS being applied.

To fix this the AJAX request has been split into two requests, the first loads the HTML into the DIV, the second loads the CSS and writes it into a style tag in the head section - this works in all browsers. Unfortunately this isn't as easy as it sounds due to various browser quirks when creating style elements, populating the element and adding it to the head section.

Essentially the following code will ensure the style element is created correctly:

function addCss(cssCode)
{
var styleElement = document.createElement(”style”);
styleElement.type = “text/css”;
if (styleElement.styleSheet)
{
styleElement.styleSheet.cssText = cssCode;
}
else
{
styleElement.appendChild(document.createTextNode(cssCode));
}
document.getElementsByTagName(”head”)[0].appendChild(styleElement);
}

Nicholas Zakas explains this in great and excellent detail:
http://yuiblog.com/blog/2007/06/07/style/

Thursday, 5 March 2009

Installing SQL Server Express 2005 on Windows 2008 SBS

Due to what frankly seems to be a complete botch from Microsoft SQL Server Express 2005 can be a pain to get installed on Windows Server 2008 SBS.

See:
http://technet.microsoft.com/en-us/library/cc794697.aspx

Especially:

Installing SQL Server 2005
If you plan to install SQL Server 2005 on the original server running Windows SBS 2008, do the following before you run the installation.

  • Click Start, click All Programs, click Accessories, and then click Run.

  • Type regedit, and then click OK.

  • At the User Account Control prompt, click OK.

  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\90.

  • Double-click OriginalMachineName, and then change the OriginalMachineName value name to the current server name.

  • Click OK.

Wednesday, 4 March 2009

Developer Developer Developer South West Taunton 23rd May 2009


From the DDD South West site: DDD South West is a free one day technical event for developers. It is a day of learning, discussing, contributing and being part of the community in the South West. Our goal is to provide free technical education, the opportunity to mix with peers and to make and develop relationships in the .NET industry.


Free registration started on 2nd March 2009, get over to the DDD site now to register.

C# how to get the current method and calling method names

Helpful CodeProject article:

http://www.codeproject.com/KB/dotnet/MethodName.aspx

Install SQL Express 2005/2008 from the command line

Information for installing SQL Server 2008 from the command line
including parameters/switches:
http://msdn.microsoft.com/en-us/library/ms144259.aspx

Information for installing SQL Server 2005 from the command line
including parameters/switches:
http://msdn.microsoft.com/en-us/library/ms144259(SQL.90).aspx

Friday, 27 February 2009

Ad hoc access to OLE DB provider has been denied

Using post SP2 SQL 7 (+ 2000 etc) attempting to access an OLEDB data source using OPENROWSET can produce the slightly spurious error:

Ad hoc access to OLE DB provider 'MSDASQL' has been denied. You must access this provider through a linked server.

In usual Microsoft style the message doesn't really mean what it says. From SQL 7 SP2 onwards MS by default blocked ad hoc query access with OLEDB. As the message suggests you could setup a linked server but that can be a real pain. Alternatively if you need ad hoc access server wide you could turn on ad hoc access for the SQL server you are using, explained in MS speak here:

http://support.microsoft.com/default.aspx?kbid=266008

Ah, but it's not that simple. A little more witchcraft is required. The following registry settings can be used to enable ad hoc access:

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Providers] "DisallowAdhocAccess"=dword:00000000


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Providers\Microsoft.Jet.OLEDB.4.0] "DisallowAdhocAccess"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Providers\MSDAORA] "DisallowAdhocAccess"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Providers\MSDASQL] "DisallowAdhocAccess"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Providers\SQLOLEDB] "DisallowAdhocAccess"=dword:00000000

Still not working?!

  • Go to Enterprise Manager > Security > Linked Servers

  • Right-click select "New Linked Server..."

  • Select an OLEDB provider.

  • Click "Provider Options".

  • Check "Disallow adhoc access".

  • Click OK

  • Enter a name for the linked server.

  • Click OK

  • Delete the new linked server.

  • Right-click select "New Linked Server..."

  • Select an OLEDB provider.

  • Click "Provider Options".

  • Unheck "Disallow adhoc access".

  • Click OK

  • Enter a name for the linked server.

  • Click OK

  • Delete the new linked server.


No-one said it would be easy...

Friday, 20 February 2009

Command line shut down or restart

Quite frequently all PCs in our office have to be restarted for various updates, configuration changes etc. We also have a policy of all PCs being turned off overnight and have become a little draconian in enforcing this - the electricity bills are huge otherwise!

A local or remote shut down or restart can be triggered using the command line.

shutdown [-i -l -s -r -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u] [p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)

You will need to be an administrator or have admin rights to remotely shut down or restart another PC. Whilst this can be useful technique only grant admin rights to those who really need them otherwise anyone in the office could start restart other workstations!!!

Disable SSLv2 in IIS 6 for PCI Compliance

Anyone working on PCI Compliance will know the restrictions placed on IIS. The recommendations are only common sense but remarkably few companies have implemented them.

SSLv2
SSLv2 has always been full of holes and there is now very little need for it to be enabled on any server. Almost no clients require it and if it is enabled it is potentially a serious security problem.

  • Open Registry Editor.

  • Select HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server

  • On the Edit menu select New then DWORD Value

  • Name the new value Enabled

  • Ensure the value is set to 0

  • Restart the server


Full details on disabling SSLv2 can be found in the following MS knowledge base article:
http://support.microsoft.com/kb/187498

Cryptographic Algorithms
If the scan for PCI compliance has picked up SSLv2 then it will almost certainly have warned about a number of weak algorithms (http://support.microsoft.com/kb/245030)

The following list need to be disabled to ensure the only Cipher algorithms available are 128 bit+ :
RC4 64/128
RC4 56/128
RC2 56/128
RC2 56/56
RC4 40/128
RC2 40/128

To disable a cipher:

  • Open Registry Editor.

  • Select HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers

  • Select the key for the cipher you wish to disable

  • On the Edit menu select New then DWORD Value

  • Name the new value Enabled

  • Ensure the value is set to 0

  • Restart the server


It is also worth considering disabling the MD5 hash as well, although be very careful that it is definitely not in use!

To disable MD5:

  • Open Registry Editor.

  • Select HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Hashes\MD5

  • Select the key for the cipher you wish to disable

  • On the Edit menu select New then DWORD Value

  • Name the new value Enabled

  • Ensure the value is set to 0

  • Restart the server

Monday, 9 February 2009

CFDOCUMENT Font Issues - Type 1

This has been reported many times but there are a number of issues with CFDOCUMENT and embedding fonts in PDFs - in particular in MX7. One client required a PDF to use the Dax font and had initially provided Type 1 fonts, these of courses didn't work as ColdFusion didn't recognise them. TrueType TTF fonts were then provided but still didn't work despite the fonts being installed in the system fonts folder and being correctly referenced by the font family name in the page CSS.

The core issue is that CFDOCUMENT will attempt to use the first version of a font with a matching font-family name - regardless of it's type. Our system had Type 1 and TrueType versions of Dax installed but CFDOCUMENT always tried to use the Type 1 version. The only way to resolve the issue was to completely remove the Type 1 version, the output now works perfectly!

Thursday, 29 January 2009

Sorting custom collections in C#

Take a look at Craig Gibbons' blog for a run-down on sorting custom collections.

Add a range of ports to Windows Firewall from the command line

To add a range of ports to Windows Firewall from the Command Line:

  • Click Start, click Run, type cmd, and then click OK.

  • Type in the following where the range is specified in brackets and the name you choose for the firewall entry is in double quotes.
    FOR /L %I IN (5001,1,5201) DO netsh firewall add portopening TCP %I "Passive FTP"%I

  • Each port in the range will be added with an "OK" confirmation.

Enabling Passive FTP on Windows 2003 with Windows Firewall

After much searching I have finally (!) located the best way of enabling passive FTP through Windows Firewall.

On Windows 2003 Server with IIS6
To Enable Direct Metabase Edit

  • Open the IIS Microsoft Management Console (MMC).

  • Right-click on the Local Computer node.

  • Select Properties.

  • Make sure the Enable Direct Metabase Edit checkbox is checked.


Configure PassivePortRange via ADSUTIL script

  • Click Start, click Run, type cmd, and then click OK.

  • Type cd Inetpub\AdminScripts and then press ENTER.

  • Type the following command where the range is specified in "..". cscript.exe adsutil.vbs set /MSFTPSVC/PassivePortRange "5001-5201"

  • Restart the FTP Publishing Service.
    You'll see the following output, when you configure via ADSUTIL script:
    Microsoft (R) Windows Script Host Version 5.6Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
    PassivePortRange : (STRING) "5001-5201"


Add each port to the Windows Firewall

  • Click Start, click Control Panel, open Windows Firewall, and select the Exceptions tab.

  • Click the Add Port button.

  • Enter a Name for the Exception and the first number in the port range.

  • Click TCP if not already selected and click OK.

  • Repeat for each port in the range - for large ranges see the end of the document.

  • Enable the Windows Firewall on the General Tab.


On Windows 2000 Server with IIS5 Configure PassivePortRange via Registry Editor

  • Start Registry Editor (Regedt32.exe).

  • Locate the following registry key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Msftpsvc\Parameters\

  • Add a value named "PassivePortRange" (without the quotation marks) of type REG_SZ.

  • Close Registry Editor.

  • Restart the FTP Publishing Service.
    Note: The range that FTP will validate is from 5001 to 65535.


Thank you to http://www.newagedigital.com/cgi-bin/newagedigital/articles/ms-firewall-ftp.html for the heads up.

Monday, 26 January 2009

Recover from corrupt SQL LDF transaction log file

Another favourite this month. A fault on one of our client's servers caused it to restart once every 10 minutes for 2 hours - the result was a corrupt LDF transaction log file for the main application database.

It is surprisingly simple to recover from this situation:

1. Stop the SQL Server service
2. Copy the affected database (both LDF and MDF files) out of the main data folder.
3. Restart the SQL Server service
4. Create a new database of the same name and location as the database affected in step 2 - it is critical the filenames and paths are identical.
5. Stop the SQL Server service.
6. Copy the original MDF file (copied in step 2) in to replace the new MDF file created in step 4
7. Start the SQL Server service - the database will show as being suspect.
8. Now you need to recover the database, working from Query Analyser or SQL Management Studio:

Use master
go

sp_configure 'allow updates', 1
reconfigure with override
go

select status from sysdatabases where name = '{{DBName}}'
go
-- Make a note of the status - in case you need to restore the value.

update sysdatabases set status = 32768 where name = '{{DBName}}'
go

9. Restart SQL Server - the database should now show up in emergency mode.
10. Delete the LDF file for the database.
11. Rebuild the transaction log:

DBCC REBUILD_LOG ('{{DBName}}', '{{Full path to the LDF file}}')
go
-- SQL Server will confirm: Warning: The log for database '' has been rebuilt.

12. If all appears to be OK:

USE {{DBName}}
GO
ALTER DATABASE {{DBName}} SET SINGLE_USER
go
DBCC CHECKDB ('{{DBName}}', REPAIR_ALLOW_DATA_LOSS)
go

13. If all still appears to be OK:

sp_dboption '{{DBName}}', 'single_user', 'false'
go

Use master
go

sp_configure 'allow updates', 0
go

Tuesday, 13 January 2009

IIS6 - which W3WP.EXE belongs to which application pool

Our servers run with a number of application pools to separate load between several intensive websites/processes. When everything is running fine management is easy but if an application pool begins to use excessive resource it is necessary to identify which W3WP.EXE process is using the resource and therefore which app pool is causing the problem.

Microsoft have provided a script file (.vbs) to list all W3WP.exe processess, the PID and the application pool. Simply open a command prompt (Start > Run, enter "cmd", click OK), type iisapp and hit return. Below is an example of the output:

W3WP.exe PID: 1468 AppPoolId: AppPoolForSite1.com
W3WP.exe PID: 3056 AppPoolId: AppPoolForSite2.com
W3WP.exe PID: 1316 AppPoolId: AppPoolForSite3.com

Thank you ASP Alliance for this one:
http://aspalliance.com/576

Shrink SQL Server Log File LDF

Having recently had a very intensive database with limited data generating a huge transaction log file (>4Gb for a 150Mb database) it was necessary to carry out a temporary truncate and then schedule once per day, the following prodecure is very effective:

USE {{DatabaseName}}
GO

DBCC SHRINKFILE({{FileName}}, 1)
GO

BACKUP LOG WITH TRUNCATE_ONLY
GO

DBCC SHRINKFILE({{FileName}}, 1)
GO