No access to Database File - asp.net

Last week I created a ASP.NET Web Application project on my machine. It was connecting to a SQL server database file for testing. The database was created in the server explorer part of visual studio and it created a database file with all of the information within it. I was using windows authentication to connect to the database.
Recently my computer has been migrated onto a new netowrk within my company. Now I no longer have access to the database file. The error I am getting is Login failed for user "DOMAIN/USER". I guess this is because the Domain has changed and my computer and the database server are in different domains. However I do not have access to the old domain to add a new login or user with priveladges to access the database.
How can i get arround this?

You cannot get around this, unless an admin is willing to give you a copy of the files from the old drive.
So, you must re-create your database.
Fortunately, if you took proper precautions, this will be easy.
Option 1: If your database is under source control, simply checkout the latest good version of the database.
Option 2: Load the latest backup of the database.

Related

How to access SQLite DB from IIS hosted WCF Service?

I am trying to deploy a WCF service that uses a SQLite DB to read some data as well as connecting to another Database (MS SQL). The service itself is consumed by a ASP Web site running on the same server.
The problem is that only my user is able to fully use the website and service. Every other user can't seem to open the sqlite database file.
What kind of permissions or special access do you need to access a sqlite database from IIS?
The Application pool is setup with a domain account so that access to the MS SQL Database can be granted (Integrated Security).
The folder where the database is stored is accessible by the account. And I've even tried to make it accessible by Everyone and all users with no luck.
I feel I'm missing something obvious but I can't figure out what...
Update: The error is as follows:
System.Data.Entity.Core.EntityException
An exception of type 'System.Data.Entity.Core.EntityException' occurred in EntityFramework.dll but was not handled in user code
Additional information: The underlying provider failed on Open.
Inner Exception:
System.Data.SQLite.SQLiteException
Unable to open database file.
I was able to resolve the issue, I'm going to document it here for posterity. I took a few steps to do so, and I currently don't have the environment set up to be able to reproduce the issue consistently and quickly, so I'm not entirely sure which was the actual solution.
Disclaimer aside, here are my changes:
I created a new Application Pool and Website on IIS, on another directory entirely, not on "C:\inetpub\wwwroot". I used "C:\Sites\MySite" to deploy both my WCF service and the website which consumed it.
I changed the application pool identity account to a new AD Service account.
I placed the database inside of the Service Web App directory, within a directory called data. I removed all inherited permissions from the directory and the database file, and gave the both the service account and Everyone Full Control of the directory and database file.
I edited the connection string for sqlite to have the setting "Journal Mode=Off;".
I stopped and started both the Application Pool and the WebSite on IIS.
After this the service worked correctly, and I was able to access both the database file and the connection to SQL Server. If I get the opportunity, I would set up some kind of virtual network to replicate this and see if I could figure out exactly what caused the error in the first place.

How to Connect Kentico Website with database

I just started working with Kentico and after Kentico Installation there is no setup files for my sql server database but I get the files are locally stored in the database(on localdb). So now I want to know that how can I connect with the existing database(sql server). As I try to change the web config but there are issue when we run the service from Kentico Service Manager.
Also I am having an another issue that how can this be possible with kentico that if the admin made certain changes in the text through interface and those changes should be reflected in database as well.So that next time when anybody tries to access the website it will reflect to him. Please let me know about it. Thanks in advance.
Please, refer:
Connecting your project to the database
Daabase Setup
Managed projects are connected to the database and contain Kentico EMS data by default.
If you're using an unmanaged project, you must connect the project to the database manually. You have two options to connect your project to the database:
entering the database credentials into the database setup wizard
adding a connection string to your application's web.config
Connection string template
<add name="CMSConnectionString" connectionString="Persist Security
Info=False;database=DATABASE_NAME;server=SERVER_NAME;user
id=USER_NAME;password=PASSWORD;Current Language=English;Connection Timeout=240;"/>

How to effectively set up MySQL Users and Roles in the production server WITHOUT Visual Studio?

So far I have been using the WebSite Administration Tool built in Visual Studio 2010 to manage Users and Roles along with MySQL Membership and Roles Provider.
Now, I have deployed the application to the production server and I am getting the following error:
Even if I tried to copy one of the roles and one of the users from my local DB to the one used by the production server, it didn't quite work and I keep getting the same error. At least, I'm sure that's the cause of the error because I did a remote debugging which led me to find it.
At this point I am very confused on how to get it working properly. So, any help or guidance would be really appreciated.
EDIT: At this point the User has been already authenticated in the login page using the connectionString to the production DB server. For that reason, I have dismissed any kind of problems related to the connectionString. I get this error while loading the masterPage where the role is needed in order to choose which menu to display.
The exception message says it all: It cannot connect to the database. Verify that your production DB server is running, that the connection string is correct and that you have network connectivity (including name resolution) from the web server to the DB server.
The solution for this problem was to create the mysql_aspnet_membership provider by granting full access through the machine.config and autogenerating the schema, instead of manually creating the membership tables in the database, which I though there could have been a valid way to create the db.
Afterwards, this didn't break anymore.

Where to start when uploading a SQL Server database to a web server

Here's another question on my lips.
My website uses a database which was created in SQL Server 2008 R2 Enterprise Edition. Where do I start when I plan to upload the database to the web server? My Website will require this database. Should I send the Scripts which created the database to the Staff of the web server so they can Recreate my database, or should I detach my database and place it in the App Data folder, followed by an update of my Connection strings to reference the detached database?
Another thing I fear is the Database version. Will my Database connection break on the web server because of the "Version of database is 655 and cannot be downgraded to 612" Error? and If yes, How would I prevent that?
The Best way would be to
1: Send them the scripts, let them run it on their side, they should then be able to provide you with server name, database name user id etc.
2: Create a .bak backup file of the database and send that to them and ask them to restore it for you, this way you save a lot of the hassle of creating scripts and you also ensure that the database is like you want it and you know they haven't made a mess of restoring the scripts.
You can also ask them if they don't have some sort of management console where you can upload the database yourself
My suggestion would be to create a back up of the SQL database, and give that to the web server admin to restore on their server. This will mean that you can guarantee that you will get no problems with the structure, and you should simply have to change the connection string in your Web.Config (assuming that you have always created your connections in code based on the connection string in the web.config), to contain a user name and password that your web server admin gives you (if it's a back up and restore of your db, assuming you use SQL authentication, the new db on the web server will have the same users anyway).
Some options;
If you have access via Management Studio just use the import/export tools or the Copy Database Wizard
If the remote sql server can read from one of the site directories you have access to upload a .bak backup and restore, or upload the database files proper and use one of the sp_attach* procedures
Script the database (including data) upload the individual files & create a quick and dirty script that will execute them.

How to use aspnetdb database with an asp.net website

I have created a website using asp.net 3.5.
And now I have added member support to it using Membership API and aspnetdb database.
And I have done all testing on my local machine.
Now, what issue needs to be considered with respect to aspnetdb while uploading this site to the server. ie; how this database will be available on the server side ?
Note : This is my first ever website.
I was just looking for an answer to this myself.
I've found the following that might help you:
http://www.studiocoast.com.au/knowledgebase/article-6-aspnet-using-sql-server-instead-of-aspnetdbmdf.aspx
"When developing applications in
ASP.NET 2.0, the default option for
roles and users is to use a local SQL
database in the App_Data directory.
This works fine locally, but will
bring up an error when uploaded to a
production server. To fix this the
ASP.NET membership information needs
to be stored in a dedicated SQL Server
database."
"ASP.NET includes a program called
Aspnet_regsql.exe which you can run
locally to configure your database.
More information on the program can be
found here:
http://msdn2.microsoft.com/en-us/library/ms229862.aspx"
Look in your C:\Windows\Microsoft.NET\Framework\v2.0.50727\ folder for the file InstallMembership.sql.
Thats the SQL script to create the database you need.

Resources