ClickOnceでSQL Server Compactのファイルを間違って開くとクライアントのデータが初期化される件について

| コメント(83) | トラックバック(0)
Click Onceで開発を進める中で結構ネックなのがデータファイルの取り扱いについて。

データファイルとしてsdfファイル(SQL Server Compact)を使っているわけですが 何かで開くとクライアントにまで勝手に配布されてしまい 今まで使って蓄積データが全て初期化されてしまう、ってとてもすてきな仕様です。。。

Click Once 便利なんだけど 今一歩かゆいところに手が届いてないですよね。

開かないようにする、、、って運用でカバーをしようかと思ったけど ついうっかりのクダブルクリック一発、、、で全ユーザーの蓄積データが消えてしまう、、、ってのは
恐すぎるので以下のようなアルゴリズムで回避しました。

ご参考までに。

まずデータファイルを2つに分けます。
master.sdf
data.sdf

master.sdfは開発者側で管理するデータが入っているマスタデータのみのデータベースです。
後から追加とか変更も楽々できるので楽ちんです。

そしてdata.sdfはユーザー作成のデータが入るデータベースです。
さらに起動時にmaster.sdfのマスターデータをコピーして上書きするようにしています。
これはデータベースが違うとselect文でINNER JOINとかできなくて不便だから、ということでこうしています。

このようにマスターとデータでデータベースを分けるのが第一段階。
これで マスターデータは開発社側で管理でき ユーザーデータは上書きする心配もあまりない。

ただしついうっかりユーザーデータのファイルを開く(ダブルクリックする)と上書きしてしまうのでもう一工夫が必要です。

それは初回起動時にファイルをリネームしてしまうのです。
たとえば data.sdf → user.sdfとか・・・

厳密には
「data.sdfが存在し、かつuser.sdfが存在しない場合 data.sdfをuser.sdfにリネームする」
です。

これで万が一うっかりファイルを開いてしまってもdata.sdfは上書きされますがuser.sdfは影響ないのでOKです♪

ご参考までに。






トラックバック(0)

トラックバックURL: http://blog.romaji.net/mt4/mt_cgi/mt-tb.cgi/85

コメント(83)

Thank you finding the time to speak about this, I must say i feel strongly regarding it and have learning extra for this topic. If you can, as you acquire expertise, could you mind updating your site with a lot more data? Its extremely helpful to me.

YouTube was began in 2005 by 3 PayPal employees and also, since then YouTube has expanded to one of several largest websites on the earth. Youtube Currently has over 1 billion page views per month And Over 1 Billion Distinctive Page Views 30 days.

There are several fascinating time limits here however I don’t know if I see they all center to heart. There is some validity however Let me take hold opinion until I explore it further. Good article , thanks and that we want extra! Included in FeedBurner as properly

[...] were built with a investigate my post Never Pray For Patience, and i also needed to share her comment and my response: I watched Evan Almighty, and won't [...]

What a lovely day for a 1247390! SCK was here

Great work! That is the kind of info that are meant to be shared around the web. Shame on Google for not positioning this post higher! Come on over and visit my web site . Thanks =)

Just desire to say your article is as astounding. The clarity in your post is just great and i can assume you're an expert on this subject. Fine with your permission allow me to grab your feed to keep updated with forthcoming post. Thanks a million and please keep up the rewarding work.

Very helpful post! I really enjoyed reading it. So good to read a blog that's written in good English! I will definitely be back for much more in the foreseeable future. Thank you.

I recently came across your blog and have been reading along. I want to express my admiration of your writing skill and ability to make reader to read the while thing to the end. I would like to read more of your blogs and to share my thoughts with you.

I actually do not understand just how i discovered your blog post since I have been looking for details about about the problems in Pakistan, but anyway I am very lucky that I stumbled upon your post since I had a pleasant 15 mins reading it. Keep it up! One final thing, could you endorse other important posts with regard to the very same issue?

There are certainly a number of details like that to take into consideration. That may be a great point to bring up. I offer the ideas above as normal inspiration however clearly there are questions like the one you carry up where crucial thing will probably be working in trustworthy good faith. I don?t know if best practices have emerged round issues like that, but I'm sure that your job is clearly recognized as a good game. Each girls and boys feel the impression of only a second’s pleasure, for the rest of their lives.

Extremely useful blog post. Your perspective is very lucid as well as intriquing. I'll definitely be subscribing to your RSS or Atom. I really hope you will post often on similar topics. However I'm curious what your sources of the post are? Cheers.

I simply wished to thank you so much again. I'm not certain the things I could possibly have worked on in the absence of these strategies discussed by you regarding that industry. It was before an absolute horrifying difficulty for me, however , understanding this expert fashion you processed that forced me to cry for delight. Now i'm thankful for this service and in addition sincerely hope you realize what an amazing job that you are undertaking training the others with the aid of your website. I'm certain you haven't encountered any of us.

I think it was been greatly balanced. Fair I mean.

We appreciate your posts and look forward to coming back

You certainly understand what you are speaking about. Man, this blog is just great! I cannot wait to read more of what you have got to say. I'm really joyful that I discovered this when I do mainly because I'm really getting down to become bored with the whole blogging and site-building field. You've turned me around man!

Wow, incredible blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is great, as well as the content!

Great beat ! I would like to apprentice at the same time as you amend your web site, how could i subscribe for a weblog web site? The account aided me a applicable deal. I have been tiny bit acquainted of this your broadcast provided brilliant transparent idea.

I just wanted to comment and say that I really enjoyed reading your blog post here.

hey, nice weblog and good publish

Hi! Do you know if they make any plugins to assist with Search Engine Optimization? I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good results. If you know of any please share. Many thanks!

I really like following your blog as the articles are so simple to read and follow. Excellent. Please keep up the good work. Thanks.

After research a number of of the weblog posts on your website now, and I actually like your approach of blogging. I bookmarked it to my bookmark website listing and shall be checking back soon. Pls take a look at my website as properly and let me know what you think.

I haven¡¦t checked in here for a while as I thought it was getting boring, but the last several posts are good quality so I guess I¡¦ll add you back to my everyday bloglist. You deserve it my friend :)

Rattling nice style and design and fantastic written content, nothing else we need :D.

Thanks a lot for sharing

I've lately began a weblog, the information you present on this website has helped me tremendously. Thank you for all your time & work.

hey all, I was just checking out this blog and I actually admire the basis of the article, and have nothing to do, so if anybody wish to to have an engrossing convo about it, please contact me on AIM, my title is heather smith

I’m impressed, I must say. Actually not often do I encounter a blog that’s each educative and entertaining, and let me tell you, you've hit the nail on the head. Your concept is outstanding; the difficulty is one thing that not sufficient persons are speaking intelligently about. I'm very glad that I stumbled throughout this in my search for one thing regarding this.

Amazing blog! Is your theme custom made or did you download it from somewhere? A design like yours with a few simple adjustements would really make my blog jump out. Please let me know where you got your theme. With thanks

This one is an inspiration personally to uncover out far more associated to this subject. I must confess your information prolonged my sentiments in addition to I'm going to right now take your feed to remain up to date on each coming weblog posts you may probably create. You're worthy of thanks for a job perfectly performed!

I do know this isn't precisely on subject, but i've a web page utilizing the identical program as properly and i get troubles with my feedback displaying. is there a setting i'm lacking? it's potential you might assist me out? thanx.

Excellent post , I'm going to spend much more time researching this topic

This blog doesn't render correctly on my iphone4 - you might want to try and fix that

Im not that much of a reader to be honest but your sites pretty good, keep it up as I will bookmark ready for my next read

I really like following your blog as the articles are so simple to read and follow. Excellent. Please keep up the good work. Thanks.

Hi, I think your blog might be having browser compatibility issues. When I look at your website in Opera, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, very good blog!

I dugg some of you post as I thought they were invaluable very beneficial.

Awesome job over again! Thanks a lot=)

I’d must test with you here. Which isn't one thing I usually do! I take pleasure in studying a put up that may make folks think. Also, thanks for allowing me to remark!

I will bookmark your blog because your posts are very informative.

so interesting a topic.

I always was interested in this topic and stock still am, thanks for posting.

I simply wanted to say thanks once again. I am not sure what I could possibly have created in the absence of those ideas shown by you on that industry. It truly was a depressing crisis in my view, however , witnessing a specialized approach you dealt with the issue forced me to jump for fulfillment. I am just grateful for your guidance and as well , believe you know what a powerful job you happen to be providing teaching some other people by way of a blog. Most probably you haven't come across all of us.

he blog was how do i say it… relevant, finally something that helped me. Thanks

I have a high standard I abide by for choosing reading material, especially online. Your article met my standards then flew right by them. You¡¯ve written a great article with loads of great informational content.

This web site does not show up appropriately on my iphone - you may want to try and fix that

Just killing some in between class time on Digg and I found your article . Not normally what I desire to read about, nevertheless it was completely value my time. Thanks.

I've just lately started a weblog, the knowledge you provide on this web site has helped me tremendously. Thank you for all your time & work.

I never throught I would spend so much time of the d--m internet. If I had found your blog earlier, it would have saved me some time in my research.

The new Zune browser is surprisingly good, but not as good as the iPod's. It works well, but isn't as fast as Safari, and has a clunkier interface. If you occasionally plan on using the web browser that's not an issue, but if you're planning to browse the web alot from your PMP then the iPod's larger screen and better browser may be important.

Hello! I am so grateful I stumbled upon your internet site. I seriously discovered you by error, whilst I was searching on Stumbleupon for something else. Anyway, I am here now and would just decide to thank you for a fantastic posting along with a over-all useful blog site (I additionally love the theme / design). I don't have time to browse it all at the moment but I've book marked it and also added in your RSS feeds, so when I have time I will be returning to read more. Please do keep up the awesome job.

Nice! Just wanted to respond. I thoroughly loved your post. Keep up the great work.

Great information. Thanks very much.

A bore is someone who persists in holding his own views after we have enlightened him with ours.

Hmmm interesting stuff

Thank you pertaining to giving this exceptional content on your web-site. I discovered it on google. I may possibly check back once again in the event you publish extra aricles.

Be alert to give service. What counts a great deal in life is what we do for others.

I found your weblog site on google and check a couple of of your early posts. Proceed to keep up the excellent operate. I simply extra up your RSS feed to my MSN News Reader. In search of ahead to studying extra from you later on!…

Thank you a lot for providing individuals with an exceptionally spectacular chance to check tips from this website. It is usually very awesome and also full of a great time for me personally and my office acquaintances to search your web site a minimum of thrice a week to read the fresh guidance you will have. And definitely, I'm so at all times satisfied with your excellent solutions served by you. Some two facts in this posting are unquestionably the most effective we have ever had.

I do love the way you have framed this problem plus it really does supply me a lot of fodder for consideration. On the other hand, from everything that I have seen, I basically hope when other remarks pile on that people keep on issue and not start on a soap box regarding some other news of the day. Anyway, thank you for this excellent point and while I can not go along with this in totality, I value the point of view.

Hmmm interesting stuff

A very very interesting article! I'll try to track that continues here! Thank you.

"Under consideration": We've never heard of it.

Now you have your new web page and you're eager to begin making some sales! However, how can you make gross sales if you happen to would not have high volumes of visitors to your website?

hey all, I used to be just checking out this weblog and I actually admire the idea of the article, and don't have anything to do, so if anybody would like to to have an engrossing convo about it, please contact me on AIM, my title is heather smith

An excellent article many thanks

Cat: A lapwarmer with a built-in buzzer. -- Anonymous

When I originally commented I clicked the notify myself when new remarks are added and now whenever a remark is added I recieve many emails with the exact same opinion. Will there be anyway you can remove folks by that service? Thank you so much!

I cant access the RSS feed. I am getting a 500 internal server error :(

Hello! I simply want to give an enormous thumbs up for the good data you might have here on this post. I will be coming back to your blog for extra soon.

Sorry for the huge review, but I'm really loving the new Zune, and hope this, as well as the excellent reviews some other people have written, will help you decide if it's the right choice for you.

As I site possessor I believe the content matter here is rattling great , appreciate it for your hard work. You should keep it up forever! Best of luck.

You made some good points there. I did a search on the topic and found most people will agree with your blog.

Hi, I can’t understand how to add your site in my rss reader. Can you Help me, please

Hi! Someone in my Myspace group shared this website with us so I came to look it over. I'm definitely enjoying the information. I'm book-marking and will be tweeting this to my followers! Exceptional blog and great design.

With the qualities of cleanliness, affection, patience, dignity, and courage that cats have, how many of us, I ask you, would be capable of becoming cats? -- Fernand Mery

It¡¦s actually a cool and useful piece of information. I am glad that you simply shared this useful information with us. Please keep us informed like this. Thank you for sharing.

The following time I read a blog, I hope that it doesnt disappoint me as a lot as this one. I imply, I know it was my option to learn, however I really thought youd have something attention-grabbing to say. All I hear is a bunch of whining about something that you could fix for those who werent too busy looking for attention.

Never put off until tomorrow what you can put off indefinitely.

Thank you for another excellent write-up. Exactly where else can anyone get that form of data in composed in such a apparent way. I've a demonstration next week, and I was looking for precisely the advice you've got just provided me. Thank you.

You can't own a cat. The best you can do is be partners. -- Sir Harry Swanson

I'm right 90% of the time, so why worry about the other 3%?

コメントする

2011年9月

        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30