Adding user and password to Sql Server database - sql-server-2005

My connection string defined in Web.Config currently indicatea no user or password is needed:
<connectionStrings>
<add name="CinemaxConnectionString" connectionString="Data Source=PCName\SQLEXPRESS;Initial Catalog=Cinemax;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
I would like to add user and password, like this:
<connectionStrings>
<add name="CinemaxConnectionString" connectionString="Data Source=PCName\SQLEXPRESS;Initial Catalog=Cinemax;User=cinemax; Password=abc"
providerName="System.Data.SqlClient" />
</connectionStrings>
Obviously, this requires changing some settings in Sql Server to add user and password. What is the best way to do this? I specify I have Sql Server 2005 Express and the current authentcation mode is "Sql Server and Windows Authentication".
Thank you in advance for your help.
It would be nice to see a double take on this: user-interface and code solution.

The below statements would do the job for you.
CREATE LOGIN cinemax WITH PASSWORD = 'abc';
GO
CREATE USER cinemaxUser FOR LOGIN cinemax
GO
GRANT SELECT TO cinemaxUser
GO
GRANT INSERT TO cinemaxUser
GO
GRANT UPDATE TO cinemaxUser
GO
GRANT DELETE TO cinemaxUser
GO

Related

SQL Server (Linked Server)

My database is from a linked server and I have a problem with my connection string in ASP.NET (web.config) it says that :
Database schema could not be retrieved for this connection. Please make sure the connection settings are correct and that the database is online. Cannot open database "AA" requested by the login. The login failed. Login failed for user 'sa' at DataObjectSupport(423,6)
I try to use this connection string.
<connectionStrings>
<add name="localconnection" connectionString="Data Source=SERVERNAME;Persist Security Info=True;Initial Catalog=database; uid=sa; Password=password; " providerName="System.Data.SqlClient"/>
</connectionStrings>

Unable to login with user that I created in sql database

I'm trying to connect with my DB using a account that I created with db_owner rights. Windows authentication works but not sql server authentication
I can confirm that the role was created as there is a error message login failed for user when using a wrong password. Compared to when correct password.
My local db is created in ASP.net web application by simply adding a local db in App data.
Error message is
user guest does not have permission to run DBCC checkpriamry file.
User has been created using
CREATE LOGIN [SomeUser] WITH PASSWORD = 'topsecret';
CREATE USER [SomeUser] FOR LOGIN [SomeUser];
exec sp_addrolemember 'db_owner', 'SomeUser'
EDIT:
<connectionStrings>
<add name="Shop" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Shop.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
https://imgur.com/a/9aCWVCU
are the links of error message
Your connection string when define login must be like this :
<connectionStrings>
<add name="Shop" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Shop.mdf;Initial Catalog=Shop.mdf;Persist Security Info=True; User ID=SomeUser; Password=topsecret;"
providerName="System.Data.SqlClient" />
</connectionStrings>

Database shows up in App_Data & not in SQL Server

Does anyone know why my database won't show up in SQL Server, but will show up in App_Data? I did code first migration and update the database but still can't see it. Please help
I try changing the connection and it did not work
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-Rentals.mdf;Initial Catalog=aspnet-Rentals;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
No database shows up

Failed login for user

I'm developing a website for sharepoint using asp.net, it is connected to a database. In visual studio server explorer, the database is accessible using a new sql user I created. I granted sysadmin permissions to that user. However, when I deploy the site and run it, it gives me this error 'login failed for user'.
The sql server is configured to allow mixed authentications. I restarted the server, I played with the user permissions but nothing ever changed.
The connection string I got it from server explorer which I'm sure it is correct:
Data Source=servertest;Initial Catalog=qDB;User ID=me2;Password=***********"
What should I do? I've tried every possible solution I found on google and I ended up here.
Try like this by editing your connection string:-
Server=myServerAddress;Database=myDataBase;User Id=myUsername; Password=myPassword;
I too had same scenario this worked for me
<connectionStrings>
<add name="connectionstring" connectionString="Data Source=XYZ\SHAREPOINT;Initial Catalog=DBName;Integrated Security=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
You can Use connection string like this
<appSettings>
<add key="KhadamatConnectionString"
value="Server=[copy name from Your ServerName of SSMS];Database=AcaService;uid=admin;pwd=mypass;" />
</appSettings>
or
<connectionStrings>
<add name="KhadamatConnectionString" connectionString="Data Source=[copy name from Your ServerName of SSMS];Initial Catalog=AcaService;User ID=admin;Password=mypass;" providerName="System.Data.SqlClient"/>
</connectionStrings>

Can't connect to database when database has user and password

I am developing mvc 4 projects and when I use the following connection string it works:
<add name="name"
connectionString="Server=.\sqlexpress;Database=dbname;
Trusted_Connection=true;"
providerName="System.Data.SqlClient"/>
But when I add a username and password to this project, I can't connect to my database. I added the user credentials correctly. I have db_owner permission for this database, and in my database everything is correct. The connection string below does not work:
<add name="DocContext"
connectionString="Server=.\sqlexpress;Database=DocContext;
User ID=pooria;Password=19216801;Trusted_Connection=false;"
providerName="System.Data.SqlClient"/>
Connection String You are using follows format -
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
User ID=myDomain\myUsername;Password=myPassword;
Try using IP Address, Port in Data Source field like -
<connectionStrings>
<add name="ConnectionStringName"
providerName="System.Data.SqlClient"
connectionString="Data Source=190.190.200.100,1433;
Initial Catalog=MyDatabaseName;
Integrated Security=False;
User ID=MyUserID;Password=MyPassword;
MultipleActiveResultSets=True" />
</connectionStrings>
And the following link may help you
LINK