Tuesday, November 25, 2008

Manually enable remote connections in SQL Server 2005

The default configuration of the SQL Server 2005 doesn't allow remote connections. Hence, the error message "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)" when creating a new SQL Server database or connecting to an existing database in Visual Studio 2005 (VS2005).

To manually enable remote connections on the SQL Server,

1. Open the SQL Server Surface Area Configuration through Start menu.

2. Next, select Surface Area Configuration for Services and Connections.

3. On the left panel, expand the SQL Server instance -> Database Engine -> Remote Connections. Then, on the right panel, select Local and remote connections - Using TCP/IP only.

4. Also, make sure that the SQL Server Browser service is running.

5. Finally, restart the SQL Server instance. This can be done in the Services list under Administrative Tools in Control Panel.

Friday, November 21, 2008

Build setup project and msi file using command-line

Command build the VS2005 deployment (or setup) project and create the msi file:

"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe" SOLUTIONNAME.sln /Build "Release" /project SETUPPROJECTNAME.vdproj /projectconfig "Release"

Friday, November 14, 2008

ArgumentException Column does not belong to table

When using ADO.Net, I got the following error:

Column does not belong to table . A simple fix will be to check if the column exists before accessing the column in the table. This can be done as follows:

if (row.Table.Columns.Contains(ColumnName))


// proceed here