Cannot connect to SQL Server 2014 from Visual Studio -
i have installed sql server 2014 management studio. have imported database .bkp file , try make connection. connection string looks this.
<connectionstrings> <add name="name" connectionstring="server=pcname\sqlexpress;database=databaseinmssql;user id=sa;password=password" providername="system.data.sqlclient" /> </connectionstrings>
and error:
cannot open database \"databasename\" requested login. login failed.
login failed user 'sa'
here code using 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 windows auth, , sql server authentication in sql server management studio password , user. firewall temporarily off!
i using vs 2013 community edition, , windows 8.1 64bit
it appear user sa
(which should never ever use kind of work anyways!) has default database set databasename
doesn't exist.
how fix it?
- login
sa
or other sql server system admin - go
object explorer > security > logins > sa
, right-click , selectproperties
- change default database user does exist
Comments
Post a Comment