I’m trying to run a Nant script to backup an Umbraco instance. One of the parameters I need to change is a connection string using SQLOLEDB provider. The script needs this because it takes a .bak file and restores a new database from fresh.
The mentioned line in the script that needs to be tweaked is this:
<property name="ole.db" value="Provider=SQLOLEDB;Data Source=localhost; Initial Catalog=master; Integrated Security=SSPI"/>
I’m running SQL Server 2008 express and can log into management studio fine using my Windows login. I’ve tried changing “localhost” to my PC name, .\SQLEXPRESS etc but I keep getting the following error when the Nant script fails:
System.Data.OleDb.OleDbException: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
Is it a permissions problem or is it looking for the wrong initial catalogue or something? Is there a way to quickly debug/test a connection string in this format?
To quick-test any connection string on a windows box simply create a text file and change its extension from .txt to .udl.
Double-clicking will open the datasource connection wizard where you can select the desired database driver (OleDb for SQL Server in your case), the server (local SQL Express instance in your case) and the database.
After testing this connection from the wizard you can simply open your .udl file using notepad and copy the connection string.