none
System.data.SqlClient.Sql Exception login failed for user 'sa' RRS feed

  • Question

  •  <connectionStrings >
        <add
             name="Mystring"
             connectionString="Data Source=Data Source=sai-pc;Database=GYMONEDBMVC;User ID=sa;Password=pluto7788aa;Trusted_Connection=False;"
             providerName="System.Data.SqlClient"/>
      </connectionStrings>

    This does not work. It gives me and error. 

                WebSecurity.InitializeDatabaseConnection("Mystring", "Users", "sa", "", autoCreateTables: true);

    • Moved by 宝宝徐 Wednesday, September 20, 2017 2:22 AM
    Friday, September 15, 2017 2:33 PM

All replies

  • Hi !

    you don't have user sa or the password is wrong. otherwise use the user with the windows authentication. 

    make sure that the sa user is enabled 

    to do so :

    if you have sql management go to security=>login=> look for sa if sa had red flag it is disabled => right click on sa click properties and go status and make sure you enable it

    kind regards

    Laurens


    Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.





    • Edited by laurens vdb Friday, September 15, 2017 4:07 PM
    Friday, September 15, 2017 3:59 PM
  • <connectionStrings>
        <add name="Mystring" connectionString="Data Source=sai-pc;Database=GYMONEDBMVC;UID=adrian;Password=pluto7788aa" providerName="System.Data.SqlClient" />
      </connectionStrings>

     I have created a user called adrian and a password.

     WebSecurity.InitializeDatabaseConnection("Mystring", "Users", "Id", "UserName", autoCreateTables: true);

    when i run the project it brings me to the above.


    Friday, September 15, 2017 4:27 PM
  • <connectionStrings>
        <add name="Mystring" connectionString="Data Source=sai-pc;Database=GYMONEDBMVC;UID=adrian;Password=pluto7788aa" providerName="System.Data.SqlClient" />
      </connectionStrings>

     I have created a user called adrian and a password.

     WebSecurity.InitializeDatabaseConnection("Mystring", "Users", "Id", "UserName", autoCreateTables: true);

    when i run the project it brings me to the above.

    Friday, September 15, 2017 6:07 PM
  • hi adriantreanor , 

    are you getting an error ? 

    can you provide the full erro message. 

    thanks 

    kind regards

    Laurens


    Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 15, 2017 8:22 PM
  •  web.config
     <connectionStrings>
        <add name="Mystring" connectionString="Data Source=sai-pc;Database=GYMONEDBMVC;UID=adrian;Password=pluto7788aa" providerName="System.Data.SqlClient" />
      </connectionStrings>

    When i run the project it brings me to the code:

                WebSecurity.InitializeDatabaseConnection("Mystring", "Users", "Id", "UserName", autoCreateTables: true);

    System .Data.SqlClient.SqlException. A network-related or instance specific error occured while 

    establishing a connection to SQL server. The server was not accesible. Verify that the instance name 

    is correct and that SQL server is configured to allow remote connections. (provider:Name Pipes

    provider, error:40- Could not open a connection to SQL server

    In SQL server manager I created a user adrian. Gave full server permissions and granted permission to connect to database engine.

    Friday, September 15, 2017 9:38 PM
  • Hello again ,

    i think your connectiuon string is is wrong , you need to define the server

    for example something like this: 

    <add name="Mystring" 
            connectionString="Server=sai-server; Database=GYMONEDBMVC; User Id=adrian; password=pluto7788aa"
            providerName="System.Data.SqlClient" />


    A good site to figure out what the connection string must be

    https://www.connectionstrings.com/

    kind regards


    Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by laurens vdb Friday, September 15, 2017 10:19 PM
    Friday, September 15, 2017 10:17 PM
  • web.config

    <connectionStrings>
       <add name="Mystring" connectionString="Data Source=sai-pc;Database=GYMONEDBMVC;UID=adrian;Password=pluto7788aa" providerName="System.Data.SqlClient" />
      </connectionStrings>

    <connectionStrings>
    <add name="Mystring"
            connectionString="Server=localhost; Database=GYMONEDBMVC; User Id=sa; password=Password123"
            providerName="System.Data.SqlClient" />
    </connectionStrings>


    <connectionStrings>
        <add name="Mystring"
            connectionString="Server=sai-server; Database=GYMONEDBMVC; User Id=sa; password=Password123"
            providerName="System.Data.SqlClient" />
      </connectionStrings>

    <connectionStrings>
        <add name="Mystring"
            connectionString="Server=localhost; Database=GYMONEDBMVC; User Id=adrian; password=pluto7788aa"
            providerName="System.Data.SqlClient" />
      </connectionStrings>

    wont work. I tried localhost.

    Friday, September 15, 2017 10:50 PM
  • Hi adriantreanor,

    Welcome to MSDN forum.

    Since this forum is to talk about visual studio IDE, please provide more information about the problem. What's the type of your project and when did you meet the error?

    Best regards,

    Joyce


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 18, 2017 8:55 AM
  • I have just installed visual studio 2017 and I am learning c#.  The project was from the website

    http://www.aspdotnet-suresh.com/2015/09/aspnet-mvc-example-demo-project-application-with-database-download.html

    It's probably about the database as I have no errors, warnings.

    It is the web.config file.

    Monday, September 18, 2017 6:33 PM
  • Hi,

    Please open a new thread in Microsoft asp.net forum, visual studio general questions forum is to talk about visual studio IDE. If you have problem with visual studio, please feel free to let me know.

    Best regards,

    Joyce


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 19, 2017 9:42 AM