I'am using session state handling in ASP.NET by MSSQL server with:
sessionState mode="SQLServer"
in web.config. Locally I used aspnet_regsql with no problems but while trying to do same on production server it throws exception at me (* - are masked data):
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regsql.exe -S somehostserver.com -U _admin -P _password -ssadd -sstype c -d mydb
Start adding session state.
.
An error occurred during the execution of the SQL file 'InstallSqlState.sql'. Th
e SQL error number is 229 and the SqlException message is: The EXECUTE permissio
n was denied on the object 'sp_delete_job', database 'msdb', schema 'dbo'.
If the job does not exist, an error from msdb.dbo.sp_delete_job is expected.
SQL Server: *
Database: [*]
SQL file loaded:
InstallSqlState.sql
Commands failed:
/* Drop all tables, startup procedures, stored procedures and types. */
/* Drop the DeleteExpiredSessions_Job */
DECLARE #jobname nvarchar(200)
SET #jobname = N'***' + '_Job_DeleteExpiredSessions'
-- Delete the [local] job
-- We expected to get an error if the job doesn't exist.
PRINT 'If the job does not exist, an error from msdb.dbo.sp_delete_job is expect
ed.'
EXECUTE msdb.dbo.sp_delete_job #job_name = #jobname
SQL Exception:
System.Data.SqlClient.SqlException (0x80131904): The EXECUTE permission was deni
ed on the object 'sp_delete_job', database 'msdb', schema 'dbo'.
If the job does not exist, an error from msdb.dbo.sp_delete_job is expected.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolea
n breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception
, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cm
dHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, Tds
ParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName,
Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult res
ult, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Web.Management.SqlServices.ExecuteFile(String file, String server,
String database, String dbFileName, SqlConnection connection, Boolean sessionSta
te, Boolean isInstall, SessionStateType sessionStatetype)
Using SQL scripts causes similar errors. What should I do ?! Hosting owner suggests "make backup on ur machine and place it in production", but This causes another problems...
Any suggestions !? Or Iam forced to craft by hand all scripts for tables and procedures ?!
Best regards
It seems that the user is missing the "RSExecRole" role in the Master and MSDB system databases. Reporting Services uses a predefined database role called "RSExecRole" to grant report server permissions to the report server database.
The "RSExecRole" role is created automatically with the report server database. However, when you move a report server database to a new or different SQL Server Database Engine, must re-create the role in the Master and MSDB system databases.
Here is a link reference to how to create the "RSExecRole":
http://technet.microsoft.com/en-us/library/cc281308.aspx
Related
Fortunately, this is in UAT rather than production.
The UAT servers are Azure VMs running SQL Server 2012 and Windows Server 2012.
On one page in the application I get an error
Login failed for user 'User'. at System.Data.SqlClient.SqlInternalConnection
Microsoft.ApplicationBlocks.Data.SqlHelperParameterCache.GetSpParameterSetInternal(SqlConnection connection, String spName, Boolean includeReturnValueParameter)
at Microsoft.ApplicationBlocks.Data.SqlHelperParameterCache.GetSpParameterSet(String connectionString, String spName, Boolean includeReturnValueParameter)
at Microsoft.ApplicationBlocks.Data.SqlHelperParameterCache.GetSpParameterSet(String connectionString, String spName)
The login is a SQL Server login, not a domain login
On the SAME web page, there are 3 other stored procedure calls that are made to the same database with the same connection string prior to this stored procedure begin called
I have dropped and recreated the stored procedure
I have dropped and recreated the database login
The account is a member of a database role that grants it EXECUTE rights on the schema this stored procedure belongs to
If I log into SSMS as this user, I can:
Expand the stored procedure list for the database
Expand the parameter list for the affected stored procedure
Run the affected stored procedure and get the expected results
I have an alternative web server set up on the SQL Server which uses domain logins in the connection string, that runs with no problem. We are trying to deprecate the SQL Server version of the web site.
Can anyone suggest what might be causing this, and how to address it?
Thanks you .NET SqlClient security behaviour.
Working call via Data Application block
return SqlHelper.ExecuteReader(ConnectionString, sql_OutboundQueue_TypeAndStatusCount, DBUtility.GetNull(since));
This chains down to calling SqlHelperParameterCache.GetSpParameterSet
Failing call via Data Application block
SqlConnection con = new SqlConnection(QueueDataProvider.ConnectionString);
SqlCommand cmd = new SqlCommand(QueueDataProvider.OutboundQueue.sql_OutboundQueue_Search, con);
con.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(SqlHelperParameterCache.GetSpParameterSet(con.ConnectionString, cmd.CommandText));
Reason:
con.ConnectionString has the password cleared if you are using SQL Logins, but only AFTER you call con.Open
Thanks to: ConnectionString loses password after connection.Open
I have database and webpages related to it are uploaded on server but not able to access the database from server but when run on local machine through VS2010 i was able to access it.
Asked Server Admin also about the problem but they told that everything is fine from server side there is problem in code they are saying.
The following error i'm getting:
Server Error in '/' Application.
Invalid object name 'Login'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'Login'.
Source Error:
Line 20: SqlCommand com = new SqlCommand("select Password from Login where Username='" + Uname_txt.Text.Trim() + "'", con);
Line 21: con.Open();
Line 22: SqlDataReader dr = com.ExecuteReader();
Line 23: try
Line 24: {
If everything is working locally, then problem is definitely in how you've setup connecting to the database on the server.
So, look at connection string in web.config and make sure that it is setup properly (if using Integrated Security make sure appropriate APP POOL is allowed to access database).
Also, make sure Login table is indeed created in the database.
Once you do all that you have lots of things to follow up with:
Stop using reserved keywords in SQL expressions (Password, Login, etc) or at least wrap them in brackets like [Password].
Try to get in habit of referencing schema when working with tables (dbo.Login instead of just Login)
Extract queries like that in Stored procedures so that you are not vulnerable to SQL Injection
You have not posted the connection String, I suspect, you have not supplied the INITIAL CATALOG in connection string, because of which it is directly connected to Master Database and of course your table not exists in Master.
INITIAL CATALOG = should be added in your connection string. I hope this will help you.
Note: You can also use DATABASE = in connection string.
I am building webform using vs2012 Express. I am using the ASP.NET Membership provider.
In configuring the sqlmembershipprovider, I ran the following sql batch on my db.
\WINDOWS\Microsoft.NET\Framework\v4.030319\InstallCommon.sql
\WINDOWS\Microsoft.NET\Framework\v4.030319\InstallMembership.sql
to install the Membership.When i tried to Register new user on my application I received the following Error Message:
Exception Details: System.Data.SqlClient.SqlException: Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +1769462
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5318578
.......
Going through the trace and Answers on similar question posted on stack overflow, I notice that I run the two sqlbatches on a wrong db:A. I created similar table on db:A and change the connection string in the web congfig. it works.But the db:B am working on is where I want install the membership, when I ran the same sqlbatches on this db:B the necessary objects are not installed.Both databases are on the same server.
Did any know why and what should i do next?
The correct method of setting up the membership provider database is to run the asp.net reg tool. It can be found in the location below:
"C:\Windows\Microsoft.NET\Framework\<FrameworkVersion>\aspnet_regsql.exe"
More information
http://msdn.microsoft.com/en-us/library/x28wfk74(v=vs.100).aspx
I have a classic ASP app which connects to an access database, I receive the following error when I try to access a page which connects to the database:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x1b48 Thread 0x1970 DBC 0x1948024 Jet'.
/gasket.inc, line 24
Here is my gasket.inc file:
<%
'include file for gasket table database object
'Dimension variables
Dim adoConG 'Database Connection Variable
Dim strConG 'Holds the Database driver and the path and name of the database
Dim rsGasket 'Database Recordset Variable
Dim strAccessDBG 'Holds the Access Database Name
Dim strSQLG 'Database query sring
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDBG = "\\MyServer\databases\gaskets\gaskets.mdb"
'Create a connection object
Set adoConG = Server.CreateObject("ADODB.Connection")
'Database connection info and driver
strConG = "DRIVER={Microsoft Access Driver (*.mdb)};uid=admin;pwd=; DBQ=" & strAccessDBG
'Set an active connection to the Connection object
'adoConG.Open "DSN=Gaskets"
adoConG.Open strConG
'Create a recordset object
Set rsGasket = Server.CreateObject("ADODB.Recordset")
%>
Does that admin user require permission to access the database? Or am I missing something else which is obvious?
If you're using a UID/PWD for this, that would have to match an account that was used to lock the database, or a machine/domain account that will have write to/lock permissions to the db. Also, keep in mind that classic ASP is running under the IUSR_ account by default - sometimes this account must have write access to the directory/file containing the Access db.
I have made a small ASP.NET website. It uses sqlcachedependency
The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications.
Source Error:
Line 12: System.Data.SqlClient.SqlDependency.Start(connString);
This is the erroneous line in my global.asax.
However, in sql server (2005), I enabled service broker like so (I connect and run the SQL Server service when I debug my site):
ALTER DATABASE mynewdatabase SET ENABLE_BROKER with rollback immediate
And this was successful.
What am I missing? I am trying to use sql caching dependency and have followed all procedures.
Thanks
I faced the same problem on one of our servers. this solved the issue (replace DBNAME with database name)
ALTER DATABASE DBNAME SET NEW_BROKER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE DBNAME SET ENABLE_BROKER;
Finally, check whether you get 1 for is_broker_enabled flag:
SELECT is_broker_enabled FROM sys.databases WHERE name = 'DBNAME'
Do you use a normal SQL instance, including Express, or are you using User Instances? ie. your connection string uses "AttachDbFilename" option? On user instances because the MDF is attached each time the instance is created, the Service Broker gets disabled each time because attach and restore operations always disable the broker in the database.
Ditch the "with rollback immediate" and try running the statement again.
Does it hang? If so kill any other sessions that are in the database and are blocking the session trying to alter the database.
Here's the script I mentioned in my comment.
use master
go
declare #parent int
declare #cmd varchar(100)
set #parent = 53
while exists (select * from sys.sysprocesses where spid = #parent and blocked <> 0)
begin
select #cmd = 'kill ' + cast(blocked as varchar(10))
from sys.sysprocesses
where spid = #parent
print #cmd
exec (#cmd)
end
You can change it by
Data Base - > Properties -> Options -> Service Broker