Example #1
0
 private async Task<string> createTable(string path)
 {
     // create a connection string for the database
     var connectionString = string.Format("Data Source={0};Version=3;", path);
     try
     {
         using (var conn = new SqliteConnection((connectionString)))
         {
             await conn.OpenAsync();
             using (var command = conn.CreateCommand())
             {
                 command.CommandText = "CREATE TABLE People (PersonID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName ntext, LastName ntext)";
                 command.CommandType = CommandType.Text;
                 await command.ExecuteNonQueryAsync();
                 return "Database table created successfully";
             }
         }
     }
     catch (Exception ex)
     {
         var reason = string.Format("Failed to insert into the database - reason = {0}", ex.Message);
         return reason;
     }
 }