Database Context Changed To &<dbname&>

Jan 13, 2005

I am in a bind here..

I am getting the message (after do any sort of query) Database context changed to <dbname> I am using PHP as the p language.

Does anyone have any clue on why it is doing that..

Recently my host upgraded there PHP to version 4.3.10 and before the upgrade the queries were working fine.

Im on a windows server that runs PHP and im using a MSSQL database.

I've checked the bug reports on PHP and didn't come up with anything as well as googling the error..

IF you have any insite on this problem please let me know.. It may be a stupid error that I am overlooking on my part.

Thanks in advance

View 1 Replies


ADVERTISEMENT

Error [Microsoft][SQL Native Client][SQL Server] Changed Database Context

Mar 2, 2008

Hi try to connect with driver {SQL Sever Client} but i can't
I'm have SQL Server 2005 Express SP2

Error connecting to the ODBC server:[Microsoft][SQL Native Client][SQL Server] Changed database context to..


Please Help me

Thanks

View 10 Replies View Related

Changed Context To ... Message When Editing Permissions W/ VBA

Oct 25, 2007

I have a client using a small SQL Express database with an Access front end.

I've created a form in the front end that allows a supervisor the ability to perform two very basic security operations. 1) Adding a new user, and 2) granting/removing write privileges. The code behind the form uses VBA to build some T-SQL strings and then executes them via an ADO connection.

The strings are as follows:

1) Add new login to server:
"CREATE LOGIN [NETWORKUserName] FROM WINDOWS WITH DEFAULT_DATABASE = MyDatabase"

2) Add user to database:
"USE MyDatabase CREATE USER [NETWORKUserName]"

3) Grant Write Permissions:
" USE MyDatabase EXEC sp_addrolemember 'db_datawriter', 'NETWORKUserName' "

4) Remove Write Permissions:
" USE MyDatabase EXEC sp_droprolemember 'db_datawriter', 'NETWORKUserName' "

I have full privileges over the server & database, and everything runs perfectly.

However, when the supervisor - whose login includes security admin privileges - tries this, he gets a message that says "Changed Context to MyDatabase, Error# -2147217900, 80040e14" and the code fails.

If I grant him "db_owner" status, the message does not come up and everything runs perfectly.

I'm not a security guru or anything, but I suspect that it's not the greatest idea to hand out db_owner privileges.

I ran a search, and the best I could come up with were a couple of KB articles:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;197459
http://support.microsoft.com/default.aspx?scid=KB;EN-US;143339

I'm not even sure these articles are talking about what's happening..

Any ideas?

View 4 Replies View Related

Changed Context To ... Message When Editing Permissions W/ VBA

Feb 15, 2008

I have a client using three small SQL Express databases with MS Access front ends. I've created a form in each of the front end apps that allows a supervisor the ability to perform some very basic security operations. The VBA code in the form concatenates some simple TSQL strings and then executes them via an ADO connection. The strings are as follows:


1) Add new login to server:
"CREATE LOGIN [NETWORKUserName] FROM WINDOWS WITH DEFAULT_DATABASE = MyDatabase"

2) Add user to database:
"USE MyDatabase CREATE USER [NETWORKUserName]"

3) Grant Write Permissions:
" USE MyDatabase EXEC sp_addrolemember 'db_datawriter', 'NETWORKUserName' "

4) Remove Write Permissions:
" USE MyDatabase EXEC sp_droprolemember 'db_datawriter', 'NETWORKUserName' "

Everything runs perfectly for me. However, when the supervisor tries this, he gets a message that says "Changed Context to MyDatabase, Error# -2147217900, 80040e14" and the VBA code fails.

I've found two workarounds, but they have drawbacks that I'd rather not deal with

1) If I change the default database for his login to "MyDatabase1" it runs fine. But sometimes he needs to be able to perform these same operations in "MyDatabase2" or "MyDatabase3".

2) If I grant him "db_owner" status, it runs fine. However, I'd rather not hand out "db_owner" status if I don't have to

The only other idea I have to to build "EXECUTE AS.." stored procedures for each of these operations and then call those SPROC's from VBA.. Will this help? Any other ideas?

View 3 Replies View Related

Database 'dbname' Cannot Be Opened Because Its Ver

Apr 1, 2007

i have curputed mdf and ldf file for ms sql 2005

i have tried to put the db in standby mode and when i try to run dbcc checkdb or any other command i get this message

Database 'dbname' cannot be opened because its version (611) is later than the current server version (539).


but without standby mode i get this error

TITLE: Microsoft SQL Server Management Studio
------------------------------

Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

Could not find row in sysindexes for database ID 40, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes. (Microsoft SQL Server, Error: 602)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=602&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------

View 2 Replies View Related

EXECUTE Permission Denied On Object 'aspnet_CheckSchemaVersion', Database 'dbname', Owner 'dbo'.

Aug 30, 2007

Hi!I have a problem. i have created a website with a login page, i have moved all my aspnetdb tables to my remote host. but when iam trying to logon i get this error messages.
EXECUTE permission denied on object 'aspnet_CheckSchemaVersion', database 'dbname', owner 'dbo'.
Someone? I really need help...

View 3 Replies View Related

The SELECT Permission Was Denied On The Object 'tblName', Database 'dbName', Schema 'dbo'

Nov 9, 2007

Hi,

I'm in need of a few more pointers when it comes to SQL Server 2005 Security setup for accessing a database through IIS web services. There's loads of great advise in these forums which I've followed so pls forgive me if I've missed a post that finally resolves this. I know I'm so close but it feels so very far...

Anyhow, here's the set up:
- Server 2003 / SQL Server 2005 / .NET 2.0 / Visual Studio 2005 / Client XP PC

The story so far:
- Built an ASPX website in VS2005 on a client PC that connects to a SQL2005 db. No probs during development.
- Copied website to WS2005 & configured IIS accordingly. No probs browsing non-db webpages.

The problem:
As soon as I browse to a page that extracts data from the db I get the following error message..


[SqlException (0x80131904): The SELECT permission was denied on the object 'tbl_location', database 'SmartDMA', schema 'dbo'.]

...plus a whole load of code that I've seen plastered over lots of forums.

My configurations:
- The website is in the default SQL Application Pool that has the identity set to 'Predifed: Network Service' (as I'd previously has a similar error; SQLException (blah blah): Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection)

- IIS Website ASP.NET is v2.0.50727
- Website Authentication Methods / Enable Anonymous Access (ticked) Username: IUSR_SERVERNAME Password: *********. Intergration Windows Authentication (ticked).
- SQL Server Mngt, Secuirty / Logins / NT AUTHORITYNETWORK SERVICE lists the db in question with dbo as the Default Schema & public ticket as the db role membership.
- connectionString="Data Source=SERVERNAME;Initial Catalog=DBNAME;Integrated Security=true" providerName="System.Data.SqlClient"/>


What I've tried already based on forums advise:
- Changing Server Properties to SQL Server & Windows Authentication mode.
- Rather than using Integrated Security I've tried the SQL 'sa' account, but not 100% is I did that right (still got the same error anyway).

The rest of the advise I've read appears to confirm the rest of my settings, but I'm still getting the error.

Can anyone please shed any light on what I'm missing here. Feel free to ask questions on any configuration settings I've missed that may help.

Many thanks in advance..

View 4 Replies View Related

Cannot Open Database Dbname Requested By The Login. The Login Failed.

May 29, 2008

I am getting the above error. On server1 I am running a dts package via a sql server job (sql server2005). This has been working perfectly for over a year. This package needs to access a database on server2. The database in question on server2 was recently restored from our produciton environment to refresh the data. Every since thsi time the job on server1 is failing with the above error.

Steps I have taken so far:
droped the user from server2 and recreated it
gave the user sysadmin rights on server 2 and server1

View 1 Replies View Related

Cache Database Structure (How To Detect If Database-design Has Changed..)

Feb 24, 2006

Hello everyone,I have a webcontrol that uses database-structures alot, it uses the system tables in SQL to read column information from tables. To ease the load of the SQL server I have a property that stores this information in a cache and everything works fine.I am doing some research to find if there are anyway to get information from the SQL server that the structure from a table has changed.I want to know if a column or table has changed any values, like datatype, name, properties, etc.Any suggestions out there ?!

View 3 Replies View Related

Cannot Open Database Requested In Login 'dbName'. Login Fails. Login Failed For User 'machineNameASPNET'

Jul 27, 2005

Been looking through the forums for a solution to this problem.I already tried granting access through statements such as:exec sp_grantloginaccess N1'machineNameASPNET'But they don't seem to work.. i vaguely remember seeing somewhere a DOS command line statement that grants access to the ASPNET_WP and that fixed my problem before on another computer.. but this is a new computer and i forgot to write down the command.Can anyone help explain and propose a solution to my problem. Many thanxs.

View 9 Replies View Related

Database Context

Apr 29, 2003

Hi,

I am trying to create a block of sql statements that will read the sysdatabases table, and store the value of the database in a variable.

I want to use a cursor to step through all these databases (excep of course the control databases).

For each of the databases I want to run a backup log followed by dbcc shrinkfile. For dbcc shrinkfile, I need to change the database context.

What I am finding is that I cannot use the variable to hold the database name.

here is the code

-------------------------

SET NOCOUNT ON
DECLARE @db_name varchar(100)
DECLARE @db_filename varchar(100)

DECLARE list_dbs Cursor
FOR select [name] from master..sysdatabases

OPEN list_dbs

FETCH NEXT FROM list_dbs into @db_name

WHILE @@FETCH_STATUS = 0
BEGIN

select name = @db_filename from @db_name..sysfiles

backup log @db_name with no_log

use @db_name

dbcc shrinkfile (@db_filename, 25)


FETCH NEXT FROM list_dbs into @db_name

END

CLOSE list_dbs
DEALLOCATE list_dbs
-----------------------

I get a syntax error where ever the @db_name is used (on the select and on the use).

Any suggestions?

Thanks,

Jim

View 7 Replies View Related

Changing Database Context

Mar 15, 2001

Hi all,

I have an application that executes the USE command as it's first order of businees with the database. According to the SQL Books On-line, all USE commands will result in the following message being generated:

Error 5701
Severity Level 10
Message Text:
Changed database context to '%.*ls'.

However, my application has never reported this message, execept for at one customer site. I cannot figure out why at this one particular site, the customer is seeing this message each time the application starts. Once they ok the message, everything else with the application is fine, but it is a nuisance for them (gotta love customers!).

Any ideas why this would start happening?

View 1 Replies View Related

Has_perms_by_name Database Context

Feb 6, 2008

In reading Has_Perms_By_Name documentation in BOL, it appears that using a three-part name will make no assumption on the database context. However, when I run the code below, I get results that are database context sensitive.




Code Snippet

USE [master];
print has_perms_by_name('master.sys.sysusers', 'object', 'select')
print has_perms_by_name('msdb.sys.sysusers', 'object', 'select')
print has_perms_by_name('AdventureWorks.sys.sysusers', 'object', 'select')
print ''
USE [msdb];
print has_perms_by_name('master.sys.sysusers', 'object', 'select')
print has_perms_by_name('msdb.sys.sysusers', 'object', 'select')
print has_perms_by_name('AdventureWorks.sys.sysusers', 'object', 'select')
print ''
USE [AdventureWorks];
print has_perms_by_name('master.sys.sysusers', 'object', 'select')
print has_perms_by_name('msdb.sys.sysusers', 'object', 'select')
print has_perms_by_name('AdventureWorks.sys.sysusers', 'object', 'select')




The results are:


1

1

1



1

1

1



0

0

0

I created a login called 'temp' and added a user for this login in the AdventureWords database. I then added a securable for sys.sysusers for this user in the Adventureworks database. I then selected the "Deny" checkbox for the Select permission. I connected as temp and ran the T-SQL above.

It appears that the database name is being ignored when included in the name of the securable. What am I missing? Is this a bug?


My version: Standard SQL Server 2005 9.0.3054 on Windows 2003 R2 SP2 (3790).

Thanks,
Randy

View 1 Replies View Related

System Process Database Context

Feb 27, 2007

SImon writes "I'm unable to take a user database offline because there are system process using it and I can't identify or kill the system processes"

View 1 Replies View Related

Is There Anyway To Tell When A Database Was Last Accessed Or Changed?

May 29, 2007

Is there a simple way to tell when a database was last accessed or changed?



We have some databases on old servers which we would like to discontinue but do not know if they are being used.



We would rather not just take them offline.



Is there anyway I can find out if they are still being used?



Please help if you can.



Regards, Major (that is my Christian name ;-)

View 3 Replies View Related

How To Change The Database Context And Modify Tables?

Oct 4, 2007

I have 30+ databases in sql 2000.
I want to dynalically loop though each of the databases and alter a column named 'EmpName' for all the 'Employees' tables in that database.
Here is my attempt.use Master
go
declare @SQLString Nvarchar(1000)
declare @DBName Nvarchar(100)
declare @SQL2 NVARCHAR(1000)declare @TABLE_NAME NVarchar(100)
DECLARE curDB CURSOR LOCAL FORWARD_ONLY STATIC FOR
SELECT name FROM sysdatabases
OPEN curDB
FETCH NEXT FROM curDB INTO @dbname
While @@FETCH_STATUS=0
Begin
      SET @SQL2 = 'USE ' + @DBNAME + ' ALTER TABLE ' + @TABLE_NAME + ' MODIFY EmpName varchar(100)'
     from information_schema.tables where table_type = 'BASE TABLE' and table_name like '%Employees%'      PRINT @SQL2
      EXECUTE SP_EXECUTESQL @SQL2
fetch next from curDB into @DBName
end
Close curDB
End
When i execute the above script in master, it says 'Query executed successfully' but when i see the all the Employees table in each of the database, the required change is not made.
Can anybody explain this or give an alternate solution? 
 
 

View 2 Replies View Related

The Database Principal Is Set As The Execution Context Of One Or More Procedures ...

Aug 14, 2007

I have database in the database there are a few users that no one is used. When I try to drop thpse users I got next error message:
"The database principal is set as the execution context of one or more procedures, functions, or event notifications and cannot be dropped." (Msg 15136)

Indeed, I think that those users have execute rights on store procedures.
How do I find for wich procedures or other database objects those users have grants?
How do I delete them from database (and maybe from logins of the server)?
How can I see what grants a user has?
How can I see what grants does STP has?

View 10 Replies View Related

How To Change Database Context Dynamically In SQL 2000

Oct 4, 2007

I am using Sql Server 2000.
I have about 25+ databases . I want to run a series of commands on each database... how can I change the database context - the current database - dynamically in a loop...
something like this below:



declare @SQLString Nvarchar(1000)

declare @DBName Nvarchar(100)

declare @SQL2 NVARCHAR(1000)

declare @TABLE_NAME NVarchar(100)

While @@FETCH_STATUS=0

Begin

SET @SQL2 = 'USE ' + @DB_NAME + ';GO;ALTER TABLE ' + @TABLE_NAME + ' MODIFY Name varchar(100)'

PRINT @SQL2

EXECUTE SP_EXECUTESQL @SQL2

End




I am getting an error when i run the above commands:
Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'GO'

Can someone give me the correct solution?

View 4 Replies View Related

In 2005, Finding Users Who Have Context In A Database?

Jun 23, 2006

I know sysprocesses has the information, but I can't seem to find how this is done using the dmv's. sessions doesn have a db context, and requests is only active while activity is occurring.

Thanks!

View 4 Replies View Related

Database Settings Changed(Very Very Urgent)

Mar 8, 2001

How do i find who has changed the settings in the database.

basically when i looked at this morning i saw a database which is set in single user mode.when i tried to look at the errorlog i found nothing except the spid's of different people and as far as i know i think that spid's are assigned randomly depending on there availability.

Now this has happened twice recently and now i want to find out who the culprit is his username, machine name but not spid.

Can i do it if how can i.

how do i track each and every users info what he is doin and at what time.

do i need to set up or configure any options.

sometimes i also see that there is a dbcc command run by as it says winnt/system what does this mean how is this running.

Thanks in advance for ur great help.

Its very urgent because its a production machine.

View 4 Replies View Related

Database Won't Start In Cluster - Cannot Generate SSPI Context

Jun 2, 2006

Hi,
I have a MSSQL database running in a Microsoft cluster. I was working on troubleshooting for another SAP problem when they suggested I change the setting using hte SQL Server Client Network Utility to 'named pipes' from 'tcp/ip'. Every since, despite changing it back I'm unable to start the database in the cluster.

I'm kind of a newbie at this so I'd really appreciate any help in getting this database up and running.

Here is the error message from the event log:
sqsrvres] checkODBCConnectError: sqlstate = HY000; native error = 0; message = [Microsoft][ODBC SQL Server Driver]Cannot generate SSPI context

View 2 Replies View Related

SQL Server 2008 :: Unable To Change Database Context

Apr 28, 2015

USE master
Declare @db as nvarchar(258) = quotename (N'tempdb')
EXEC (N'USE' + @db + N'; EXEC(''SELECT DB_NAME();'');');

View 5 Replies View Related

Cannot Connect To SQL Server Database Using Ado.net After IP Address Has Changed

May 4, 2004

Dear all,

I wasn't able to connect to my SQL server 2000 database (which reside in the network in a windows 2003 server) after the IP address of the server has changed and the server is shut down, moved and re-started.

I was able to connect to this server by using ADO using VB. I was able to register this server in my EM and was able to create ODBC connection. Just when using ADO.NET, I wasn't able to connect. Any ideas? Will there be any caching within ADO.NET still pointing to the old IP address?

Thank you for all the help in advance.

View 5 Replies View Related

Dont Backup If Database Hasnt Changed

Sep 15, 2005

I do weekly full backups of my SQL databases via a scheduled T-SQL job.I noticed that I have some static databases that dont normally change,so I dont want to back it up if it has not changed, but when it does,then I want a backup.Is there something in the master table, as example, that I can checkprior to running the backup that will indicate any changes?An example is the Northwind database. I could exclude it from thebackup, but then I would not back it up if it where to change. Againthis is an example, I would not need to modify Northwind.Thanks in advance for any ideas; they usually give me ideas to problemsyet to come....Rob Camarda

View 3 Replies View Related

Unable To Access The Database Master Under The Current Security Context.

Jun 16, 2007

I have a login that is mapped to a Windows sysadmin account. I used it to login to Sql Server 2005. I then created a database called Freedom. I then added a Windows login and user called FreedomAdmin, with Freedom set as the default database. When I login in to Windows using FreedomAdmin and then try to login in to Sql Server 2005, I get the following error:

The server principal "FREEDOM1FreedomAdmin" is unable to access the database "master" under the current security context.

If the default database for FreedomAdmin is Freedom (and it is - I checked from my sysadmin login account), why can't I login. Must I give FreedomAdmin permissions to master?

View 6 Replies View Related

User Is Not Able To Access The Database Model Under The Current Security Context

Feb 7, 2008

I have a restriced user on SQL Server that is only permitted to creat a new database and manage it only. All other database are hidden to that user.

when that user login to SQL Server and create a database and try to change the default folder path for data and log files, gets an error,

The Server principal "User" is not able to access the database "model" under the current security context. (MSSQL Server, Error: 916)

Any idea???

Thanks,

View 7 Replies View Related

SQL 2012 :: Database Mail Profile Security Changed On Its Own?

Oct 30, 2015

We had a strange incident with our Database Mail today. We use sp_send_DBMail to send mail from stored procedures in our SQL Server 2012 (11.0.2138). There are 7 profiles available for use by different databases. The actual stored procedures are called by Web apps using a connection string that has a specific SQL user identified.

Last night app 1 was using profile 1 like usual and app 3 was using profile 3 like usual. This this morning (7 hours later) App 3 was sending from profile 1 everytime a call to sp_send_dbmail was made. Not good. App 1 was still correctly sending from profile 1.

We ran a call to sp_send_dbmail from a query window using profile 3 and it sent using the correct profile 3. We used the Database Mail right-click option of "Send Test Email..." to both profiles and they worked as expected.

Our investigation showed that in the Database Mail configuration wizard "Manage Profile Security" section Private Profiles tab... the User name that is used to call the stored procedures from web app 3's sp_send_DBMail did not have access to profile 3 anymore. It did have access to 5 of the other 7 profiles. 1 of the no access profiles was legitimate #7.

The only thing that has been changed lately was, 2 days ago a mail profile was deleted as it was no longer used. We used the Database Mail Configuration Wizard to remove it.

View 0 Replies View Related

Transact SQL :: Send Changed Database Record To Computer

Apr 21, 2015

I have an online SQL Server database, and my web site registered clients can change the records of this database. My need: if a record of this database is changed, whole the changed record send to me and to the person who changed it immediately. I thought it could be possible through Transact-SQL,

View 2 Replies View Related

The Server Principal XYuser Is Not Able To Access The Database Ydb Under The Current Security Context

May 23, 2007

SQL2005 on winserver 2003. I have a view in Xdb that accesses tables in 2 different databases (Xdb and Ydb) on the same server. I have mixed mode security. I have a SQL user (XYuser) that has read access to all tables and views on both databases, yet when I try to access the view using a C# windows application I get the following error:



The server principal "XYuser" is not able to access the database "Ydb" under the current security context



This same scenario works under SQL 2000. I looked through the postings and tried to set TRUSTWORTHY ON on both databases but that didn't help. I can access any other views or tables on the SQL 2005 server, just not the one that joins the tables cross databases. Any help is much appreciated... john

View 17 Replies View Related

Windows Server Principal Denied Access To Database Under Current Context

May 1, 2007

Hi guys. I created a database "MyDatabase" using an AD Account "user01" which is a member of a domain group "GroupA". I have created a login in my SQL Server 2005 for this AD group. I have also added the said login as a user of my database. I created other AD users and put them in the same group. When I try to access the database using the other users, I get this message

The server principal "MyDomainuser02" is not able to access the database "MyDatabase" under the current security context.

This KB tells me that my situation is triggered by the first case in which the owner of the database is windows authenticated. I have already set the database to be TRUSTWORTHY. I haven't tried CERTIFICATES though. I believe I haven't done anything complex to warrant this solution.

I'm really lost with the myriads of principals and securables that SQL2005 has. All I want is just to execute a certain set of stored procedures. I can't do this because I can't even execute "USE MyDatabase". What are the permissions I need to give to "GroupA" ?

View 5 Replies View Related

USE DbName In Proc...

Dec 7, 2001

Need to have 'Use Master' statement in one stored procedure from a Admin database to execute some task only in Master database could be performed.

error: Use database statement is not allowed in a procedure or trigger.

Is there a way to bypass this error?
I know my last result will be to put this stored procedure in Master, which I really don't want to...

thanks for help
-D

View 2 Replies View Related

USE [dbname] In Sp_executesql

Sep 14, 2007

I am trying to get file space usage information for all of the databases in my server and store it in a table to collect a history of spce usage. I know that I can get this on a per database basis if I use DBCC(SHOWFILESTATS). So, I would issue a USE statement and then a DBCC statement inserting the rows into a temp table for later processing. Since databases can come and go, I would like to loop through the records in sysdatabases and for each one, issue the USE and then the DBCC via an sp_executesql.
This is all working fine except, the sp_executesql of the USE statement seems to be ignored.

Is there some way to get this statement to take effect?
Is there a better way to get this information - ie is this stored in a table or view that I can't seem to find?

Thanks in advance for your help.
Bob

View 4 Replies View Related

Transact SQL :: Send Changed Record Of Online Database To Application

Apr 23, 2015

I am programming an online game (such as chess) which two players can play together online.

Each one of the players should have installed the game application (developed by C#) on their computers.

When a player do some action, a record of a database (SQL Server 2012) which has been placed on the internet will be changed.

My need: when a record of this online database changes, whole the record send to both players' game application immediately.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved