1

I am working on one project which is in Asp.Net web form and Sql server. When I run application I get the error Unable to connect Sql Server Session Database and inner exception is Cannot open database ASPState requested by the login.

I did some google search to fix this issue. I don't have sa password so i cannot logged in as sa to assign privileges to ASPState database for the newly created User.

I don't see any ASPState database on Sql Server when i logged in. So i thought I might need to run aspnet reg exe on my machine. So i tried to run aspnetreg_regsql.exe but i got the following error.

An error occurred during the execution of the SQL file 'InstallCommon.sql'. The SQL error number is 5170 and the SqlException message is: Cannot create file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\aspnetdb.mdf' because it already exists. Change the file path or the file name, and retry the operation.

CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

Creating the aspnetdb database...

I am totally blank now to solve this issue, I will really appreciate your suggestion for this. This issue hold to publish on production.

M.kazem Akhgary
  • 18,645
  • 8
  • 57
  • 118
Gayatri
  • 559
  • 2
  • 8
  • 16

3 Answers3

1

Dont think that there is a simple answer to this with the permissions that you have, I think that what has happened is that the database HAS been created, but the user you are using does not have any access to it at all.

Without having an administrators credentials I dont think that you will be able to resolve the problem.

You can however work around it by re-creating the database with a different name:

aspnet_regsql -d[YourNewDBName] -RestOfYourParamaters

That should allow you to re-run the creation script, however there is no guarantee that you wont end up with the same issue on the newly created database.

D3vy
  • 831
  • 7
  • 19
  • I tried your solution, got this error now. Unable to use SQL Server because either ASP.NET version 2.0 Session State is not installed on the SQL server, or ASP.NET does not have permission to run the dbo.TempGetVersion stored procedure. If the ASP.NET Session State schema has not been installed, please install ASP.NET Session State SQL Server version 2.0 or above. If the schema has been installed, please grant execute permission on the dbo.TempGetVersion stored procedure to either the ASP.NET application pool identity, or the Sql Server user specified in the sqlConnectionString attribute. – Gayatri Jul 15 '15 at 00:38
  • I created new database from command prompt and then it install aspnetdb properly. Last time i tried to run aspnet_regsql from UI not through the command. Finally its working now. Thanks for your help. – Gayatri Jul 15 '15 at 16:49
0

You should issue the command DROP DATABASE aspnetdb and then re-run your script.

Ross Bush
  • 14,648
  • 2
  • 32
  • 55
  • I tried to drop database but query did not run successful. I got the error 'Cannot drop the database 'aspnetdb', because it does not exist or you do not have permission.' – Gayatri Jul 13 '15 at 03:02
0

'InstallCommon.sql' surely ain't any database. It must be a script that installs a new Database, as the name suggests. Run the script, and then link the generated database

naveen
  • 53,448
  • 46
  • 161
  • 251