Msg 5123, Level 16, State 1, Line 1 CREATE FILE encountered operating system error 5(Access is denied.) - database-administration

How can I resolve this error:
Msg 5123, Level 16, State 1, Line 1 CREATE FILE encountered operating system error 5(Access is denied.)
while attempting to open or create the physical file 'C:\Banking.mdf'.

You need to ensure that you have the appropriate account permissions on the account in order to access the folder the mdf file is located in.
More detail can be found in the following link.
https://dba.stackexchange.com/questions/22250/sql-server-create-file-encountered-operating-system-error-5-access-is-denied

I encountered the same error when I called 'update-database' the first time I tried to run Entity Framework Core / EF Core.
I solved it!
The full error message was:
CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'C:\Users\peterObjectData.mdf'.
Creating files in C:\Users\ directory requires admin rights.
To fix this, one can add a file location and name for the mdf file in the connection string:
optionsBuilder.UseSqlServer("Server = (localdb)\mssqllocaldb; Database = ObjectData; Trusted_Connection = True; AttachDbFileName=D:\Databases\ObjectDB.mdf");
Here, "D:\Databases\ObjectDB.mdf" is the location and filename of the .mdf file created. This fixed my issue.
If you want to read more on ConnectionStrings and AttachDbFileName, here's the documentation:
https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring?view=netframework-4.7.2#examples

That must be your C drive denied the SQL server to create file. You can either change the direction to other drive(D:;E:) or if you dont want to, then you have to change the security properties for your C:\ drive. Right click C:, choose properties, security, change authenticate user and user to full control then you good

Related

Azure .Net SDK Error : FsOpenStream failed with error 0x83090aa2

We are trying to download a file present in Data Lake Store. I have been following the below tutorial which uses .Net Azure SDk.
https://azure.microsoft.com/en-us/documentation/articles/data-lake-analytics-get-started-net-sdk/
As we have already the file present in Azure Data Lake Store , I just added the code to download the file
FileCreateOpenAndAppendResponse beginOpenResponse = _dataLakeStoreFileSystemClient.FileSystem.BeginOpen("/XXXX/XXXX/test.csv", DataLakeStoreAccountName, new FileOpenParameters());
FileOpenResponse openResponse = _dataLakeStoreFileSystemClient.FileSystem.Open(beginOpenResponse.Location);
But it's failing with the below error
{"RemoteException":{"exception":"RuntimeException","message":"FsOpenStream
failed with error 0x83090aa2 ().
[83271af3c3a14973ad7814e7d9d201f6]","javaClassName":"java.lang.RuntimeException"}}
While debugging we inspected the beginOpenResponse.Location that been used in the second line code. It seems to the correct value as below
https://XXXXXXXX.azuredatalakestore.net/webhdfs/v1/XXXX/XXX/test.csv?op=OPEN&api-version=2015-10-01-preview&read=true
The error does not provide much information to track down the problem.
I agree that the store errors are currently non-printable comment. We are working on improving this.
According to my store developer, 0x83090aa2 is access check failed. Can you please check if you have access to the storage account and/or the path is correct?

Distributed Queries in SQL Server, data from XLS

I would like to create a view in SQL Server 2008 that displays the data contained in an Excel file.
I do not want to use the import data as these data are updated.
I found this: http://support.microsoft.com/kb/321686/en
I made these commands to enable some options :
sp_configure 'show advanced options', 1
RECONFIGURE
GO
sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO
But when I try to read the Excel file with this query:
SELECT * FROM INTO XLImport3 OPENDATASOURCE ('Microsoft.Jet.OLEDB.4.0', 'Data Source=C:\Documents and Settings\jconnor\Desktop\Test.xlsx') ... [Sheet1$]
I back (it's a translation from french) :
The OLE DB provider " Microsoft.Jet.OLEDB.4.0 " for linked server " (null) " returned >message " Unspecified error " .
Msg 7303 , Level 16 , State 1, Line 1
Unable to initialize the object data source OLE DB provider " Microsoft.Jet.OLEDB.4.0 " for >linked server " (null) " .
Does someone have any clue ?
Thank you in advance
Kal,
So your main error is likely this;
OLE DB provider "MICROSOFT.JET.OLEDB.4.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MICROSOFT.JET.OLEDB.4.0" for linked server "(null)".
I would check some permissions.
Check the permissions on the Temp folder
This is needed because the provider uses the temp folder while retrieving the data. The folder can be one of the below based on whether you use a local system account or network domain account.
For network accounts, folder is
\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp
and for local system account its \Windows\ServiceProfiles\LocalService\AppData\Local\Temp
Right click on this folder and give it read write access to the account (or group) executing the code. That solved the error for me.
Also
http://blogs.msdn.com/b/spike/archive/2008/07/23/ole-db-provider-microsoft-jet-oledb-4-0-for-linked-server-null-returned-message-unspecified-error.aspx
This is because the SQL Server Service is trying to write the temp DSN to the temp folder for the login that started the service, in this case the Admin/Admin login.
The temp folder is something like: C:\Documents and Settings\Admin\Local Settings\Temp
.15 As mentioned, the OleDbProvider will always execute in the context of the user who initialized it, in this case User/User.
.16 User/User has no rights on this folder (C:\Documents and Settings\Admin\Local Settings\Temp).
If running FileMon when the SQL is executed, we can see the following:
(Actually, try using Process Monitor - http://technet.microsoft.com/en-us/sysinternals/bb896645)
sqlservr.exe:000 QUERY INFORMATION C:\DOCUME~1\Admini~1\LOCALS~1\Temp ACCESS DENIED Attributes: Error
So to summarize so far:
The SQL Server service is started as Admin/Admin, when the select is made, the OleDb provider is invoked by User/User.
Now the OleDb provider attempts to create a temporary DSN in the temp directory. This will be the temp directory for the SQL Server service (Admin/Admin)
but the user (in this case User/User) does not have write permissions on this folder. And the error occurs.
There are two ways to resolve this.
Option 1:
Log out of the machine and log in as the account that starts the SQL Server Service (in this case Admin/Admin) then start a command prompt
and type “set t” (no quotes), this will show something like:
TEMP=C:\DOCUME~1\Admin\LOCALS~1\Temp
TMP=C:\DOCUME~1\Admin\LOCALS~1\Temp
these are the environment variables set for %TEMP% and %TMP%, so go to that folder and right click and select Properties -> Security,
then add the user, in this case User/User, note that the default for the user is Read&Execute/List Folder Content/Read, this not enough, you have to select Write as well.
Log out, and log in again as User/User and rerun the command from SSMS. This time it should work.
Option 2:
Log on as Admin and change the TEMP and TMP variable to, for example, C:\Temp, basically this moves the Temp directory out of the Documents and Settings folder.
However, you must restart the SQL server for this to take effect.
So basically, what happens is that when SQL Server starts, it uses the Temp folder of the startup account (Admin/Admin) but the MICROSOFT.JET.OLEDB.4.0 will always execute
as the user who calls the SQL command (User/User) and this will fail unless this user does not have Write access to that temp folder.
Without knowing all setups out there, perhaps option 2 is the preferred solution since with option 1, you will have to add ALL the users that will invoke the provider which may not be practical.
Also, when changing the startup account for the SQL Server service, then the TEMP directory for that account will be used, and you will see the error again until you, again, give write permissions for all the users on this TEMP folder...or a user group (preferred).

Server Error in '/DotNetNuke_Community' Application

I'm getting the following error when attempting to run DotNetNuke 7.1 from IIS.
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 572: //first call GetProviderPath - this insures that the Database is Initialised correctly
Line 573: //and also generates the appropriate error message if it cannot be initialised correctly
Line 574: string strMessage = DataProvider.Instance().GetProviderPath();
Line 575: //get current database version from DB
Line 576: if (!strMessage.StartsWith("ERROR:"))
I've tried running it from Visual Studio 2012 after downloading and extracting the source code to a folder, then running, but I get the same error (also, VS loads about 13 instances of it's built in webserver which can't be correct).
Clearly, there is something wrong with the database. From what I've read in the past, there should have been a start up configuration page (for configuring settings the first time you run the project).
I did look at the local version of IIS (running on Windows 8) and it created the site fine there, however, for some reason the internal webserver attempts to run (and the option to run on an external IIS is greyed out).
Anyone run into this problem with DNN Community edition? I've tried running as admin and setting permissions with no luck at all.
Any way to fix this?
Ok, the key is to delete the Database.mdf file completely.
Then create a new empty database of your choice in SQL Server (2008 or greater).
Create a new user account with db_owner access (as it must be able to create tables, etc).
Change the connection strings in the release.config and development.config to connect to the database.
DELETE the web.config file.
RENAME either config file to "web.config"
Set the default project to the web project in VS
set the default page to default.aspx
Run
I made the erroneous assumption that running the app would rename the config file for me (not sure why I assumed that).
SOLVED!

Error when backing up a database in SQL Server 2008 R2

In XP machine, I am using SQL Server 2008 R2 to backup files, that the files are stored in the c:/ProgramFiles/.../Data folder, but in this case I got the exception
Cannot open backup device 'C:\Program Files\Data\BlaBla_123.bak'.
Operating system error 5 (failed to retrieve text for this error. Reason: 1815).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
My query
ALTER DATABASE BlaBla SET SINGLE_USER WITH ROLLBACK IMMEDIATE
backup database BlaBla to disk = 'C:\Program Files\Data\BlaBla_123.bak'
But I know this will work when I stored the backup file in the D drive or something,
My question is, How to save the backup in the Same folder and What I need to do from code side or query side?
I added Network Service (or of the accout that is assigned to the SQL Server service account) with Full Control permission to the ACL (Access Control List) of the backup .bak file.

Error 4005 when running ExtractFile in a scheduled agent

I have a scheduled LotusScript agent that I want to loop through documents in a view and extract the attached file(s) to a folder on the server:
'extract file
If Not IsEmpty(rtitem.embeddedObjects) Then
ForAll o In rtitem.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then
Call o.ExtractFile("\\TestServer\TestFolder\"+o.name)
End If
End ForAll
End If
This agent works fine when ran through the Notes client. However, when the agent is scheduled I get the following error: "Error: 4005 - Notes error: Logon failure: unknown user name or bad password". It errors at the "Call o.ExtractFile(..." line above.
I've tried changing the security level on the agent to "Allow restricted operations with full admin rights" and "Run as Web user" but the error persists.
Any thoughts are greatly appreciated.
This appears to be a network error and not an error within Lotus Notes. Make sure the account under which the server is running has access to the share.
This is very common issue: If you are going to extract the file on
some location then also check the drive is exists on server or not.
Make sure you have proper rights to create a file on the folder, it means folder should have full access.
Agent should have proper rights.

Resources