<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Changing MS Access database password from application' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Changing MS Access database password from application' posted on the 'Delphi and Kylix' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2009 Programmers Heaven</copyright>
    <pubDate>Fri, 20 Nov 2009 20:30:58 -0700</pubDate>
    <lastBuildDate>Fri, 20 Nov 2009 20:30:58 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Changing MS Access database password from application</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/259317/259317/changing-ms-access-database-password-from-application/</link>
      <description>Hi!&lt;br /&gt;
&lt;br /&gt;
I have a database created in MS Access. It is protected by a password. I also have an application working with that database. I would like to know whether and how it is possible to change this database password from the application (I'm using ADO to connect to it).&lt;br /&gt;
&lt;br /&gt;
Any help highly appreciated.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/259317/259317/changing-ms-access-database-password-from-application/</guid>
      <pubDate>Sun, 16 May 2004 23:01:05 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
    <item>
      <title>Re: Changing MS Access database password from application</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/259317/267026/re-changing-ms-access-database-password-from-application/#267026</link>
      <description>: Hi!&lt;br /&gt;
: &lt;br /&gt;
: I have a database created in MS Access. It is protected by a password. I also have an application working with that database. I would like to know whether and how it is possible to change this database password from the application (I'm using ADO to connect to it).&lt;br /&gt;
: &lt;br /&gt;
: Any help highly appreciated.&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
Ok, after a couple of months I was finally able to find the solution myself. So, if anyone is interested, here is how to make it. (I don't have Delphi available at hand, so I hope I remember it correctly) &lt;br /&gt;
&lt;br /&gt;
1. Use ADOConnection component from the ADO panel to connect to your Access database. When building a connection string, choose Microsoft Jet OLE DB 4.0 provider. Your connection string then should like something like&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=C:\Program files\TestBase.mdb;
Persist Security Info=False&lt;/pre&gt;&lt;br /&gt;
Note that in order to change password you should open database exclusively. To do that, in ADOConnection mode property choose ShareExclusive option.&lt;br /&gt;
&lt;br /&gt;
2. You will also need some component capable of dealing with SQL. I used ADOCommand. Put it to form and connect to ADOConnection you have created before.&lt;br /&gt;
&lt;br /&gt;
3. When you want to change database password, use your ADOCommand component. Try the following code:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt; 
 cs := 'ALTER DATABASE PASSWORD NewPassword OldPassword';
 ADOCommand1.CommandText := cs;
 ADOCommand1.Execute;&lt;/pre&gt;&lt;br /&gt;
Here cs is a string and instead NewPassword and OldPassword type in the corresponding values. If password is not set, type NULL in place of OldPassword.&lt;br /&gt;
&lt;br /&gt;
Can you believe it? As simple as that!&lt;br /&gt;
&lt;br /&gt;
P.S. you can even manage user-level security from Delphi. If interested, here is how to do it: &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acadvsql.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acadvsql.asp&lt;/a&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/259317/267026/re-changing-ms-access-database-password-from-application/#267026</guid>
      <pubDate>Sun, 18 Jul 2004 23:31:27 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
  </channel>
</rss>