{"id":97,"date":"2010-08-05T15:13:11","date_gmt":"2010-08-05T13:13:11","guid":{"rendered":"http:\/\/www.capri-soft.de\/blog\/?p=97"},"modified":"2010-08-05T15:15:40","modified_gmt":"2010-08-05T13:15:40","slug":"zugriff-von-vba-auf-microsoft-sql-server","status":"publish","type":"post","link":"https:\/\/www.capri-soft.de\/blog\/?p=97","title":{"rendered":"Zugriff von VBA auf Microsoft SQL Server"},"content":{"rendered":"<p>Zun\u00e4chst wird (z.B. in Excel) im VBA-Editor im Men\u00fc &#8222;Verweise&#8220; der Verweis &#8222;Microsoft ActiveX data Object&#8220; hinzugef\u00fcgt, damit man Zugriff auf die ADO-Klassen bekommt.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nPrivate Sub CommandButton1_Click()\r\n    Dim Cn As New ADODB.Connection\r\n    Dim Rs As New ADODB.Recordset\r\n    \r\n    Cn.Provider = &quot;SQLOLEDB.1&quot;\r\n    \r\n    Cn.ConnectionString = &quot;Password=daspasswort;&quot; &amp; _\r\n    &quot;Persist Security Info=True;&quot; &amp; _\r\n    &quot;User ID=deruser;&quot; &amp; _\r\n    &quot;Initial Catalog=datenbankname;&quot; &amp; _\r\n    &quot;Data Source=rechnername&quot;\r\n    \r\n    Cn.Open\r\n    \r\n    Rs.CursorType = adOpenKeyset\r\n    Rs.LockType = adLockPessimistic\r\n    Rs.Open &quot;SELECT TOP 10 * FROM globe2010juni_converted&quot;, Cn, adOpenStatic\r\n   \r\n    Do Until Rs.EOF\r\n      Debug.Print Rs.Fields(&quot;compcode&quot;).Value\r\n      Rs.MoveNext\r\n    Loop\r\n   \r\n    Cn.Close\r\nEnd Sub\r\n<\/pre>\n<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=https%3A%2F%2Fwww.capri-soft.de%2Fblog%2F%3Fp%3D97&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>Zun\u00e4chst wird (z.B. in Excel) im VBA-Editor im Men\u00fc &#8222;Verweise&#8220; der Verweis &#8222;Microsoft ActiveX data Object&#8220; hinzugef\u00fcgt, damit man Zugriff auf die ADO-Klassen bekommt. Private Sub CommandButton1_Click() Dim Cn As New ADODB.Connection Dim Rs As New ADODB.Recordset Cn.Provider = &quot;SQLOLEDB.1&quot; Cn.ConnectionString = &quot;Password=daspasswort;&quot; &amp; _ &quot;Persist Security Info=True;&quot; &amp; _ &quot;User ID=deruser;&quot; &amp; _ &quot;Initial &hellip; <a href=\"https:\/\/www.capri-soft.de\/blog\/?p=97\" class=\"more-link\"><span class=\"screen-reader-text\">Zugriff von VBA auf Microsoft SQL Server<\/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":[12],"tags":[],"class_list":["post-97","post","type-post","status-publish","format-standard","hentry","category-vba"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4yGeN-1z","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/97","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=97"}],"version-history":[{"count":6,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":102,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/97\/revisions\/102"}],"wp:attachment":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}