13

I have created new session database using the command (aspnet_regsql.exe -S -E -ssadd -sstype p) and it created DB called ASPState. Then I renamed it to something like E_ASPStateDB. I have configured the correct DB name in the sessionState connection string. But still it throws the exception Invalid object name 'ASPState.dbo.ASPStateTempApplications'

What i need to do, so that it will use the new database name?

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
Ravi
  • 1,293
  • 6
  • 20
  • 31
  • Not sure but i guess DB name is hard coded by MS, one suggestion would be to run profiler and see the the query being sent. – Guru Kara Jun 27 '12 at 12:54

4 Answers4

16

I ran this on the db server that the site was connecting to and it solved it immediately.

USE [ASPState]
GO

DECLARE @return_value int

EXEC    @return_value = [dbo].[CreateTempTables]

SELECT  'Return Value' = @return_value

GO
web-tiki
  • 99,765
  • 32
  • 217
  • 249
SureshNT
  • 161
  • 1
  • 3
  • 3
    This solved my issue immediately, but each time I restart my server, I have to run this. Is there a better way to make this change permanant on server? – Diablo Jan 04 '17 at 08:50
4

Since you renamed the DB you will have to regenerate the ASPnet session tables. Below is the solution to it.

To Remove, use following command: [open visual studion command prompt]

aspnet_regsql -ssremove -S [SERVER] -U [USER] -P [PWD] -d [DATABASE] -sstype c

Then add them again by following command

aspnet_regsql -ssadd -S [SERVER] -U [USER] -P [PWD] -d [DATABASE] -sstype c
Kashif Khan
  • 685
  • 2
  • 11
  • 30
2

You must modify the stored procedures because they invoke the tables with the database name and schema, as follows:

[ASPState].dbo.ASPStateTempApplications

you have to change it for

[E_ASPStateDB].dbo.ASPStateTempApplications

Wilson Narro
  • 67
  • 1
  • 7
0

once you have registered a DB name using aspnet_regsql, you shall have to use the name you registered with. There is no point really to change the name afterwards. If you really want to use a name like E_ASPStateDB, why not delete the registration of ASPState first and then re-registering with the name E_ASPStateDB. It shall make your life easier

Shezi
  • 1,352
  • 4
  • 27
  • 51
  • Yeas we need to remove earlier registration to use new db name as we have one to one relationship only. –  Jul 11 '12 at 12:10