CREATE DATABASE permission denied in database 'master' - asp.net

I receive this error when trying to login using ipadd/loginpage.aspx. This happens when I try to login on my Local Area Network using a different machine:
CREATE DATABASE permission denied in database 'master'.
An attempt to attach an auto-named database for file E:\StoreDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

You cannot create a database nor attached a database because you have no privileged to do so. Here's my workaround:
First, run the SQL Server Management Studio as "administrator". Then, login to your account. Next, click the Security folder --> click Logins --> choose your account name --> check the properties and verify the status if you have permission to connect to database engine.
I hope it helps you.

Related

Failed to connect to your database server

I do not understand what is wrong. It's as if all the data is correct.
Resolve all issues below to continue the installation. For help configuring your database server, see the installation handbook, or contact your hosting provider.
Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory.
> - Is the database server running?
Does the database exist or does the database user have sufficient privileges to create the database?
Have you entered the correct database name?
Have you entered the correct username and password?
Have you entered the correct database hostname and port number?
I take data from the ".env" file (DB_NAME=... DB_USER=... DB_PASSWORD=...)
As far as I know, Drupal does not use .env file by default. Instead you have to copy default.settings.php to settings.php under web/sites/default directory.
There you have a $database array in which you can provide the above information. Or you just create settings.php file as mentioned above with required permission and then simply put in your DB credentials in the installation wizard (Your screenshot). Drupal will automatically update the settings.php file.
Once the installation is over, you can provide 444 permission bits to settings.php for security.

How to handle "create database permission denied in database master" in windows Authentication?

I opened "ASP.NET SQL Server Setup Wizard" using the command apsnet_regsql from visual studio 10 command propmpt(Run as Administrator).
In that wizard I selected Windows Authentication instead of Sql Authentication. When I tries to connect to Master Database I am getting the following exception
An error occurred during the execution of the SQL file 'InstallCommon.sql'. The SQL error number is 262 and the SqlException message is: CREATE DATABASE permission denied in database 'master'. Creating the TestDB database
and the SqlException is:
create database permission denied in database 'master' in windows authenticAtion.
By the exception I understand that I don't have permission to create database. But how and where can I get permission to do that.
i have SQL Server 2008 in my system which comes as default with Visual Studio 2008 only.
So please help me and give a solution for my problem.Thanks
Obviously the reason why this is happening is because the user does not have the permission in sql sever to do any modification one of the ways to solve it would be to go to security folder chose user select properties might be permissions and make this user a dbadministrator or other advanced role than login with this user and try to create the database
here are couple of articles
http://msdn.microsoft.com/en-us/library/dd568727.aspx
http://msdn.microsoft.com/en-us/library/ms178630(v=sql.90).aspx
http://www.blackwasp.co.uk/SQLChangeOwner.aspx

ASP.NET Membership provider SQL Server Express

Is there any problem with using ASP.NET Membership via SQL Server Express ?
When I use this code :
Roles.AddUserToRole("shah", "Admdin")
I am faced with the error shown below.
Config :
OS : windows 7 64 bit.
SQL Server version: SQL Server Express Edition, Version :9.00.4035.00
connectionString="Data Source=.\sqlexpress;Initial Catalog=MShop;Integrated Security=True"
The user instance login flag is not supported on this version of SQL
Server. The connection will be closed. Description: An unhandled
exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and
where it originated in the code.
SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance
using a database location within the application's App_Data directory.
The provider attempted to automatically create the application
services database because the provider determined that the database
does not exist. The following configuration requirements are necessary
to successfully check for existence of the application services
database and automatically create the application services database:
If the application is running on either Windows 7 or Windows Server 2008R2, special configuration steps are necessary to enable
automatic creation of the provider database. Additional information is
available at: http://go.microsoft.com/fwlink/?LinkId=160102. If the
application's App_Data directory does not already exist, the web
server account must have read and write access to the application's
directory. This is necessary because the web server account will
automatically create the App_Data directory if it does not already
exist.
If the application's App_Data directory already exists, the web server account only requires read and write access to the
application's App_Data directory. This is necessary because the web
server account will attempt to verify that the Sql Server Express
database already exists within the application's App_Data directory.
Revoking read access on the App_Data directory from the web server
account will prevent the provider from correctly determining if the
Sql Server Express database already exists. This will cause an error
when the provider attempts to create a duplicate of an already
existing database. Write access is required because the web server
account's credentials are used when creating the new database.
Sql Server Express must be installed on the machine.
The process identity for the web server account must have a local user profile. See the readme document for details on how to create a
local user profile for both machine and domain accounts.
Yes, you can use membership with SQL Express. I think you do not have your Roles configured correctly in web.config. The error indicates it's trying to create the database, but the database should already exist if you are trying to add a role to a user,
You must create the user first, then add them to the role, if the database doesn't exist then either you didn't create the user first, or your roles are configured to use a database that doesn't exist.

Login failing on live server - asp.net

I am new to asp.net and am trying to test my first site on a production server.
What I have is a login control "login.aspx" that after successful login redirects the user to an admin area of the site.
When I test the site using VS2008 on my Windows XP machine all works well and I can login and administer the site. I am using Forms authentication to process the login.
When I upload the site to the production server it is a different story. I can access the login.aspx page. When I enter my login details and click "Login" it takes a really long time to process the page and eventially the page fails.
This is the error that I am getting:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:
If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
Sql Server Express must be installed on the machine.
The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.
Can anybody please help me on this issue.
Have you actually read the error message? It says exactly what is wrong, and how to fix it :-)
It clearly states "The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist."
Ergo, the database that is referenced in the web.config file was not uploaded to the production site.
Upload it to App_Data, and get back to us.
-Oisin
p.s. the connection string is in Web.config.

MS SQL update to Integrated Security

For debugging purpose, I backedup one of QA database and restored to local machine. Since it is in my local machine, I just want to connect to it using Integrated Security=True in my asp.net application. But I am getting following error:
Cannot open database "db1" requested
by the login. The login failed. Login
failed for user "DEV-LPTP-1784\ASPNET".
Any thoughts?
Thanks.
Delete and recreate database login you use. After db restore the database user has the same name, but inner SQL Server id is different, so SQL Server thinks that server login "DEV-LPTP-1784\ASPNET" is different than db user "DEV-LPTP-1784\ASPNET"
The user that ASP.NET is running under does not have access to that database. You can either grant that user access via SQL Management Studio, or change your connection string to use a specific username and password.

Resources