“初始目录”的要点是什么,在SQL Server连接字符串中? [英] What is the point of "Initial Catalog" in a SQL Server connection string?

查看:152
本文介绍了“初始目录”的要点是什么,在SQL Server连接字符串中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到的每个SQL Server连接字符串都是这样的:

Every SQL Server connection string I ever see looks something like this:

Data Source=MyLocalSqlServerInstance;Initial Catalog=My Nifty Database;
    Integrated Security=SSPI;

我需要初始目录设置吗? (显然不是,因为我工作的应用程序似乎工作没有它。)

Do I need the Initial Catalog setting? (Apparently not, since the app I'm working on appears to work without it.)

那么,是什么呢?

推荐答案

如果作为连接字符串的用户可以访问多个数据库,则必须指定连接字符串要连接到的数据库。如果你的用户只有一个数据库可用,那么你是正确的,没有关系。但是这是一个很好的做法是把它放在你的连接字符串中。

If the user that is the connection string has access to more then one database you have to specify the database you want the connection string to connect to. If your user has only one database available then you are correct that it doesn't matter. But it is good practice to put this in your connection string.

这篇关于“初始目录”的要点是什么,在SQL Server连接字符串中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆