I am working with Sqlite db in uwp, I am able to create db successfully without any issue in Local folder of my app.
But when I try to create in other places, I get error as
"SQLite.Net.SQLiteException: 'Could not open database file: E:\Users\PC3\Pictures\Abcd\MyDbFolder\mydb.sqlite (CannotOpen)"
I got the path string using StorageFolder.Path which I got through Folder picker, then I added it to FutureAccessList too. Though not works. Since the New db connection method expects the path, I am struggling for a long time, to use path in the Constructor.
//DbPathFromFAList = foldername.path (got from FutureAccess List) + mydbName.sqlite;
sqliteConn = new SQLiteConnection(new SQLitePlatformWinRT(), DbPathFromFAList);
As Rob said in this thread,
SQLite uses paths not streams and bypasses the file broker. It's database has to be in application data so the app has direct read/write permissions or install dir for read only.
You could not pass the path string parameter such as D: E: to SQLiteConnection method, even though you have used FilePicker to get the full file's permission.
In general, we use LocalFolder to store db file that could access directly.
DbFilePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Sqlite.db");
sqliteConn = new SQLiteConnection(new SQLitePlatformWinRT(), DbFilePath);
And the specified path is located at:
C:\Users[Your User Name]\AppData\Local\Packages[Your Package Name]\LocalState
You can not set it to the D or E disk. If you have used external database, please copy the db file to the local folder. for more please refer this document.
Related
I am creating an android app using xamarin shared project.
I have created a database using SQLite to store user's username, password, email, and other information.
This is my code to create SQLite code but it doesn't matter bc I know it works. User can signup, login, go to home page where they can see list of user's information. This means I am able to select and insert data from UserDatabase.db3 database.
var fileName = "UserDatabase.db3";
var documentPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var path = Path.Combine(documentPath, fileName);
var platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
var connection = new SQLiteConnection(platform, path);
Issue is that I can't see or find UserDatabase.db3.
What I can tell is SQLite database is store on user's phone and .db3 file is hidding under location
/Data/Data/com.companyname.AppName/File/
on google it said that some how I need to root my phone(What ever that means). But shouldn't there a way to see this find without rooting? maybe a desktop software that can access .db3 without rooting junk?
I also tried the following but db3 file was no where to find
Visual Studio > View > Tool Windows > Device File Explorer
If There is not other way to access my db3 file, than maybe there is a work around?
i guess I can just create a test page in my app where it display tables by using 'select' statment? Is this a good approch?
if you want to see your database,click on device file explore in Android studio->Click On Data->Click On Data->Click On "Your Package Name"->Click On Database->Here You Can See Your Database
I have a secure Azure Blob set up as follows:
ContainerName > SubDirectory/FileName
E.g., /Photos/0000001/pic.png
Some of these sub directories contain thousands of files that all need to be rendered to a web page. Since the Blob is secured, I'm currently getting an access token for each individual file using GetSharedAccessSignature(...).
Is there a way I could instead get a single token that would grant access to all files within the sub directory ("/0000001/"), or is what I'm currently doing considered best practice?
You can only get Shared Access Signature for a blob container or for a single blob, but you are NOT able to get Shared Access Signature for a blob virtual directory, since directory isn't a real concept in Azure Blob Storage.
Not sure how I missed this, but here's how to get an access token for a directory:
var blob = storageService.Context.Container.ListBlobs().FirstOrDefault();
var policy =
new SharedAccessBlobPolicy()
{
Permissions = SharedAccessBlobPermissions.Read,
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(10)
};
blob.Container.GetSharedAccessSignature(policy);
Newer versions support directory level access if hierarchical namespace is activated i.e. data lake. See MS Docs: Service SAS support for directory scoped access.
I have problem with connecting to DBF files on remote location using OleDb.
When I use local path everything works fine.
My connection string:
string path_dbf = #"\\server\directory";
OleDbConnection conn = new OleDbConnection(#"Provider=VFPOLEDB.1;Data Source="+path_dbf+";");
I've tried to use OleDb and Odbc, but both have failed when I use remote location. I also try to use mapped directory under the OS, but it doesn't work.
I get error:
Error: Sys.Net.WebServiceFailedException: The server method 'MethodName' failed with the following error: System.Data.OleDb.OleDbException-- Invalid path or file name.
I also try to use Odbc DSN like this:
OdbcConnection conn = new OdbcConnection("dsn=MyDsnName;");
but it doesn't work. MyDsnName is Free Table directory type and it points to my mapped remote directory.
I don't have idea of any possible solution.
So I want to ask if there is a maybe some additional connection string options to do that or I do something wrong.
Thanks.
It is probably a permissions issue when running as a web app. The user which may be something like "USR_MACHINE" may not have proper permissions to the other server location and thus failing.
To confirm this, try changing your website service to "Run As" some other user that DOES have permissions, such as yourself... if STILL not a problem, then try running .net as the ADMINISTRATOR FOR CONFIRMATION PURPOSES ONLY, then revert back to the USR_MACHINE account.
Once you have confirmed, then you might want to create a somewhat restricted user so they only have access to the folder and features you want them to for security purposes.
I need to pick an underlying method of saving data collected in the field (offline and remote locations). I want to use the HTML5 Database with SQLite but I can I pick the location? So far, I haven't been able to accomplish that. Here is some sample code I was using:
var dbName = "";
var Dir = blackberry.io.dir;
var path = Dir.appDirs.shared.documents.path;
dbName = path + "/" + "databasetest.db";
var db = openDatabase(dbName, '1.0', 'Test', 50 * 1024);
I used an "alert()" to see the file was "supposedly" created, but when I opened the folder in Explorer I cannot find it. Not really sure why and hense my question.
My application is for data entry, without getting into specifics, user may end up collecting a lot or little data. But I want some way of downloading the SQLite database?
Is this the intention of the SQLite database, or will I have to use another solution?
Thanks!
Chris
The Web SQL Database specification was designed for browsers where it would not have been appropriate to allow web pages to access arbitrary file paths.
The intended way to download data is to upload it to a web server in the cloud.
If you want to know the file name of your database, try executing the PRAGMA database_list. (Whether your app can access that path is a different question.)
Invalid path name. Path does not contains a proper root list. See FileSystemRegistry class for details.
I want to create a DB in appication folder.I created a folder in res folder. I tried to access this folder(db) as:
URI dbURI = URI.create("file:///res/db/MyDB.db");
Database database = DatabaseFactory.create(dbURI);
URI dbURI = URI.create("file:///db/MyDB.db");
Database database = DatabaseFactory.create(dbURI);
URI dbURI = URI.create("/res/db/MyDB.db");
Database database = DatabaseFactory.create(dbURI);
URI dbURI = URI.create("/db/MyDB.db");
Database database = DatabaseFactory.create(dbURI);
I also tried to create SDCard directory on simulator and give this path. None of them worked for me. Please help me.
Your res/ directory is for things you want to add to the project, but as far as I'm aware you can't create files inside of it after you've deployed. Regardless, what you should probably do is either create it in a folder on the user's device (probably file:///store/), or on the SD card (file:///SDCard/).