cancel
Showing results for 
Search instead for 
Did you mean: 

Ultralite Access is denied in UWP but not in dot NET

Former Member
3,771

I am using SQL Anywhere 17 Developer’s version. I have a local UltraLite 17 database that I can access (connect to) with SQL Central 17 and a Visual Studio 2017 app using UltraLite.NET 17. I have subsequently converted this app into an UWP app utilizing the WinRT UltraLite library. This app cannot connect to the database that .NET app and SQL Central can connect to. The WinRT UltraLite library returns with the error “Access is denied”, error number -82. The same connection parameters: uid, pwd, and dbkey are used in all three instances. The UWP app has been run via the VS debugger in the “Local Machnine” and “Simulator” with the same results. The “Portable” project is compiled for “AnyCPU” while the UWP project is compiled for “x64”. I am using the x64 UltraLite libraries too.

In Sql Central 17 I created a new UltraLite db that does not require an uid, pwd or dbkey. I can connect to it via my app with UltraLite.NET but not the UWP app built with WinRT UltraLite. Same “Access is denied” error.

I have tried the connection string with and without double and single quotes. Yes in UWP apps one has to build the connection string and not set an object’s parameters (at least I couldn’t find it). Any thoughts would be greatly appreciate

Accepted Solutions (1)

Accepted Solutions (1)

chris_keating
Product and Topic Expert
Product and Topic Expert

What is the location of the database file?

UWP can only access certain file locations by default. If the database is stored in a location other than those allowed locations, you will encounter this error.

See https://docs.microsoft.com/en-us/windows/uwp/files/file-access-permissions#accessing-additional-loca...

Former Member
0 Kudos

Location seems to be an issue. I can connect to two different UL 17 DB's in a certain location but not others. The location they are accessible is where the one was created with a UL Sample program - custdb.udb. The interesting thing is that in the locations that I cannot access these two databases I can access an XML file I have with StreamReader. I guess that threw me off a little since I'm not useing StorageFile. I will read the link you provided in detail. Thanks.

I have a third database that was an UL 12 db and converted to 17 that I can't connect to from any location - Access is Denied. This is the database that I want to connect to and eventually sync once we get all the software purchased and installed, e.g. MobiLink 12 upgraded to 17. Any thoughts on this issue?

chris_keating
Product and Topic Expert
Product and Topic Expert
0 Kudos

You may want to try putting the converted v17 UL database file in the location ApplicationData.Current.LocalFolder.Path which is accessible in UWP:

UltraLite.Connection conn = UltraLite.DatabaseManager.OpenConnection("dbf=" + ApplicationData.Current.LocalFolder.Path + "\\mydatabase.udb;dbkey=mydbkey");

The ApplicationData.Current.LocalFolder.Path points to a location under local app data for the application. That location is:

%localappdata%\\packages\\<package_name>\\LocalState

where package_name is defined in the Package.appxmanifest under the Packaging tab in the IDE -or- as Name in the file. By default, it is a GUID value.

Answers (1)

Answers (1)

Former Member
0 Kudos

The location you described is the location I was using. I went ahead and reconverted the UL 12 db to UL 17 and now it can be connected to with my UWP app in the location you suggested.