简体   繁体   中英

VS 2010 Connecting to SQL Server 2008: Login failed for user "

I've created a web forms project in Visual studio 2010 that has to connect to an SQL Server 2008 database that's located on a different computer on the local network.

Here's my connection string from the web.config file:

<connectionStrings>
    <add name="myDatabase"
         connectionString="Data Source=myDatabase;Initial Catalog=myCatalog;Persist Security Info=True;User ID=sa;Password=myPassword*"
         providerName="System.Data.SqlClient" />
</connectionStrings>

And here's the string used in my entlib.config file:

<configuration>
    <configSections>
        <section name="dataConfiguration"
                 type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>
    <dataConfiguration defaultDatabase="myDatabase" />
    <connectionStrings>
        <add name="myDatabase"
             connectionString="Data Source=myDataBase;Initial Catalog=myCatalog;"
             providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>

The problem I'm encountering changes based on what's in entlib.config. If

Integrated Security=true;

is in the connection string the error I get is

Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

And if the integrated security tag is removed I get

Login failed for user ''.

I don't know why this isn't working because my company has other web projects that are able to connect to this database and I'm using the same exact connection code. The user name and passwords work when I log into SQL Management Studio. I can see the database in VS 2010's server explorer, and I'm using the connection string from there. I'm passing SQL Server authentication, and I know the right server is being reached.

尝试将整个connectionString值从web.config复制到entlib.config

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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