Tuesday, 8 January 2013

ASP.NET webforms URL routing


URL routing is very cool functionality available for ASP.NET applications. It allows us to make the application URLs more user friendly. That was not the root key why I decided to use it in our application.

Application renders the PDF files on output dynamically from images in database and show it to users. They can see it in browser in Adobe Reader. There is one functionality in Adobe Reader which allows to send PDF file by email, using email client on the computer. From some version the attachment started to have aspx extension which forces user to rename it before it can be actually opened.

Simple solution to this is to use URL routing functionality to render the file to output as if it is really PDF.

Below are few links which I found useful during implementation and deployment of the application.


Routing with ASP.NET Web Forms
URL routing is not working in IIS 6
Troubleshooting ASP.NET routing on IIS 7

Sunday, 16 December 2012

Windows phone 8 emulator

I have come accross these problems when installing Windows phone 8 emulator in vmware player.

1. CPU
- needs to support virtualization and it needs to be enabled in BIOS

2. operating system
- 64 bit
- needs to be some which supports SLAT (Windows 8, Windows Server 2012 ...)
- needs to have Hyper-V enabled

3. VMware settings
- Edit vmx file and add this configuration hypervisor.cpuid.v0 = "FALSE",  mce.enable = "TRUE"
- Processors setting - enable Virtualize Intel VT-x/EPT or AMD-V/RVI
- Processors setting - setup at least two cores
- Memory settings - setup enough memory for virtual machine

4. Windows Mobile 8 SDK
- will download and install all required prerequisities, it is good to have prepared steps above


Sources:
Windows 8 Hyper-V will require SLAT (Second Level Address Translation)
MachineSLATStatusCheck
Windows Server 2012 and Hyper-V
Hyper-V in Workstation 8
Windows Phone SDK

Monday, 11 June 2012

MSSQL trace file analysis

Today I was looking for a way how to access MSSQL server trace data from TSQL. The solution is to import data to database via function fn_trace_gettable.

SELECT * INTO temp_trc
FROM fn_trace_gettable('c:\temp\trace.trc', default);

Tuesday, 17 January 2012

Issue to restore of replicated database solved

Restore of backuped database which used replications can be a problem. Database was restored successfully but it was still marked as part of publication (see is_published in sys.databases). There was not possible to truncate, alter structure of tables etc.

This issue can be resolved by running this command on database:

exec sp_removedbreplication 'database_name'

Tuesday, 20 December 2011

How to Export Image column to file on MSSQL II

Another way how to export binary data from database. It is possible to use bcp utility.

bcp "SELECT img FROM db_name.dbo.Images WHERE ID = 1" queryout "c:\001.jpg" -T -S server

Once you run it you will be asked for the file storage type (no change required), prefix-length (needs to be 0), length of field and field terminator (no change)

Wednesday, 30 November 2011

Update of XML data

Code snippet for updating specific data in xml column in mssql

declare @date datetime
set @date = GETDATE()

UPDATE XmlDocuments
SET    xmlmetadata.modify ('replace value of (/Header/Date/text())[1] with sql:variable("@date")') 
WHERE ID = '1000001'

Friday, 16 September 2011

Bulk update of Image data in MSSQL

This is just simple example how to do update of image data in Microsoft SQL database.

UPDATE Images SET Img = (SELECT BulkColumn AS Img FROM OPENROWSET(BULK N'C:\NoImage.TIF', SINGLE_BLOB) AS [Document])