<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=40999&amp;view=findpost&amp;p=266006</guid>
        <pubDate>Thu, 18 Dec 2003 14:54:53 +0000</pubDate>
        <title>Создание файла БД Access?</title>
        <link>https://forum.sources.ru/index.php?showtopic=40999&amp;view=findpost&amp;p=266006</link>
        <description><![CDATA[Vit:  через DAO можно примерно так:<br><br><!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b></b> </td></tr><tr><td id='CODE'><!--ec1-->procedure CreateMSAccessDatabase&#40;filename&#58; string&#41;; <br>var DAO&#58; Variant; <br>&nbsp; i&#58; integer; <br>const Engines&#58; array&#91;0..2&#93; of string = &#40;&#39;DAO.DBEngine.36&#39;, &#39;DAO.DBEngine.35&#39;, &#39;DAO.DBEngine&#39;&#41;; <br><br>&nbsp; function CheckClass&#40;OLEClassName&#58; string&#41;&#58; boolean; <br>&nbsp; var Res&#58; HResult; <br>&nbsp; begin <br>&nbsp; &nbsp; Result &#58;= CoCreateInstance&#40;ProgIDToClassID&#40;OLEClassName&#41;, nil, CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER, IDispatch, Res&#41; = S_OK; <br>&nbsp; end; <br>begin <br>&nbsp; for i &#58;= 0 to 2 do <br>&nbsp; &nbsp; if CheckClass&#40;Engines&#91;i&#93;&#41; then <br>&nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; DAO &#58;= CreateOleObject&#40;Engines&#91;i&#93;&#41;; <br>&nbsp; &nbsp; &nbsp; &nbsp; DAO.Workspaces&#91;0&#93;.CreateDatabase&#40;filename, &#39;;LANGID=0x0409;CP=1252;COUNTRY=0&#39;, 32&#41;; <br>&nbsp; &nbsp; &nbsp; &nbsp; exit; <br>&nbsp; &nbsp; &nbsp; end; <br>&nbsp; raise Exception.Create&#40;&#39;DAO engine could not be initialized&#39;&#41;; <br>end; <!--c2--></td></tr></table><div class='postcolor'><!--ec2--><br><br>Однако гораздо проще подшить пустую базу данных в ресурсы и дело с концом...<br><br>Автор: Vit <br><br><br><!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b></b> </td></tr><tr><td id='CODE'><!--ec1-->const<br>&nbsp; CLASS_DBEngine&#58; TGUID = &#39;{00000100-0000-0010-8000-00AA006D2EA4}&#39;;<br>&nbsp; dbLangCyrillic = &#39;;LANGID=0x0409;CP=1252;COUNTRY=0&#39;;<br>&nbsp; dbOption &nbsp; &nbsp; &nbsp; = &nbsp; &nbsp; 0<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;or &#036;20 // ? похоже создание в формате Access 97<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#59;<br><br>procedure CreateMSAccessDatabase&#40;FileName &#58;String&#41;;<br>begin<br>&nbsp; Variant&#40;CreateOleObject&#40;ClassIDToProgID&#40;CLASS_DBEngine&#41;&#41;&#41;<br>&nbsp; &nbsp; .Workspaces&#91;0&#93;<br>&nbsp; &nbsp; &nbsp; .CreateDatabase &#40;FileName, dbLangCyrillic, dbOption&#41;;<br>end;<!--c2--></td></tr></table><div class='postcolor'><!--ec2--><br><br>Автор: Петрович <br><br> ]]></description>
        <author>Vit</author>
        <category>Базы данных, репортинг, печать</category>
      </item>
	
      </channel>
      </rss>
	