我怎样才能发现这个连接字符串有什么问题?

时间:2022-06-06 16:47:07

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.

我正在尝试运行一个Nant脚本来备份一个Umbraco实例。我需要更改的参数之一是使用SQLOLEDB提供程序的连接字符串。这个脚本需要这样做,因为它需要一个.bak文件并从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:

我正在运行SQL Server 2008 express,可以使用Windows登录很好地登录到management studio。我尝试过将“localhost”更改为我的PC名称,\SQLEXPRESS等,但是当Nant脚本失败时,我仍然得到以下错误:

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?

是许可问题,还是它在寻找错误的初始目录?有没有一种方法可以快速调试/测试这种格式的连接字符串?

1 个解决方案

#1


7  

To quick-test any connection string on a windows box simply create a text file and change its extension from .txt to .udl.

要快速测试windows box上的任何连接字符串,只需创建一个文本文件,并将其扩展名从.txt更改为.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.

双击将打开datasource连接向导,您可以在该向导中选择所需的数据库驱动程序(在您的示例中为SQL Server提供OleDb)、服务器(在您的示例中为本地SQL Express实例)和数据库。

After testing this connection from the wizard you can simply open your .udl file using notepad and copy the connection string.

在从向导测试此连接之后,您可以使用记事本打开.udl文件并复制连接字符串。

#1


7  

To quick-test any connection string on a windows box simply create a text file and change its extension from .txt to .udl.

要快速测试windows box上的任何连接字符串,只需创建一个文本文件,并将其扩展名从.txt更改为.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.

双击将打开datasource连接向导,您可以在该向导中选择所需的数据库驱动程序(在您的示例中为SQL Server提供OleDb)、服务器(在您的示例中为本地SQL Express实例)和数据库。

After testing this connection from the wizard you can simply open your .udl file using notepad and copy the connection string.

在从向导测试此连接之后,您可以使用记事本打开.udl文件并复制连接字符串。