I'm developing an asp.net mvc application at my office. I wanted to work at home as well, so, I pushed my project on github, when I came my home back, I pulled it from github to my projects folder, now I tried to access its SQL Server database in server explorer using windows authentication, on pressing ok, it showed me the following error :
Cannot open database "HrAndPayrollSystem.Models.HrAndPayroll" requested by the login. The login failed.
Login failed for user 'user'.
and here is my connection string :
<connectionStrings><add name="HrAndPayroll" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=HrAndPayrollSystem.Models.HrAndPayroll;Integrated Security=False" providerName="System.Data.SqlClient" />
What could be the reason, how should I resolve it? Thanks in Advance :)
So, I somehow managed to get through this.
In other words, this error says that you need to access your database at least for a single time, means you need to perform some transactions with the database, inserting something or retrieving something, at this point you accessed the database for the first time on the different machine. Since, I had to access database at the point when my application starts, so, crashing start crashes my whole application, so I created another controller that does not contain any authorize attribute, just to leave it open in order to access the database, created a single field, accessed the database, now go and check your database in server explorer, you are about to access it for the first time in the database, and now also, it will never crash anywhere.
So, the point is that you need to access your database at least for a first time..
Related
We use Azure SQL Database, and therefore had to jump through some hoops to get cross-database queries set up. We achieved this following this great article: https://techcommunity.microsoft.com/t5/azure-database-support-blog/cross-database-query-in-azure-sql-database/ba-p/369126 Things are working great for most of our databases.
The problem comes in for one of our databases which is read-only. The reason it's read-only is b/c it is being synced from another Azure SQL Server to derive its content. This is being achieved via the Geo-Replication function in Azure SQL Database. When attempting to run the query GRANT SELECT ON [RemoteTable] TO RemoteLogger as seen in the linked article, I of course get the error "Failed to update because the database is read-only."
I have been trying to come up with a workaround for this. It appears user permissions are one of the things that do NOT sync as part of the geo-replication, as I've created this user and granted the SELECT permission on the origin database, but it doesn't carry over.
Has anyone run into this or something similar and found a workaround/solution? Is it safe/feasible to temporarily set the database to read/write, update the permission, then put it back to read-only? I don't know if this is even possible - I was told by one colleague that they think it will throw an error along the lines of "this database can't be set to read/write b/c it's syncing from another database..."
I figured out a work-around: Create a remote connection to the database on the ORIGIN server. So simple, yet it escaped me until now. Everything working great now.
I am facing an issue since yesterday. I have a SQL Server located on a remote hosting provider. The provider claims that there could be max 5 connections at the same time.
I also have my own developed app. Until now there was only one user using the application and there was no problem with the connection to that database.
Now we got an additional user who will be working with this app from another place. The problem is, when the first user logged in into the program and he's using it, the second user retrieving information on login form that cannot connect to the SQL Server but before application thinking around 30 seconds before that message.
Seems there can be only one conenction at same time and not 5. Can you advise something or is there any test I can do to check it and make sure where I stand?
I have a silverlight application where when I run the application I read the database and populate the results in the combobox, but when I publish it on the server(IIS) the it returns me a null, I can't even debug the error because it return the result when I host it on my system but null when hosted..
Please guide...
Taking a stab in the dark here. Most likely this is a security issue. When debugging locally, your web server runs under your credentials. If using integrated authentication to your database, then the web service host acts like it is you when making requests to the database. However, when you deploy, the server tries to connect to the database using the credential associated with the application pool that is running your site. Check your database connection string to see if it is pointing to the right database and try using a named user/password with an account that does have access to the database.
If this doesn't fix the problem, try accessing one of your services directly (using Fiddler?) to see what the service is returning as an error message that your Silverlight client is ignoring.
I am having to modify an old web project that us using classic asp. There are actually 2 different projects that are clones of each other, they just point to different databases.
I modified the code from the first project (asp, db, stored procs etc.) and it all works great.
I then copied all that code to the other project since they are clones. All works just fine there too. I can execute the stored procs in query analyzer and all the data comes back as expected and it shows up on the display asp pages.
When i hit the edit button on the page I get the "Microsoft OLE DB Provider for SQL Server error '80040e09'" and it shows the select part of the query in the error window.
I dont get anything about permissions etc.. If I view the page source the data is actually in there. I am really confused as to what is going on.
Anyone have any suggestions or things to look for.
Thanks
This appears to be a permissions error based on the usual meanings of this error code.
I would manually log in to the database using the same credentials you have configured in your application's connection string. Then run the same query and see what happens.
When I link the Microsoft Access to SQL Server locally, everything works. The second I go to a computer that is on the network, I am not able to open the form I created on the Access database.
I found out that if I open the link, I will get an error. If I choose where the DB through configurations in Access, I get the error again. If I try this a third time, it connects to the database and it is fully linked--I am able to type data into Access and it will store it in the SQL Server database as well.
My question is: How do I get it to connect to the server on the first try? I have to hit "connect" three times which takes about 5 minutes to log in. That isn't very efficient when the people using this program nothing about computers.
Linking Access to SQL Server uses ODBC. Make sure your ODBC settings are correct.