Friday 15 August 2014

c# - Cannot open database "ServicesDb" requested by the login in local machine -


This error has popped up in the last two days. I was following the method of creating a race service API, then It came along the way:

The database requested by the login "Services" login failed.
The login user failed for 'my-pc \ my'

So I stopped for a while and read the book and nothing. So I downloaded it and when I run it, I get an error similar to my own service.

This is a shock for me, as I have always used for the Windows certification when I used the local database engine, I have not had any problems, so I It seems that there is something to do and what I am using for the first time.

Connection String:

  & lt; ConnectionStrings & gt; & Lt; Add name = "ServicesDb" provider name = "System.Data.SqlClient" connectionString = "data source = (localDB) \ v11.0; >  

Has any other problem been encountered while following this book? Does anyone know what this can be, And how can I pass it?

UPDATE : Here is the code that fails to execute, the book uses Ninject and therefore I.

  Private Zero Configurable Enhancer (IKernel Container) {// Create NHibernate ISessionFactory object var sessionFactory = FluentNHibernate / / It fails, sessionFactory variable is not starting. Cfg.Fluently.Configure () .Database (MsSqlConfiguration.MsSql2008.ConnectionString (c = & gt; c Kkantseshncontekst ( "Web"). Mappings (M = & gt; M . Fluent mappings. Adfremaesdakshns Oops & lt; SqlCommandFactory & gt; ()) .BuildSessionFactory (); // Add ISessionFactory instance in container. bind & lt; ISessionFactory & gt; (). ToConstant (sessionFactory); // sessionFactory here Required // Configure a Resolver method used to create OSISIS Object Container is done. & Lt; ISession & gt; (). ToMethod (CreateSession); Container.Bind & LT; ICurrentSessionContextAdapter & gt; () & Lt; CurrentSessionContextAdapter & gt; (); }   

OK, in both cases I was thinking that the database was there . This is because in Visual Studio, the connection string throws the shadow of the database of the application in the server explorer. And because of that and because of the fact that I have worked with the first unit framework code first, which uses migration and takes care of all my SQL goods

I have Microsoft SQL Server Management Studio Opened and confirmed that the database was actually present there. When I found out that it was there, I made it and ensure that it corresponds to my connection string. After that all were good and I could execute my SQL script in Visual Studio.

No comments:

Post a Comment