Microsoft SQL Server Transact-SQL

Insert Multiple Rows in SQL Server

In SQL Server 2005, in order to insert 3 rows to a table, you had to run 3 INSERT statements:

insert into Customers (Name, City, Phone) values (‘Customer #1’, ‘Jerusalem’, ‘2343245’)

insert into Customers (Name, City, Phone) values (‘Customer #2’, ‘Tel Aviv’, ‘0987345’)

insert into Customers (Name, City, Phone) values (‘Customer #3’, ‘Haifa’, ‘275466’)

In SQL Server 2008, you can insert multiple rows in a single insert statement that takes a number of value arrays:

insert into Customers (Name, City, Phone)

values

(‘Customer #1’, ‘Jerusalem’, ‘2343245’),

(‘Customer #2’, ‘Tel Aviv’, ‘0987345’),

(‘Customer #3’, ‘Haifa’, ‘275466’)

Source link

IIS Outlook

OWA saves .docx and .xlsx file as .zip

The problem:

When any Office 2007 attachment (.docx, .xlsx, etc) is opened from OWA, the user is asked to save the document before they open it. When they do this, the default extension is .zip. If the user changes it to the correct extension before opening, the file opens correctly.

This happens because the Office 2007 MIME file types are not configured on the web server and the users browser does not know how to open the files. If IE is configured to open files based on the file header, it identifies the file as a zip, which is technically correct.

The administrator can fix it site wide by adding the Office 2007 file types to the MIME settings on the server.

On the user side, IE has an option to open files based on content, not extension. The user should add the OWA URL to the Trusted (or Local Intranet) list before making this change.

read more »

Tips & tricks

Acordo ortográfico e Microsoft Word 2010

O novo acordo, que vai entrar em vigor até 2014, para activar a opção no Word 2010 Português basta navegar até ao Menu Ficheiro, seguido de Opções e item Verificação. Depois seleccionar a opção Modos de Português de Portugal : Pós-Acordo

word2010ao


para converter textos automáticamente para o novo acordo ortográfico pode utilizar o programa Lince

http://www.portaldalinguaportuguesa.org/index.php?action=lince

.NET IIS Microsoft Networking

IIS does not allow downloading files from .mdb format.

add the following to the web.config as follows:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
        <fileExtensions allowUnlisted="true" >
          <remove fileExtension=".mdb" />
          <add fileExtension=".mdb" allowed="true"/>
        </fileExtensions>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

MIME Type must be registered on IIS

Microsoft Silverlight

Silverlight & SQL server connection

You can’t. Instead you should create a WCF service one server that Silverlight can talk to.

Tutorial that does that: http://silverlight.net/learn/tutorials/sqldatagrid.aspx

Your Silverlight app has two projects. One Aspx project for server side, one silverlight on client side.

Your database resides on server side.

You can access it from server side aspx project.

Client side doesn’t know about database.

You can use WCF for connection.

Direct connection is not possible to the database.

ArcGIS Tips & tricks

ArcGis 10.0 License Manager error

When trying to set / change license manager on the remote machine, ArcGISAdmin gives an error saying my server “is an invalid hostname. Please enter a valid hostname.”

Normally this error is due to firewall restrictions ArcGIS Server.

Tips & tricks Utils

Error installing SQL Server 2008 Native Client (HRESULT:0x800736FD)

Problem solved changing the registry key.

Ckeck if the “Windows Modules Installer” service is started. If not, and you receive an error “1450 Insufficient System resources” error, when trying to start it, then it is the origin of the problem.
To solve it:

1) Open regedit and replace the following value:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control

Key: RegistrySizeLimit

Type: REG_DWORD

Value: 0xFFFFFF (4294967295)

2) Reboot

3) Open a command prompt as administrator and run SFC /SCANNOW to check the integrity of system modules.

4) Install pending windows updates (surelly there are many of them)

IIS Microsoft

Changing the Framework on IIS7

dotnet

Simple, but a little hidden:

  1. Open IIS
  2. Click on “Application Pools” :
  3. In the side panel (right) click on “Website” you want to change the framework:
  4. Sidebar, locate the “Edit Application Pool” and then click Basic Settings
  5. Clicking on “Basic Settings …” will appear the following selection screen FrameWork:
  6. Now, select the framework of your choice by clicking on the list. NET Framework Version:
  7. Once selected click “OK”
IIS Silverlight

How to solve Unhandled Error in Silverlight Application Code: 2104

The Problem: You ftp a Silverlight App to an IIS website, go to the website in a browser, and get the following error:

Message: Unhandled Error in Silverlight Application
Code: 2104
Category: InitializeError
Message: Could not download the Silverlight application. Check web server settings

The Cause: The Silverlight Mime types (.xaml, .xap and .xbap) are not listed in that websites registered mime types, therefore IIS will not send those files to the browser.

The Solution: Open IIS on the server, go to HTTP headers, click on Mime Types, click “Add New” and add the following:

Extension – Mime Type
.xaml – application/xaml+xml
.xap – application/x-silverlight-app
.xbap – application/x-ms-xbap

Hit Apply and your application will load!

Code Snippets

Export image to PDF in Silverlight

After a few hours serching a way to put a image into pdf in silverlight, something worked out, here goes:

Libraries used:
Imports silverPDF
Imports PdfSharp.Pdf
Imports PdfSharp.Drawing
Imports iTextSharp.text
Imports ImageTools
Imports ImageTools.IO.Jpeg
Imports ImageTools.ImageBase
Imports ImageTools.Helpers
Imports ImageTools.ImageExtensions

Code snippet (vb):

        Dim d As New SaveFileDialog()
        d.Filter = "PDF file format|*.pdf"
        ' Save the document...
        If d.ShowDialog() = True Then
            Dim document As New PdfDocument()
            Dim page As PdfPage = document.AddPage()
            Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
            Dim img As ImageTools.ImageBase = Me.canvas1.ToImage()
            Dim mstream As New MemoryStream()
            Dim encoder As New JpegEncoder()
            encoder.Encode(img, mstream)
            mstream.Seek(0, SeekOrigin.Begin)
            Dim pdfImg As XImage = XImage.FromStream(mstream)
            gfx.DrawImage(pdfImg, 0, 0)
            document.Save(d.OpenFile())
        End If

CodeSnippet (C#):

SaveFileDialog d = new SaveFileDialog();
d.Filter = "PDF file format|*.pdf";

// Save the document...
if (d.ShowDialog() == true) {
	PdfDocument document = new PdfDocument();
	PdfPage page = document.AddPage();
	XGraphics gfx = XGraphics.FromPdfPage(page);

	ImageTools.ImageBase img = this.canvas1.ToImage();
	MemoryStream mstream = new MemoryStream();
	JpegEncoder encoder = new JpegEncoder();
	encoder.Encode(img, mstream);
	mstream.Seek(0, SeekOrigin.Begin);
	XImage pdfImg = XImage.FromStream(mstream);
	gfx.DrawImage(pdfImg, 0, 0);

	document.Save(d.OpenFile());

}