I just installed SQL Server 2012 Express edition on my computer (Windows 8).
When I try to create a database from the Management studio, I'm getting the following error:
Create failed for Database 'TestDB'. (Microsoft.SqlServer.Smo)
CREATE DATABASE permission denied in database 'master'.
(Microsoft SQL Server, Error: 262)
When I try to access it from the visual studio, I'm getting the following similar error message:
CREATE DATABASE permission denied in database 'master'.
Is there any reason for that? I can't even access the engine from the management studio.
EDIT
Here's my connection string
<add name="DefaultConnection"
connectionString="Data Source=localhost\sqlexpress;Initial
Catalog=OptimumWeightDB;Integrated Security=True;
Integrated Security=True;
User Id=sa;Password=mypassword" "
providerName="System.Data.SqlClient" />
This is the context class
public class OWDbContext : DbContext
{
public OWDbContext()
: base("DefaultConnection") { }
}
First of all. Try to log into SQL Management Studio on your SQL Server using Windows Authentication.
If you can create database / manipulate database using you windows account there maybe a problem on the security set up on your sa login account.
Then try to re create / create new login account and set its permission to db admin.
Other thing make sure that SQL server Authentication is Enabled on your SQL Server.
When you already connected to your SQL Server using Windows Authentication right click your SQL Server > Properties > Security > SQL server and Windows Authentication mode.
also change your connection string to
Data Source=localhost\sqlexpress; Initial Catalog=OptimumWeightDB; user=yourloginname; password=yourpassword;
Best Regards
Related
I have installed SQL Server 2014 as well as Management Studio. Than I have imported database from .bkp file and try to make connection. My connection string looks like this.
<connectionStrings>
<add name="Name"
connectionString="server=PCNAME\SQLEXPRESS;database=DatabaseInMSSQL;User ID=sa;Password=password"
providerName="System.Data.SqlClient" />
</connectionStrings>
And this is error:
Cannot open database \"DatabaseName\" requested by the login. The
login failed.
Login failed for user 'sa'
Here is the code that I am using to connect
public void OpenConnection()
{
if (connection == null)
{
connection = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["Name"].ConnectionString);
}
if (connection.State != ConnectionState.Open)
{
connection.Open();
}
}
I can login normally as well as windows auth, and SQL Server Authentication in SQL Server Management Studio with that password and user. My firewall is temporarily off!
I am using VS 2013 Community edition, and Windows 8.1 64bit
It would appear that the user sa (which you should never ever use for any kind of work anyways!) has a default database set as DatabaseName which doesn't exist.
How to fix it?
Login as sa or any other SQL Server system admin
Go to Object Explorer > Security > Logins > sa and right-click and select Properties
Change the default database for that user to something that does exist
When I try to connect to database I get Database Login Error. The connection I use is "Data Source=IK-PC\\SQLEXPRESS;Initial Catalog='abc.new';Persist Security Info=True;User Id=IK-PC\\Administrator"
My server name: IK-PC\SQLEXPRESS
My authentication is Window Authentication
My user name is IK-PC\Administrator.
Everything is shown on SQL Management Studio Connect to Server form.And my database name is abc.new, which is attached to the SQLMS.
If you're using a Windows login in SQL Server, you should use Integrated Security=True (or Integrated Security=SSPI) instead of user Id and password.
"Data Source=IK-PC\\SQLEXPRESS;Initial Catalog='abc.new';Persist Security Info=True;Integrated Security=True"
You need to then run the process accessing SQL Server as IK-PC\Administrator user.
I am stuck with a connection from a MS SharePoint Server 2013 to an MS SQL Server 2012 in Windows Azure. I built three VMs: An ADDC, An MSSQL Server and the SharePoint Server. All of them are in the same subnet.
When I am trying connect the SQL Server during the SharePoint setup I am getting following error:
Cannot connect to database master at SQL server at xxx.cloudapp.net. The database might not exist, or the current user does not have permission to connect to it.
The firewall on the SQL Server is deactivated (for testing), The Domain User is listed in database/security/logins and all rights are granted. Perhaps I am missing something.
Connectionstring:
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDB;Data Source=MyDB.cloudapp.net
I failed to connect using this connection string
strConnString = "Provider=SQLOLEDB;Initial Catalog=fsw;SERVER=HARDIXP\hardi;Integrated Security=SSPI;"
Microsoft OLE DB Provider for ODBC
Drivers (0x80004005) [Microsoft][ODBC
SQL Server Driver][DBMSLPCN]SQL Server
does not exist or access denied.
I can connect fine using SQL Server Management Studio. On the "Connect to Server" dialog, I have
Server Name: HARDIXP
Authentication: Windows Authentication
After it is connected, the server looks like this
HARDIXP (SQL Server 10.0.2531 - HARDIXP\hardi)
If I don't specify the server name, the error will be
Microsoft OLE DB Provider for SQL
Server (0x80040E4D) Login failed for
user 'HARDIXP\IUSR_GEOFFREYXP'.
Note that it is trying a different user, probably because the database was first set up for Geoffrey, not Hardi.
How can I connect to my local SQL Server from this Classic ASP code?
EDIT: I am on Windows XP, IIS 5.1
Assuming this is running on windows.
The ASP process needs to be running as a windows authenticated user that has access to the
database. Just set the application pool on the website to have this identity's credentials.
first I have checked that Server Authentication is already set to:
"SQL server and Windows Authentication mode" (mixed mode)
้here 's my web.config connectionstring
<connectionStrings>
<add name="StockConnectionString" connectionString="Data Source=192.168.0.2;Initial Catalog=Stock;Persist Security Info=True;User ID=op;Password=operator" providerName="System.Data.SqlClient"/>
</connectionStrings>
Whene I test running (ctrl+F5) under VS2010 development this can connect to remote SQL server without any problem. but when i publish this project to local IIS (same web.config) an error occured..
Login failed for user 'op'. Reason:
Not associated with a trusted SQL
Server connection.
also i can connect to SQL server via SQL server Management Studio with SQL server authentication same user/pass.
no idea what's wrong with this.
finally, after 3 days can't figure this out. then i tried start over.
created a new project (ASP.NET MVC 2 web app) in VS2010.
go to Database Explorer > Add Connection..
use SQL server authentication to remote SQLserver directly instead of local.
then gotcha!! it told me..
this server version is not supported. you must have Microsoft SQL server 2005 or later.
my project was created under Win XP connect to SQLserver 2000 and it's work fine. now the answer for an error above is..
Visual Studio 2010 dropped support for SQL Server 2000. You'll either have to go back to VS2008/SL3, upgrade your SQL Server, or do things manually outside of Visual Studio.
...really appreciate this so much
Does it make any difference if you add this to the connection string ?
Trusted_Connection=False;
A clue is that it's saying that it's not trusted which indicates it's not using the username and password from the string. Has a connection string been possibly imported into IIS ?
Trusted is windows authentication which by the error is being used. Sql server authentication is username and password which you are trying to use.