Thursday, June 28, 2007

ADO.net- Difference between using a IPAddress OR a Server name in the Connection String

I Lately wondered what is the difference between using the server name and using a IPAddress in a SQL connection string?

I got the answer Now-

IPAddress will always create a TCP/IP connection from client to SQL Server instance. This will hold true even if you are connecting to the SQL Server running on Local machine [where the client is also running] and Shared Memory option of that SQL Server instance is enabled.

If you use a Server name [or local, localhost,period(.) etc.]in the connection string, SqlClient will first check if the instance is running on local machine, If Yes, then whether SQLServer Shared Memory is enabled, and if Yes too, then it will connect using shared Memory rather than using any other protocol like TCP/IP,Named Pipe etc. to connect to the server.

To test this I’ve done following-

I installed SQLExpress on my local machine.For SQlExpress, only the shared memory connection type on the local machine is accessible by default, although the user can explicitly turn on other supported protocols such as TCP/IP and Named Pipes.

I created a simple .Net Winform which connects to AdventureWorks DB to show data from SalesOrderHeader in a DataGridView [This is the simplest stuff I could have tried with :-)]

Everything worked fine as I was able to show table data onto my Grid.
My App.config had an entry for SQL Connection string which uses my machine name for data Source-

providerName="System.Data.SqlClient" />


When I changed this connection string to use MYIPADDRESS instead of MYMACHINENAME, I got the error "provider: SQL Network Interfaces, error: 28 - Server doesn't support requested protocol".
I went to Surface Area Configuration tool to enable Remote connections with support to TCP/IP.
I restarted the SQL engine before running my application again and ..... Bingo! Everything starts working again.

This behaviour can be helpful while using replication, when both the main server and replication server are installed on the same machine.

I am not sure whether this can be true when connecting from .Net client to a Local Oracle DB with shared memory enabled, I need to try that. Once done I will post the results.

Wednesday, June 27, 2007

SCSF and Enterprise library 3.1 Binaries Issue

Although the latest version of SCSF uses EntLib 3.1 , but there is an issue which I faced and traced to resolution.

I created a project in SCSF and tried to open configuration file[Shell.exe.config] from compiled binary folder using the EntLibConfig.exe found in C:\Program Files\Microsoft Enterprise Library 3.1 - May 2007\Bin folder.

To my surprise I kept on getting error related to 'Could not load file or Assembly 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll' ..etc...etc.... .
I tried many other options like copying this tool to Application binaries folder, Copying Application binaries to EntLib binaries folder etc. But I couldn't succeed.

Then after some Googling I found the solution.

The problem relates to Precompiled binaries of Enterprise Library 3.1, Which are Strong named by default [while compiled by MS guys].
While SCSF by default uses Non-Strong named enterprise library binaries.
So here is the issue of a Mismatch.

I compiled the Enterprise library source code to produce Non-Strong named assemblies, which got compiled to 'C:\EntLib3Src\App Blocks\bin' folder. Then by using EntLibConfig.exe from C:\EntLib3Src\App Blocks\bin folder, everything starts working.

Thanx to the Toms' blog which helped me to get to the solution.

ENJOY

P.S: You can install the source code for EL from
Start-->All Programs--> Microsoft Patterns and Practices -->Enterprise Library 3.1-May 2007 --> Enterprise Library Source Code Installer

Wednesday, June 20, 2007

How to add customized folders to Open and Save as dialog boxes left Pane

For Office and Outlook - check this-
How to customize the Places Bar in Office 2000
For Office XP - Changes should be done at following Registry entries-
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\Open Find\Places\UserDefinedPlaces


For Windows dialog boxes Check this-
Windows Tweak: Add Shortcuts to Save As


Common DWORD entries-
0 Desktop
1 Internet Explorer
2 Programs
3 control panel
4 Printer Faxex
5 My Documents
6 Favorites
7 Startup
8 My Recent Documents
9 Send To
10 Desktop Folder
11 My Computer
12 My Network Places
13 Nethood
14 Fonts

Labels