Saturday, October 25, 2008

How to run a Windows based desktop Application (32-bit) developed using ASP.Net 2.0 on Vista 64-bit Operating System?

It will be worth mentioning that every 32-bit (x86) application can run on 64-bit (x64) O.S (considering only a set of 64-bit hardware available).

To run Windows Application (32-bit) developed using ASP.Net 2.0 on Vista 64-bit Operating System, you need to strictly specify the application to run at x86 (32-bit) and NOT All CPU's option. Follow the steps mentioned below to build application for x86 (32-bit) O.S. :

1) Open the application that you want to run on 64-bit O.S in VS 2005.
2) Open Solution Explorer by Pressing Ctrl+Alt+L or by clicking View>Solution Explorer.
3) Select the project, right click on project and than click properties.
4) Select Compile Option and press "Advance Compile Options".
5) Than select Target CPU to x86 and press OK.
6) Rebuild/Recompile the application. Create installer (.msi) file of the application and install on 64-bit O.S.

This will do the trick and you will be able to run a 32-bit (x86) application on 64-bit (x64) O.S.

Tuesday, September 30, 2008

How to dynamically number rows in a SELECT Transact-SQL statement

Reference URL: http://support.microsoft.com/kb/186133

If you have to return a single record set while joining any tables, than first create a view and then apply:

Use the following code in SQL Server 2005.

select rank() OVER (ORDER BY a.au_lname, a.au_fname) as rank, a.au_lname, a.au_fname
from authors a order by rank

Use the following code in SQL Server 2000.

select rank=count(*), a1.au_lname, a1.au_fname
from authors a1, authors a2
where a1.au_lname + a1.au_fname >= a2.au_lname + a2.au_fname
group by a1.au_lname, a1.au_fname
order by rank


You can get more details by typing "dynamically number rows site:support.microsoft.com" in google search box.

Friday, September 5, 2008

Manually configure SQL Express and the Windows Firewall to allow remote access.

Manually configure SQL Express and the Windows Firewall to allow remote access. Use the following steps to enable remote access to SQL Express:

1. Open the SQL Server Configuration Manager by clicking Start, All Programs, Microsoft SQL Server 2005, Configuration Tools, SQL Server Configuration Manager.
2. In the left pane of the SQL Server Configuration Manger, expand the node for SQL Server 2005 Network Configuration and select Protocols for SQLEXPRESS.
3. In the right pane, right-click Named Pipes and choose Enable.
4. Right-click TCIP/IP and choose Enable.
5. In the left pane, select SQL Server 2005 Services.
6. In the right pane, right-click SQL Server Browser and choose Properties.
7. Click the Services tab in the Properties dialog box.
8. On the Services page, set the Start Mode property to Automatic and click OK.
9. Right-click SQL Server Browser and choose Start.
10. Right click SQL Server (SQLEXPRESS) and choose Restart.

Use the following steps to configure the Windows firewall.

1. Open the Windows Firewall dialog box and click the Exceptions tab.
2. Click Add Program and Browse to find sqlbrowser.exe and click OK.
3. Click Add Program and Browse to find sqlservr.exe. Click OK.
4. Click Add Port and enter ?�SQL Service??for Name, 1433 for Port number, and select the TCP radio button.
5. Click OK on the Windows Firewall dialog

Thursday, September 4, 2008

Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances

If you are getting the following error:

“Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances” What should I do?

Answer: To fix this, please Open the SQL Server Management Studio Express. This is the downloadable program in the same site where you downloaded the SQL Server 2005 express used to manage SQL Server 2005 Express.


In the query editor type this text: exec sp_configure 'user instances enabled', 1.


Then type: Reconfigure.


Then restart the SQL Server database.


Ref: http://blogs.msdn.com/hongmeig/archive/2007/08/31/generating-user-instances-in-sql-server-is-disabled-use-sp-configure-user-instances-enabled-to-generate-user-instances.aspx

Saturday, August 23, 2008

Restore SQL Database using SQL Script

Copy the .bak file to the physical drive (i.e. D:\ or E:\ etc.) of the machine.
Open Query Analyzer from Start Menu or from Enterprise Manager of SQL for the concerned server. Once inside log into the Query Analyzer.

Type
DATABASE FIILELISTONLY FROM DISK = 'F:\ABC01122008.bak' in order to get the LogicalName for 'ABC_log' and 'ABC_data'.


Apply the following script to restore SQL database using SQL Script & .BAK file.
RESTORE DATABASE {db name} FROM DISK =‘C:\{db name} .bak’ –Backup file path WITH MOVE ‘Logical_Name_Data’ TO D:\SQLDATA\MSSQL\data\{db name}_Data.MDF’, –MDF file destination path MOVE ‘Logical_Data_Log’ TO ‘D:\SQLDATA\MSSQL\data\{db name}_Log.LDF’, — LDF Location STATS = 1, REPLACE GO

Make sure to replace the {db name} = Name of your Database and Logical_Data = Name of the Logical file — File system name.

Here is complate code of the same
RESTORE DATABASE CTS2
FROM DISK = 'F:\CTS.bak' WITH REPLACE,
MOVE 'ABC_data' TO 'E:\SQLDatabase\CTS2_data.MDF',
MOVE 'ABC_log' TO 'E:\SQLDatabase\CTS2_log.LDF', STATS = 1, REPLACE
GO


Above script snippet will replace the existing database at the specified location. You can also rename the .MDF and .LDF files as you like.