1
任何人都不會有如何解決此錯誤消息的任何想法:錯誤CS1729:「SQLiteConnection」不包含一個構造函數1個參數(CS1729)
錯誤CS1729:「SQLiteConnection」不包含一個構造函數,需要1個參數(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;
}
}
}
}
在此先感謝您的幫助
其實我使用Xamarin Studio和我只有一個項目和解決方案 – Geeksan
我覺得你的數據庫連接字符串應該用'開始「數據源=」' – Deolus
你確定你有正確的庫,這一個,https://github.com/praeclarum/sqlite-net具有帶有一個構造函數的'SQLiteConnection',就像你的代碼一樣,名稱空間'使用命名空間SQLite',而'使用命名空間SQLite.Net'另外看起來像這個庫https ://github.com/oysteinkrog/SQLite.Net-PCL,並且需要「SQLiteConnection」(平臺實例)的附加參數。 – steve16351