设为首页 收藏本站
查看: 565|回复: 0

Windows Phone 7.5

[复制链接]

尚未签到

发表于 2015-5-13 07:43:57 | 显示全部楼层 |阅读模式
http://www.codeproject.com/KB/windows-phone-7/ExtractingSQLCEDB.aspx
Introduction
  By now, most of you have heard that Windows Phone 7 – Mango release will support Local Databases (SQL CE) using Linq to SQL. But what you probably haven’t heard much about is how to extract the .SDF that is created in isolated storage to your local computer and view the contents. I find this extremely important for debugging application and making sure my database is setup exactly like I want it. So, that is what we are going to do today.
Getting Started with a Sample Application
DSC0000.png   For this tutorial, we will need a sample application that uses a local database. If you are already using a local database (SQL CE) in your Mango application, then you can skip this section, otherwise go ahead and download the “Local Database Sample” from MSDN.
  Below is an excerpt from the MSDN Page:
  On Windows Phone OS 7.1, you can use LINQ to SQL to store relational data in a local database that resides in your application’s isolated storage container. This sample is a to-do list application that uses a multi-table local database. Items that appear in the list are added, updated, and deleted from a local database, where they will persist between application launches. For step-by-step information about how to develop this application, see How to: Create a Local Database Application with MVVM for Windows Phone.
  Download samples: C# | VB
The Database Structure
  We see code that defines our database name in App.xaml.cs. It is simply called ToDo.sdf:

DSC0001.gif Collapse | Copy Code// Specify the local database connection string.
string DBConnectionString = "Data Source=isostore:/ToDo.sdf";  And code that creates a table and defines the columns:

Collapse | Copy Code[Table]
public class ToDoItem
{
[Column( IsPrimaryKey = true )]
public int ToDoItemId { get; set; }
[Column]
public string ItemName { get; set; }
[Column]
public bool IsComplete { get; set; }
[Column]
public int _categoryId { get; set; }
[Column]
private Binary _version { get; set; }
}  Please note that I removed all code relating to MVVM to simplify this example. If you wish to see the code, then please review Model –> ToDoDataContext.cs. This sample also has another Table called ToDoCategory that was not included in this tutorial.
  Now that we have reviewed what the database looks like, let's see what it takes to extract the .SDF file from isolated storage to our local pc.
  Get the required tools if you haven’t already.

  • Download the Windows Phone SDK 7.1 RC and install it if you already have not.
  • Grab the Silverlight Toolkit for Mango.
  • Download the “Local Database Sample” from MSDN if you want to use this example.
  Go ahead and run the application and enter some data. My screen looks like this:
DSC0002.png   This should be enough data for us to work with.
  Leave the emulator running and navigate to the Properties –> WMAppManifest.xml file. Open up notepad and copy/paste the ProductId into it.
DSC0003.png   Go ahead and navigate over to your “C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Tools\IsolatedStorageExplorerTool” and run the following command:

Collapse | Copy CodeISETool.exe ts xd 8c0be8e6-11c1-44d8-be92-57f06cf52240
"C:\Users\MichaelCrump\Desktop\IsoStore"  You should:

  • Replace the GUID with your own.
  • Give it a proper file location to output the file.
  Here is what my command window looks like:
DSC0004.png   Note: I kept getting this message that is was already being used but it actually built the file anyways.
  Navigate over to the directory that you specified earlier and you will see your .SDF file from IsolatedStorage. Pretty cool huh?
DSC0005.png   Go ahead and switch over to Server Explorer inside of Visual Studio 2010 and let’s add that SDF to the project. Right click on Data Connection, then select “Add Connection”.
DSC0006.png   Make sure you select the Data Source to be: SQL Server Compact 3.5 and then hit Browser and select the .SDF file just created.
  Please note that I could not get SQL Server Compact 4.0 Data Source to work with this sample.
DSC0007.png   Hit OK and you should see your database that you crated in Mango (that was living in Isolated Storage) inside of Visual Studio.
DSC0008.png   Now if you right click on a table, then you can “Show Table Data” kind of like we are used to with normal SQL Server DBs.
DSC0009.png   Exactly the data shown in the first screen shot!
DSC00010.png   One thing to note here is that this is simply a way to VIEW what was in isolated storage. You may want to read up on modifying IsolatedStorage using the same tool if that is your intention.
Conclusion
  Of course, the IsolatedStorageExplorerTool is for more than SQL CE DBs. Basically anything in Isolated Storage in your app it can extract. It also works with devices as well as allows you to add files to IsolatedStorage from your local PC. With every release of Windows Phone, we are seeing the tools become better and better. I am very excited to see what is coming in future releases. I hope this helps someone out there troubleshooting a bug with their Windows Phone 7 application. Until next time, thanks again for reading.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-66376-1-1.html 上篇帖子: Windows Phone 7 Bitmap编码 下篇帖子: [分享]Windows Phone 7 Made Simple
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表