Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid object name 'ASPState.dbo.ASPStateTempApplications' - Exception after renaming the ASPState Database

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?

like image 942
Ravi Avatar asked Jul 17 '10 12:07

Ravi


3 Answers

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
like image 68
SureshNT Avatar answered Nov 18 '22 05:11

SureshNT


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

like image 25
Wilson Narro Avatar answered Nov 18 '22 04:11

Wilson Narro


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
like image 4
Kashif Khan Avatar answered Nov 18 '22 04:11

Kashif Khan