简体   繁体   English

在单独的文件夹中安装SQL Server CE数据库[Windows Mobile 6 Smart device ap]

[英]Install SQL Server CE database in separate folder [Windows Mobile 6 Smart device ap]

Install SQL Server CE database in a separate folder, and application in other folder as usual. 将SQL Server CE数据库安装在单独的文件夹中,并将应用程序照常安装在其他文件夹中。 While uninstalling application from device, database won't delete. 从设备上卸载应用程序时,数据库不会删除。 When reinstalling application on the same device, check if database exist in it [where we saved on first install], if not exist save in common folder for all smart devices [like \\Program Files\\ ], else use existing DB . 在同一设备上重新安装应用程序时,请检查其中是否存在数据库(我们在第一次安装时保存的位置),如果不存在,请保存在所有智能设备的通用文件夹中(例如\\Program Files\\ ),否则请使用现有的DB。

How can I do this using C#, Windows Mobile 6????? 如何使用C#,Windows Mobile 6做到这一点?

After reading your comment, I'd suggest something similar to the following: 阅读您的评论后,我建议类似以下内容:

  • When your application starts, have it check for the existence of your database at the path you require (or at a path specified in an INI file) 当您的应用程序启动时,让它在所需的路径(或INI文件中指定的路径)中检查数据库是否存在。

  • If the database is not found, ask the user if the default database should be used (or, just copy it over if they should have no choice). 如果找不到数据库,请询问用户是否应使用默认数据库(或者,如果他们没有其他选择,只需将其复制过来)。

When the application is removed, this database will remain. 删除应用程序后,该数据库将保留。

When your application is reinstalled, it can use the database that was left. 重新安装应用程序后,它可以使用剩余的数据库。

Example: 例:

namespace DBTest1 {

  public partial class Form1 : Form {

  const readonly string MYDATABASE = "\\Application Data\\DBTest1\\sqlce.db";

  private void Form1() {
    InitializeComponent();
    CreateIfNotThere(DBTest1.Properties.Resources.sqlcedb, MYDATABASE);
  }

  void CreateIfNotThere(object data, string filename) {
    if (String.IsNullOrEmpty(filename)) {
      filename = string.Format(@"{0}{1}{2}",
      Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
      Path.DirectorySeparatorChar, "sqlCe.db");
    }
    if (data != null) {
      byte[] array = (byte[])data;
      FileInfo file = new FileInfo(filename);
      if (!file.Exists) {
        using (FileStream fs = file.Create()) {
          fs.Write(array, 0, array.Length);
        }
      }
    }
  }
  // other code
}

If you want to get into writing custom CABWIZ steps, there is a nice write up in the How to create the inf file for a smart device cab project from command line? 如果您想编写自定义CABWIZ步骤, 如何在命令行中为智能设备cab项目创建inf文件中有一个不错的文章? thread. 线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 损坏的数据库Sql Server CE(Windows Mobile CE 5.0) - Corrupted Database Sql Server CE (Windows Mobile CE 5.0) 在具有Windows CE 5的设备上使用SQL Server CE数据库进行CRUD操作 - CRUD Opertaions with SQL Server CE database on device with Windows CE 5 无法访问数据库(SQL Server CE / Windows Mobile 6.5) - Unable to access database (SQL Server CE / Windows Mobile 6.5) 在取消Windows移动应用程序标准的同时,如何使SQL CE数据库与现有的DataOn设备保持一致? - While unsitalling the Windows mobile application , how to Keep SQL CE Database with Existing DataOn device? 插入,更新,删除不适用于Windows Mobile的SQL Server CE数据库文件 - Insert, Update, Delete are not applied on SQL Server CE database file for Windows Mobile 在Windows Mobile 5上将数据加载到Sql CE数据库的最快方法 - Fastest way to load data into Sql CE database on windows mobile 5 在Windows CE mobile(OS Windows CE)中访问SQLCE(Microsoft Sql Compact Edition)数据库的最快方法是什么? - Which is Fastest way to access SQLCE(Microsoft Sql Compact Edition) Database in Windows CE mobile(OS Windows CE))? Windows CE设备中的SQL异常 - SQL Exception in Windows CE device 使用Windows CE 6.0连接到SQL Server或MySQL数据库 - Connecting to a SQL Server or MySQL database with Windows CE 6.0 连接到SQL Server CE数据库 - Connect to SQL Server CE database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM