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?
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
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
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
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
Related
I'm attempting to write a bash script that will dump a database and then import it to a staging database. I would like the staging database to match the 'master' database.
I have the following code, however I recieve:
ERROR 1062 (23000) at line 23: Duplicate entry '1' for key 'PRIMARY'
# Dump production master database, excluding school_hosts table
mysqldump -h $MYSQL_HOST -u $MYSQL_USERNAME -p$MYSQL_PASSWORD --no-create-info --ignore-table=hcl_master.school_hosts hcl_master > hcl_master.sql
# Dump hcl staging database, for backup.
mysqldump -h $MYSQL_HOST -u $MYSQL_USERNAME -p$MYSQL_PASSWORD hclstaging_master > hclstaging_master_backup.sql
# Import dump file into staging master database
mysql -h $MYSQL_HOST -u $MYSQL_USERNAME -p$MYSQL_PASSWORD hclstaging_master < hcl_master.sql
After searching, I found that I could add --replace to the mysql command that is importing, however I recieve an error stating that:
mysql: unknown option '--replace'
Can anybody help with getting this script to work correctly? I'm unsure how I can drop the staging database before i import or how to get it to overwrite the primary key record?
Any help would be much appreciated. I am using MariaDB.
--replace is a mysqldump option that you specify when creating the dump, not something you can tell mysql when importing the dump.
How do I issue commands to MariaDB via the CLI without actually jumping into the interactive use mode?
I know I can type mysql which will then jump me into the interactive mode where I can write SQL commands like CREATE DATABASE dbname; and then exit to go back to the regular terminal.
However I'd like to skip that and do something like mysql 'CREATE DATABASE dbname;' all in one line.
mysql --help | grep "\-execute"
Output:
-e, --execute=name Execute command and quit
So to create a database with command line client, you just need to execute
mysql -uuser -p -e"CREATE DATABASE dbname"
You can also concatenate several SQL statements, e.g.
mysql -uuser -p -e"CREATE DATABASE dbname;SHOW DATABASES"
Put the commands that you want executed into a text file (optionally with a file extension of .sql) then, from the command line, do mysql -uuser -p < yourtextfile.sql to have all of the commands in the file executed.
I try to copy postgresql table in another database as I write in pgAdmin 3 this query
$pg_dump -t pl_biz_enhanced business_catalog | psql business_catalog_enhanced
here pl_biz_enhanced is the table i want to copy and business_catalog is the database in which is this table
But I receive syntax error near $.
That's not an SQL query.
$pg_dump -t pl_biz_enhanced business_catalog | psql business_catalog_enhanced
The $ is a reference to the UNIX shell prompt, which usually ends in $.
This is a shell command. You can't run it in PgAdmin-III.
As far as I know there's no equivalent feature in PgAdmin-III. Either do the pg_dump | pg_restore in the command prompt or manually do the equivalent in PgAdmin-III, which would be to dump just the pl_biz_enhanced table of business_catalog and then restore it to the separate database business_catalog_enhanced.
I am trying to run aspnet_sqlreg on my local database (on my machine).
aspnet_regsql -ssadd -sstype c -d "computername\localSqlserveNname" -E
And after it says "Start adding sesson state.", it says that, "An error has occured.... A network-related or instance-spcific eror occurred while establishing a connetion to SQL server. The server was not found or was not accessible." But, I am pretty sure i entered the correct name of the server and database.
Has anyone have similar error?
the error is on the name
aspnet_regsql.exe -ssadd -sstype c -d DATABASENAME -E
where DATABASENAME is the name of your new database, eg try something like "SessionStateDB"
aspnet_regsql.exe -ssadd -sstype c -d SessionStateDB -E
I think there are some steps to enable SQL Cache Depdndency :
Enabling notifications, changes in web.xml and then using Cache Dependency object.
Please help how do I pass through them ?
Have a look at this post. It takes you through using the Aspnet_regsql.exe tool, which sets it up for you.
Here is an excerpt from the above post:
...To enable a cache dependency on a particular database, run this command:
aspnet_regsql.exe -S server -U user -P password -d database -ed
This creates a new table, AspNet_SqlCacheTablesForChangeNotification,
in the designated database. Next, several AspNet_SqlCacheXxxx stored procs
are created in the same database.
Then look at this post from MSDN for an overview, with lots of How-to links.
To enable a table for SQL cache dependency use, you'll need to first run the aspnet_regsql.exe tool from a command-line prompt, with these options:
aspnet_regsql -S servername -U login -P password -ed -d databasename -et -t tablename
If your table name contains a space, then wrap the table name in quotes e.g.
aspnet_regsql -S servername -U login -P password -ed -d databasename -et -t "table name"
In your web.config, you'll need to add a caching section:
<system.web>
<caching>
<sqlCacheDependency enabled = "true" pollTime = "60000" >
<databases>
<add name="northwind"
connectionStringName="Northwind"
pollTime="9000000"
/>
</databases>
</sqlCacheDependency>
</caching>
</system.web>
When you add an item into your Cache, you use the SqlCacheDependency object to set up the relationship between the cached object and the underlying table:
SqlCacheDependency dependency = new SqlCacheDependency("databasename", "tablename");
Cache.Add(key, object, dependency);