none
How to connect SQL Server Authentication in Windows Form C# RRS feed

  • Question

  • How to connect SQL Server Authentication Mode by default in Windows Form C#.

    I know Windows form always consider Windows authentication by default. But, my windows id may keep of changing and we cannot use this Windows Authentication.

    So i want to use SQL Server Authentication for Win Form C#.

    Can you anyone pls. suggest me how to use SQL server Authentication..?

    Getting error when i use SQL server Authentication.

    Cannot open database "" requested by the login. The login failed.
    Login failed for user '*****\********'.


    • Edited by Gani tpt Friday, March 8, 2019 6:43 AM SQL Server Authentication in Win Form C#
    Friday, March 8, 2019 6:42 AM

Answers

  • How to connect SQL Server Authentication Mode by default in Windows Form C#.

    I know Windows form always consider Windows authentication by default. But, my windows id may keep of changing and we cannot use this Windows Authentication.

    So i want to use SQL Server Authentication for Win Form C#.

    Can you anyone pls. suggest me how to use SQL server Authentication..?

    Getting error when i use SQL server Authentication.

    Cannot open database "" requested by the login. The login failed.
    Login failed for user '*****\********'.



    Hello,

    See the following which requires SSMS (SQL-Server Management Studio)

    https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/create-a-login?view=sql-server-2017


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    MS SQL Server must be using mixed mode autentication. The database must be set up to use user-id and password autentication.

    The connectionstring must be setup to use user-id and password the database uses to login and use the database.

    You can ask about this at the SQL Server forum

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver


    IMHO, mix those above and you got the correct answer.

    eXEC sp_addlogin 'NameOfTheLogin', 'password' -- this will be for the entire server.
    
    
    

    Mixed Authentication
    Add PermissionsResuming, you need to login with an user authentication, for that, you'll need an user.
    That's the first answer.
    But in other for that user be working, you'll need to allow mixed authentication.
    That's the second answer.

    My guide, shows you how to do that with GUI, if you want, I can make a script in case you cannot access the SSMS.

    Then you go here and use the one that fits your need on your application if needed (if u're using EF you won't need to copy/paste that).

    And for the last as Mr. Jack said, please mark an answer.

    From I saw you already had the right answers, since you didn't marked, I came here to make the answers even clear.

    PS: Sorry if it doesn't help you and only make things worse. 


    BP-LP 2005/2016 @ll rights reserved


    Monday, March 11, 2019 7:35 PM

All replies

  • Hello,

    See the following which requires SSMS (SQL-Server Management Studio)

    https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/create-a-login?view=sql-server-2017


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, March 8, 2019 10:31 AM
    Moderator
  • MS SQL Server must be using mixed mode autentication. The database must be set up to use user-id and password autentication.

    The connectionstring must be setup to use user-id and password the database uses to login and use the database.

    You can ask about this at the SQL Server forum

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver

    Friday, March 8, 2019 10:35 AM
  • Hi

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.
    Best Regards,

    Jack

    MSDN Community Support
    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, March 11, 2019 7:51 AM
    Moderator
  • How to connect SQL Server Authentication Mode by default in Windows Form C#.

    I know Windows form always consider Windows authentication by default. But, my windows id may keep of changing and we cannot use this Windows Authentication.

    So i want to use SQL Server Authentication for Win Form C#.

    Can you anyone pls. suggest me how to use SQL server Authentication..?

    Getting error when i use SQL server Authentication.

    Cannot open database "" requested by the login. The login failed.
    Login failed for user '*****\********'.



    Hello,

    See the following which requires SSMS (SQL-Server Management Studio)

    https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/create-a-login?view=sql-server-2017


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    MS SQL Server must be using mixed mode autentication. The database must be set up to use user-id and password autentication.

    The connectionstring must be setup to use user-id and password the database uses to login and use the database.

    You can ask about this at the SQL Server forum

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver


    IMHO, mix those above and you got the correct answer.

    eXEC sp_addlogin 'NameOfTheLogin', 'password' -- this will be for the entire server.
    
    
    

    Mixed Authentication
    Add PermissionsResuming, you need to login with an user authentication, for that, you'll need an user.
    That's the first answer.
    But in other for that user be working, you'll need to allow mixed authentication.
    That's the second answer.

    My guide, shows you how to do that with GUI, if you want, I can make a script in case you cannot access the SSMS.

    Then you go here and use the one that fits your need on your application if needed (if u're using EF you won't need to copy/paste that).

    And for the last as Mr. Jack said, please mark an answer.

    From I saw you already had the right answers, since you didn't marked, I came here to make the answers even clear.

    PS: Sorry if it doesn't help you and only make things worse. 


    BP-LP 2005/2016 @ll rights reserved


    Monday, March 11, 2019 7:35 PM