r_khan
سه شنبه 08 بهمن 1392, 08:36 صبح
با سلام دیتابیس Sqlite رو با دستور زیر می سازم
ولی وقتی برنامه رو دوباره نصب میکنم . دیتابیس از بین میره و دوباره میسازه می خوام برای اولین بار که نصب کردم دیتابیس ساخته شه برای نصب های بعدی دیتابیس تغییر نکنه
کد
class SqlCon
{
private static string db_file = "sqlite1";
private static SqliteConnection GetConnection()
{
var dbPath = Path.Combine(System.Environment.GetFolderPath(Syst em.Environment.SpecialFolder.Personal), db_file);
bool exists = File.Exists(dbPath);
if (!exists)
{
SqliteConnection.CreateFile(dbPath);
}
var conn = new SqliteConnection("Data Source=" + dbPath);
if (!exists)
{
CreateDatabase(conn);
}
return conn;
}
}
ولی وقتی برنامه رو دوباره نصب میکنم . دیتابیس از بین میره و دوباره میسازه می خوام برای اولین بار که نصب کردم دیتابیس ساخته شه برای نصب های بعدی دیتابیس تغییر نکنه
کد
class SqlCon
{
private static string db_file = "sqlite1";
private static SqliteConnection GetConnection()
{
var dbPath = Path.Combine(System.Environment.GetFolderPath(Syst em.Environment.SpecialFolder.Personal), db_file);
bool exists = File.Exists(dbPath);
if (!exists)
{
SqliteConnection.CreateFile(dbPath);
}
var conn = new SqliteConnection("Data Source=" + dbPath);
if (!exists)
{
CreateDatabase(conn);
}
return conn;
}
}