2017-05-29 14 views
1

は、誰もがこのエラーメッセージを解決する方法の任意のアイデアを持っています1つの引数(CS1729)を取るコンストラクタが含まれていません:「SQLiteConnection」コンストラクタを含みませんこれは私がフォローし、それはあなたの助けを事前に:エラーCS1729:「SQLiteConnectionは」</p> <p>エラーCS1729は

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Android.App; 
using Android.Content; 
using Android.OS; 
using Android.Runtime; 
using Android.Views; 
using Android.Widget; 
using SQLite; 
using Android.Util; 

using SQLite.Net; 

namespace CPDEP1 
{ 
    public class DataBase 
    { 
     string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); 
     public bool createDataBase() 
     { 
      try 
      { 
       using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Persons.db"))); 
       { 
        connection.CreateTable<Person>(); 
        return true; 
       } 
      } 
      catch(SQLiteException ex) 
      { 
       Log.Info("SQLiteEx", ex.Message); 
       return false; 
      } 
     } 

     public bool insertIntoTablePerson(Person person) 
     { 
      try 
      { 
       using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Persons.db"))) 
       { 
        connection.Insert(person); 
        return true; 
       } 
      } 
      catch(SQLiteException ex) 
      { 
       Log.Info("SQLiteEx", ex.Message); 
       return false; 
      } 
     } 

     public List<Person> selectTablePerson() 
     { 
      try 
      { 
       using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Persons.db"))) 
       { 
        return connection.Table<Person>().ToList(); 

       } 
      } 
      catch (SQLiteException ex) 
      { 
       Log.Info("SQLiteEx", ex.Message); 
       return null; 
      } 
     } 

     public bool updateTablePerson(Person person) 
     { 
      try 
      { 
       using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Persons.db"))) 
       { 
        connection.Query<Person>("UPDATE Person set Nom=?,Prenom=?,Telephone=?,Addresse=?,Courriel=?,Cin=? Where Id=?,",person.Nom,person.Prennom,person.Telephone,person.Addresse,person.Courriel,person.Cin,person.Id); 
        return true; 
       } 
      } 
      catch (SQLiteException ex) 
      { 
       Log.Info("SQLiteEx", ex.Message); 
       return false; 
      } 
     } 

     public bool deleteTablePerson(Person person) 
     { 
      try 
      { 
       using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Persons.db"))) 
       { 
        connection.Delete(person); 
        return true; 
       } 
      } 
      catch (SQLiteException ex) 
      { 
       Log.Info("SQLiteEx", ex.Message); 
       return false; 
      } 
     } 

     public bool selectQueryTablePerson(int Id) 
     { 
      try 
      { 
       using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Persons.db"))) 
       { 
        connection.Query<Person>("SELECT * FROM Person Where Id=?", Id); 
        return true; 
       } 
      } 
      catch (SQLiteException ex) 
      { 
       Log.Info("SQLiteEx", ex.Message); 
       return false; 
      } 
     } 

    } 
} 

おかげ

+0

実は私はXamarin Studioを使用していると私は唯一のプロジェクトとソリューション – Geeksan

+0

私はあなたのデータベース接続文字列は 'で始まるべきだと思います「データソース=」' – Deolus

+2

はあなたが右のライブラリを持っているあなたは確かに、これ一つであるを持っています、https://github.com/praeclarum/sqlite-netは、あなたのコードと同じように 'using namespace SQLite'という名前空間を持っているので、一つのコンストラクタで' SQLiteConnection'を持っていますが、 'using namespace SQLite.Net'はこのライブラリのように見えます。https ://github.com/oysteinkrog/SQLite.Net-PCL、 'SQLiteConnection'(プラットフォームインスタンス)への追加パラメータが必要です。 – steve16351

答えて

4

が起こっているファイルである1つの引数(CS1729)

を取りますここに命令を送ってください:https://wolfprogrammer.com/2016/09/10/adding-a-sqlite-database-to-xamarin-forms/と同じエラーがあります。

私はここでマイクロソフトの指示(https://msdn.microsoft.com/en-us/magazine/mt736454.aspx)を参照し、フランククルーガーによって書かれた2つの非常によく似たものがあることに気付きました。下記の画像を確認し、赤色ではなく緑色でハイライト表示されているものをダウンロードしてください。

enter image description here

関連する問題