{"id":196,"date":"2009-05-28T12:11:46","date_gmt":"2009-05-28T03:11:46","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=196"},"modified":"2009-05-28T12:33:18","modified_gmt":"2009-05-28T03:33:18","slug":"pda-%e3%81%a7-sql-server-compact-35-%e3%82%92%e4%bd%bf%e3%81%86","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/196","title":{"rendered":"PDA \u3067 SQL Server Compact 3.5 \u3092\u4f7f\u3046"},"content":{"rendered":"<p>PDA\u81ea\u4f53\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4e57\u305b\u308b\u7c21\u5358\u306a\u691c\u8a3c\u3092\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u6975\u5c0fSQL Server Compact\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30fb\u30a2\u30d7\u30ea\u3092\u304a\u624b\u8efd\u4f5c\u6210<br \/>\n<a href=\"http:\/\/www.atmarkit.co.jp\/fdotnet\/joyofprogram\/20080701devssce\/devssce_01.html\">http:\/\/www.atmarkit.co.jp\/fdotnet\/joyofprogram\/20080701devssce\/devssce_01.html<\/a><\/p>\n<p>\u5229\u7528\u65b9\u6cd5\u3068\u3057\u3066\u306f\u3001<\/p>\n<p>&#8211; \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u3042\u3089\u304b\u3058\u3081\u4f5c\u6210\u3057\u3066\u304a\u3044\u3066 SD \u30e1\u30e2\u30ea\u306b\u7f6e\u304f\u3002<br \/>\n&#8211; \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089PDA\u4e0a\u306eDB(SDF\u30d5\u30a1\u30a4\u30eb)\u3092\u53c2\u7167\u3059\u308b\u3002<br \/>\n&#8211; \u7121\u7ddaLAN\u306a\u3069\u304c\u4f7f\u3048\u308b\u3068\u304d\u306f\u3001\u9069\u5b9cDB\u3092\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3059\u308b\u3002<\/p>\n<p>\u3063\u3066\u306a\u611f\u3058\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\nDB\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306b\u95a2\u3057\u3066\u306f\u3001\u5730\u56f3\u3084\u96fb\u8a71\u5e33\u307f\u305f\u3044\u306a\u56fa\u5b9a\u30c7\u30fc\u30bf\u306f\u4e38\u3054\u3068PC\u304b\u3089\u30b3\u30d4\u30fc\u3057\u3066\u3082OK\u3002<br \/>\nPDA\u3067\u7de8\u96c6\u3057\u305f\u30e1\u30e2\u66f8\u304d\u306a\u3093\u304b\u306f\u3001\u9069\u5b9cPC\u3067\u30de\u30fc\u30b8\u3057\u3066\u3084\u3063\u3066\uff08PDA\u3067\u30de\u30fc\u30b8\u3067\u3082OK\uff09\u3001DB\u306b\u66f8\u304d\u623b\u3059\u3068\u3044\u3046\u65b9\u6cd5\u304c\u3088\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>ActiveSync \u306b\u95a2\u3057\u3066\u306f\u4fdd\u7559\u3002\u4e2d\u53e4\u3067PDA\u3092\u624b\u306b\u5165\u308c\u308b\u3068\u5927\u62b5\u30af\u30ec\u30fc\u30c9\u30eb\u304c\u3042\u308a\u307e\u305b\u3093\uff08\u30b9\u30bf\u30e9\u30a4\u30b9\u3082\u7121\u3044\u3053\u3068\u304c\u591a\u3044\uff09\u3002\u306a\u306e\u3067\u3001PDA\u3068PC\u3068\u306e\u30c7\u30fc\u30bf\u306e\u3084\u308a\u53d6\u308a\u306f\u3001<\/p>\n<p>&#8211; SD\u30e1\u30e2\u30ea\u7d4c\u7531<br \/>\n&#8211; CF\u30ab\u30fc\u30c9\u7d4c\u7531<br \/>\n&#8211; \u7121\u7ddaLAN<br \/>\n&#8211; Bluetooth<\/p>\n<p>\u306b\u9650\u3089\u308c\u307e\u3059\u3002\u8d64\u5916\u7dda\u3067\u3082\u3044\u3044\u3051\u3069\u3001\u6628\u4eca\u306e\u30ce\u30fc\u30c8PC\u306b\u306f\u8d64\u5916\u7dda\u304c\u4e57\u3063\u3066\u3044\u306a\u3044\u6a5f\u7a2e\u304c\u591a\u3044\u306e\u3067\u30d1\u30b9\u3002<br \/>\n\u52ff\u8ad6\u3001PDA\u81ea\u4f53\u306b\u7121\u7ddaLAN\/Bluetooth\u304c\u4e57\u3063\u3066\u3044\u306a\u3044\u5834\u5408\u3082\u3042\u308b\u308f\u3051\u3067\u3059\u304c\u3001\u305d\u308c\u306f\u305d\u308c\u3067\uff08\u4eca\u6642\u306e\uff09\u4f7f\u3044\u52dd\u624b\u3092\u8003\u3048\u3066\u73fe\u5728\u4fdd\u7559\u3002<\/p>\n<p>\u3055\u3066\u3001\u672c\u984c\u3067\u3059\u304c\u3001PDA\u3067SQL Server Compact 3.5 \u3092\u4f7f\u3046\u3068\u304d\u306f\u3001System.Data.SqlServerCe \u540d\u524d\u7a7a\u9593\u3092\u4f7f\u3044\u307e\u3059\u3002\u3053\u306e\u4e2d\u306b SqlClient \u3068\u540c\u7b49\u306e\u30af\u30e9\u30b9\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u53c2\u7167\u8a2d\u5b9a\u306b\u300cSystem.Data.SqlServerCe.dll\u300d\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Data;\r\nusing System.Drawing;\r\nusing System.Text;\r\nusing System.Windows.Forms;\r\nusing System.Data.SqlServerCe;\r\n\r\nnamespace DBAccess01\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n\r\n        private SqlCeConnection m_cn;\r\n        private string m_ConnectString = &quot;&quot;;\r\n        \r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n            \/\/DB\u306e\u4f4d\u7f6e\r\n            System.Reflection.Module&#x5B;] modules =\r\n                System.Reflection.Assembly.GetExecutingAssembly().GetModules();\r\n            string path = System.IO.Path.GetDirectoryName(modules&#x5B;0].FullyQualifiedName);\r\n            m_ConnectString = &quot;Data Source=&quot; +\r\n                path + &quot;\\\\AppDatabase1.sdf&quot;;\r\n        }\r\n\r\n        \/\/ \u63a5\u7d9a\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n\r\n            \/\/MessageBox.Show(m_ConnectString);\r\n\r\n            m_cn = new SqlCeConnection(m_ConnectString);\r\n            try\r\n            {\r\n                m_cn.Open();\r\n                MessageBox.Show(&quot;\u63a5\u7d9a\u5b8c\u4e86&quot;);\r\n            }\r\n            catch ( SqlCeException ex )\r\n            {\r\n                MessageBox.Show(ex.Message);\r\n            }\r\n        }\r\n        \/\/ \u5207\u65ad\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            if (m_cn != null)\r\n            {\r\n                m_cn.Close();\r\n                MessageBox.Show(&quot;\u5207\u65ad&quot;);\r\n                m_cn = null;\r\n            }\r\n        }\r\n\r\n        \/\/ \u691c\u7d22\r\n        private void button3_Click(object sender, EventArgs e)\r\n        {\r\n            SqlCeConnection cn = new SqlCeConnection(m_ConnectString);\r\n            SqlCeDataAdapter da = new SqlCeDataAdapter(\r\n                &quot;SELECT * FROM t_product&quot;, cn);\r\n            DataTable dt = new DataTable();\r\n            da.Fill(dt);\r\n            this.dataGrid1.DataSource = dt;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>\u63a5\u7d9a\u6587\u5b57\u5217\u306f<\/p>\n<p>Data Source=SDF\u30d5\u30a1\u30a4\u30eb\u540d<\/p>\n<p>\u306e\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002\u4e0a\u306e\u30bd\u30fc\u30b9\u3067\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\uff08EXE\u30d5\u30a1\u30a4\u30eb\uff09\u3068\u540c\u3058\u5834\u6240\u306b\u3042\u308bSDF\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3042\u3068\u3001PDA \u306b\u306f .NET Compact Framework 3.5 \u3068 Microsoft SQL Server Compact Edition v3.5 \u306a\u308b\u3082\u306e\u304c\u5fc5\u8981\u3067\u3059\u3002.NET Compact Framework 3.5 \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306b\u95a2\u3057\u3066\u306f\u3001<a href=\"http:\/\/www.moonmile.net\/blog\/?p=82\">http:\/\/www.moonmile.net\/blog\/?p=82<\/a> \u3092\u53c2\u7167\u3057\u3066\u8cb0\u3046\u3053\u3068\u306b\u3057\u3066\u3001SQL Server Compact \u306e\u65b9\u306f Visual Studio 2008 \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u3068\u304d\u306b\u306f\u3001<\/p>\n<p>C:\\Program Files\\Microsoft SQL Server Compact Edition\\v3.5\\Devices\\<\/p>\n<p>\u306b\u3042\u308a\u307e\u3059\u3002<br \/>\n# 2005 \u3068\u304b Express Edition \u306e\u5834\u5408\u306f\u3088\u304f\u308f\u304b\u3089\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u5148\u306e\u300c\u6975\u5c0fSQL Server Compact\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30fb\u30a2\u30d7\u30ea\u3092\u304a\u624b\u8efd\u4f5c\u6210\u300d\u306e\u8a18\u4e8b\u3092\u773a\u3081\u308b\u3068\u7d50\u69cb\u5927\u5909\u305d\u3046\u306a\u306e\u3067\u3001\u3053\u308c\u306f\u307e\u305f\u5225\u306e\u6a5f\u4f1a\u306b\u3002<\/p>\n<p>\u3053\u306e\u4e2d\u306b\u3042\u308bCAB\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\u3053\u308c\u306fPDA\u306b\u3088\u3063\u3066CAB\u304c\u6c7a\u307e\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>&#8211; sqlce.ppc.wce4.armv4.CAB<\/p>\n<p>\u3092PDA\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002\u305d\u3057\u3066\u30ea\u30bb\u30c3\u30c8\uff08\u30ea\u30bb\u30c3\u30c8\u3057\u306a\u3044\u3068\u99c4\u76ee\u3089\u3057\u3044\uff09\u3002<\/p>\n<p>SD\u30e1\u30e2\u30ea\u306b\u30b5\u30f3\u30d7\u30eb\u3067\u4f5c\u6210\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u5165\u308c\u307e\u3059\u3002<\/p>\n<p>&#8211; DBAccess01.exe: \u5b9f\u884c\u30d5\u30a1\u30a4\u30eb<br \/>\n&#8211; AppDatabase1.sdf: DB\u306e\u30d5\u30a1\u30a4\u30eb<br \/>\n&#8211; System.Data.SqlServerCe.dll: CE\u7528DLL<\/p>\n<p>\u3067\u3001\u5b9f\u884c\u3057\u305f\u3068\u304d\u306e\u7d50\u679c\u304c\u3053\u3061\u3089\u2193<\/p>\n<p>SD\u30e1\u30e2\u30ea\u304b\u3089\u76f4\u63a5\u8d77\u52d5<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2009\/05\/09-05-28_11-20.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-202\" title=\"09-05-28_11-20\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2009\/05\/09-05-28_11-20-225x300.jpg\" alt=\"09-05-28_11-20\" width=\"225\" height=\"300\" srcset=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2009\/05\/09-05-28_11-20-225x300.jpg 225w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2009\/05\/09-05-28_11-20.jpg 768w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><\/p>\n<p>DataGridView \u306b\u8868\u793a\u3057\u3066\u3044\u308b\u3068\u3053\u308d\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2009\/05\/09-05-28_11-201.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-203\" title=\"09-05-28_11-201\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2009\/05\/09-05-28_11-201-225x300.jpg\" alt=\"09-05-28_11-201\" width=\"225\" height=\"300\" srcset=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2009\/05\/09-05-28_11-201-225x300.jpg 225w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2009\/05\/09-05-28_11-201.jpg 768w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><\/p>\n<p>\u30e1\u30e2\u30ea\u306e\u4f7f\u7528\u7387\u304c\u6c17\u306b\u306a\u308b\u3068\u3053\u308d\u3067\u3059\u304c\u3001\u4eca\u306f\u6e2c\u5b9a\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u7121\u8996\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u6c17\u306b\u306a\u3063\u305f\u306e\u304c\u3001<\/p>\n<p>&#8211; varchar, char \u306f\u7121\u304f\u3001nvarchar, nchar \u3067\u7f6e\u304d\u63db\u3048\u308b\u5fc5\u8981\u3042\u308a\u3002<br \/>\n&#8211; \u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306f\u4f5c\u308c\u306a\u3044\u3002<br \/>\n&#8211; \u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u304c\u3042\u308b\u3002<br \/>\n&#8211; \u65e5\u4ed8\u578b\u304cdatetime\u3057\u304b\u306a\u3044\u3002date\u578b\u3084time\u578b\u304c\u306a\u3044\u3002<\/p>\n<p>\u306a\u3069\u7d30\u304b\u306a\u9055\u3044\u304c\u3042\u308a\u307e\u3059\u3002\u500b\u4eba\u7684\u306b\u306f nvarchar \u306b\u5909\u63db\u3059\u308b\u306e\u304c\u9762\u5012\u306a\u306e\u3068\u3001\u30b9\u30c8\u30a2\u30c9\u304c\u7121\u3044\u3063\u3066\u3068\u3053\u308d\u3067\u3059\u304b\u306d\u3002\u30b7\u30b9\u30c6\u30e0\u95a2\u6570\u306f\u3069\u3053\u307e\u3067\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u306e\u304b\u5206\u304b\u308a\u307e\u305b\u3093\u304c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PDA\u81ea\u4f53\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4e57\u305b\u308b\u7c21\u5358\u306a\u691c\u8a3c\u3092\u3057\u3066\u307f\u307e\u3057\u305f\u3002 \u6975\u5c0fSQL Server Compact\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30fb\u30a2\u30d7\u30ea\u3092\u304a\u624b\u8efd\u4f5c\u6210 http:\/\/www.atmarkit.co.jp\/fdotnet\/joyofpro &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/196\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-196","post","type-post","status-publish","format-standard","hentry","category-pda"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":7,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":199,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions\/199"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}