I'm developing Windows phone 8.1 app. I have problem with Sqlite database. I created one, and made file. Now i want to use that file in my app, and get data from it.
I did create like this:
SQLiteConnection.CreateFile(@"C:\ProbaProbe\MySql.sqlite");
SQLiteConnection m_dbConnection;
m_dbConnection = new SQLiteConnection("Data Source=C:\ProbaProbe\MySql.sqlite;Version=3;");
m_dbConnection.Open();
string sql = "create table highscores (name varchar(20), score int)";
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
And i inserted some data with INSERT statment. That works nice. Now, when i want to use that MySql.sqlite in Windows Phone 8.1 app, i have problems. I did this way:
private async Task CopyDatabase()
{
string DB_PATH = Path.Combine(@"C:\ProbaProbe\MySql.sqlite");
bool isDatabaseExisting = false;
using (var db = new SQLite.SQLiteConnection(DB_PATH))
{
isDatabaseExisting = true;
grad q = new grad();
SQLiteCommand sqlComm = new SQLiteCommand(db);
string a = (db.Query<grad>("select * from grad")[0]).Ime;
catch
{
isDatabaseExisting = false;
}
}
Problem is: Could not open database file: C:\ProbaProbe\MySql.sqlite (CannotOpen)
I think i'm missing something... Anyone? Thx
Aucun commentaire:
Enregistrer un commentaire