{"id":534,"date":"2011-12-01T13:04:51","date_gmt":"2011-12-01T12:04:51","guid":{"rendered":"http:\/\/www.capri-soft.de\/blog\/?p=534"},"modified":"2011-12-01T13:06:47","modified_gmt":"2011-12-01T12:06:47","slug":"c-net-access-auf-mdb-datei-zugreifen","status":"publish","type":"post","link":"https:\/\/www.capri-soft.de\/blog\/?p=534","title":{"rendered":"C# .NET + Access : Auf .mdb-Datei zugreifen"},"content":{"rendered":"<h1>Aufgabenstellung<\/h1>\n<p>Von C# soll auf eine Access-Datenbank zugegrieffen werden. <\/p>\n<h1>L\u00f6sung<\/h1>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">public static string getCustomerCPD(string customerno)\r\n{\r\n   string cpd = &quot;Customer using getCustomerCPD not found&quot;;\r\n   OleDbConnection conn = new OleDbConnection(\r\n   &quot;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;&quot;+\r\n    &quot;Jet OLEDB:Database Locking Mode=1; &quot;+\r\n    &quot;Data Source=\\&quot;&quot; + AppDomain.CurrentDomain.BaseDirectory +\r\n     &quot;\\\\OCT.mdb\\&quot;;Jet OLEDB:Engine Type=5;&quot;+\r\n    &quot;Provider=\\&quot;Microsoft.Jet.OLEDB.4.0\\&quot;;Jet OLEDB:System database=;&quot;+\r\n    &quot;Jet OLEDB:SFP=False;&quot;+\r\n    &quot;persist security info=False;Extended Properties=;&quot;+\r\n    &quot;Jet OLEDB:Encrypt Database=False;&quot;+\r\n    &quot;Jet OLEDB:Create System Database=False;&quot;+\r\n     &quot;Jet OLEDB:Don&#039;t Copy Locale on Compact=False;&quot;+\r\n    &quot;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;&quot;+\r\n     &quot;Jet OLEDB:Global Bulk Transactions=1&quot;;);\r\n\r\n     try\r\n     {\r\n       conn.Open();\r\n       OleDbCommand comm = new OleDbCommand();\r\n       comm.Connection = conn;\r\n\r\n        comm.CommandText = &quot;SELECT cpdnumber FROM &#x5B;tbl_Customer] &quot;+\r\n                                           &quot;WHERE debitor=@customerno&quot;;\r\n        comm.Parameters.AddWithValue(&quot;customerno&quot;, customerno);\r\n\r\n        OleDbDataReader reader = comm.ExecuteReader();\r\n\r\n        while (reader.Read())\r\n        {\r\n            cpd = reader.GetValue(0).ToString();\r\n        }\r\n  }\r\n  catch (Exception e)\r\n  {\r\n     return e.Message;\r\n  }\r\n  finally\r\n  {\r\n      conn.Close();\r\n  }\r\n  return cpd;\r\n}<\/pre>\n<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=https%3A%2F%2Fwww.capri-soft.de%2Fblog%2F%3Fp%3D534&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:450px;margin-top:5px;\"><\/iframe>","protected":false},"excerpt":{"rendered":"<p>Aufgabenstellung Von C# soll auf eine Access-Datenbank zugegrieffen werden. L\u00f6sung public static string getCustomerCPD(string customerno) { string cpd = &quot;Customer using getCustomerCPD not found&quot;; OleDbConnection conn = new OleDbConnection( &quot;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;&quot;+ &quot;Jet OLEDB:Database Locking Mode=1; &quot;+ &quot;Data Source=\\&quot;&quot; + AppDomain.CurrentDomain.BaseDirectory + &quot;\\\\OCT.mdb\\&quot;;Jet OLEDB:Engine Type=5;&quot;+ &quot;Provider=\\&quot;Microsoft.Jet.OLEDB.4.0\\&quot;;Jet OLEDB:System database=;&quot;+ &quot;Jet OLEDB:SFP=False;&quot;+ &quot;persist &hellip; <a href=\"https:\/\/www.capri-soft.de\/blog\/?p=534\" class=\"more-link\"><span class=\"screen-reader-text\">C# .NET + Access : Auf .mdb-Datei zugreifen<\/span> weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,16,10],"tags":[],"class_list":["post-534","post","type-post","status-publish","format-standard","hentry","category-net","category-access","category-datenbanken"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4yGeN-8C","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=534"}],"version-history":[{"count":3,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/534\/revisions"}],"predecessor-version":[{"id":536,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/534\/revisions\/536"}],"wp:attachment":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}