When running a command line executable, one of the tasks is to drop a database. When this gets run, SQL Server tells me that
'DBName' does not exist or you do not have permission. The database is confirmed to exist. At this point in the script, it has already been taken offline and set into single user mode (to ensure that there are no active connections prior to deletion). How come the program cannot drop the database?
EDIT: The user I am running as is able to delete the database manually via SQL Server Management Studio.
The command line executable I am running is actually a compiled C# program that is executing
DROP DATABASE SQL statement via System.Data.SqlClient.SqlConnection. It is connecting to SQL Server using the same connection credentials (localhost with integrated security) as used to connect via the GUI.
The actual SQL getting executed (copy/pasted into SQL Server to test) is:
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'DBName') DROP DATABASE DBName
EDIT 2: This program Works On My Machine (tm), but not on the remote server that it needs to be run on.