简体   繁体   English

SQL 服务器 Express 2008 连接字符串

[英]SQL Server Express 2008 connection string

I am trying to configure my connection using SQL Server Express 2008.我正在尝试使用 SQL Server Express 2008 配置我的连接。

Can anyone help me please.谁能帮助我。 My server name is as follows: test\expressql2008 and my database is TestDatabase我的服务器名称如下: test\expressql2008我的数据库是TestDatabase

My connectionstring is:我的连接字符串是:

<add key="hibernate.connection.connection_string" 
     value="Server=localhost\EXPRESSQL2008;Database=TestMyproject;User=Me;Pwd=test;" />

It seems that the connections isn't working and I get the error:似乎连接不起作用,我收到错误:

NHibernate.ADOException: cannot open connection NHibernate.ADOException:无法打开连接

Here's all connectionstrings needed这是所需的所有连接字符串

http://connectionstrings.com/ http://connectionstrings.com/

<add name="SD_ConnectionString" connectionString="Data Source=[SQLEXPRESS NAME];Initial Catalog=TestDatabase;User ID=[USERNAME];Password=[PASSWORD]" providerName="System.Data.SqlClient"/>

string con = ConfigurationManager.ConnectionStrings["SD_ConnectionString"].ToString()

Can you provide more detail about this error there could be number of reasons您能否提供有关此错误的更多详细信息,可能有多种原因

1- Please check ASP.NET user has access to your database if you are using trusted connection. 1-如果您使用受信任的连接,请检查 ASP.NET 用户是否有权访问您的数据库。 2- It could be better if you create a SQL USER and assign it permission of DBOWNER to your database and with your connection use that user information. 2-如果您创建一个 SQL 用户并将 DBOWNER 权限分配给您的数据库并在您的连接中使用该用户信息,则可能会更好。

con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);

in web.config在 web.config

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM