如何将 SqlCe 数据库部署到 Windows 手机的isolatedStorage [英] How to deploy SqlCe Database into isolatedStorage for windows phone

查看:34
本文介绍了如何将 SqlCe 数据库部署到 Windows 手机的isolatedStorage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比如说,我想使用一个现有的 SqlCe 数据库,其中包含数据.我不确定哪种方法最好.

1) 这里是为 Windows 手机创建 SqlCe 数据库的正常方法

<前>使用 (CountryDataContext context = new CountryDataContext(ConnectionString)){如果 (!context.DatabaseExists()){//如果数据库不存在则创建context.CreateDatabase();}}

但是这个数据库里面有数据,所以我不想创建它.我想部署或存储在isolatedStorage中.

我该怎么做??我想使用数据库中已有的数据.

谢谢

解决方案

您可以将数据库文件作为内容包含在您的应用程序项目中,然后它将在构建时放入您的 XAP 并复制到您的应用程序安装目录中电话.

你会修改这个数据库吗?

  • 如果没有:您可以直接从安装目录访问数据库,未来的更新将自动获取任何新版本的数据库(只要您记得将它们添加到 XAP).

  • 如果您确实修改了它:那么在第一次安装时,您需要在使用之前将数据库复制到独立存储.如果您在未来的更新中更新数据库方案,您将需要注意.

    say, I want to use an existing SqlCe Database which HAS data in it. I am not sure which is the best way to do it.

    1) here is the normal way to create a SqlCe Database for Windows phone

    using (CountryDataContext context = new CountryDataContext(ConnectionString))    
        {         
            if (!context.DatabaseExists())        
            {            
    
            // create database if it does not exist            
                context.CreateDatabase();        
            }    
        }   
    
    

    But this Database has data in it , so I dont want to create it. I want to deploy it or store in in isolatedStorage.

    How should I do it ?? I want to use the data already in the database.

    Thanks

    解决方案

    You can include the database file as Content in your application project and it will then be put in your XAP at build time and copied to your application install directory on the phone.

    Will you modify this database at all?

  • If not: you can access the database directly from the install directory and future updates will get any new version of the database automatically (as long as you remember to add them to the XAP).

  • If you do modify it: then on first install you will need to copy the database to isolated storage before you use it. You will need to watch out if you update the database scheme with a future update.

    这篇关于如何将 SqlCe 数据库部署到 Windows 手机的isolatedStorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆