﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Accessing MS Access files in Powershell</title><link>http://www.visualbasicscript.com/</link><description /><copyright>(c) VBScript Forum</copyright><ttl>30</ttl><item><title> RE: Accessing MS Access files in Powershell (sanket.shetye)</title><description>  Hey that works great! thanks mate &lt;img src="http://www.visualbasicscript.com/upfiles/smiley/s13.gif" alt="" /&gt; &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=43320</link><pubDate>Sun, 18 Feb 2007 22:31:19 GMT</pubDate></item><item><title> RE: Accessing MS Access files in Powershell (SAPIENScripter)</title><description>  Try this: &lt;br&gt;  &amp;nbsp; &lt;br&gt;  &lt;font color="#0066cc"&gt;$objConnection.Connectionstring = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = $pwd\status.mdb" &lt;/font&gt; &lt;br&gt;   &lt;br&gt;  I think you have to specify the path.&amp;nbsp; Using $pwd at least doesn't force you to hard code a path. &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=43164</link><pubDate>Wed, 14 Feb 2007 07:34:48 GMT</pubDate></item><item><title> RE: Accessing MS Access files in Powershell (SAPIENScripter)</title><description>  The more I play with this, the more I think the path issue is related to the COM object OLE DB provider. COM objects under PowerShell are not 100% foolproof and completely compatible. It may be that under PowerShell the provider is defaulting to a certain directory for the database unless you specify a complete path. </description><link>http://www.visualbasicscript.com/fb.ashx?m=43163</link><pubDate>Wed, 14 Feb 2007 07:26:53 GMT</pubDate></item><item><title> RE: Accessing MS Access files in Powershell (SAPIENScripter)</title><description>  I always specify the full path, even in VBScript. And while a vbscript version of your script doesn't require the path, obviously PowerShell is different.&amp;nbsp; Remember, it is not a scripting engine like VBScript.&amp;nbsp; It is an interactive shell with batch-file like capabilities. By that I mean you can put your commands in a ps1 file and execute them much the same way you build a batch file (conceptually) in CMD.exe. &lt;br&gt;  &amp;nbsp; &lt;br&gt;  Powershell is more secure by design. For example, you have to explicity state the path of the script your want to run.&amp;nbsp; I expect path access to the database file is the same way. I'm not saying it makes things easier for you, just that I suspect there's a security reason behind it. &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=43162</link><pubDate>Wed, 14 Feb 2007 07:19:24 GMT</pubDate></item><item><title> Accessing MS Access files in Powershell (sanket.shetye)</title><description>  Guys, I need help in accessing MS Access database files in Powershell, I am using the following code (Taken from scriptcenter and modified a bit) &lt;br&gt;  ------------------------- &lt;br&gt;  &lt;font color="#0066cc"&gt;$adOpenStatic = 3 &lt;br&gt;  $adLockOptimistic = 3&lt;/font&gt; &lt;br&gt;  &lt;font color="#0066cc"&gt;$objConnection = New-Object -comobject ADODB.Connection &lt;br&gt;  $objRecordset = New-Object -comobject ADODB.Recordset&lt;/font&gt; &lt;br&gt;  &lt;font color="#0066cc"&gt;$objConnection.Connectionstring = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = status.mdb" &lt;br&gt;  $objConnection.Open() &lt;br&gt;  $objRecordset.Open("Select * from app1", $objConnection,$adOpenStatic,$adLockOptimistic)&lt;/font&gt; &lt;br&gt;  &lt;font color="#0066cc"&gt;$objRecordset.MoveFirst()&lt;/font&gt; &lt;br&gt;  &lt;font color="#0066cc"&gt;do {$objRecordset.Fields.Item("counter").Value; $objRecordset.MoveNext()} until  &lt;br&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp; ($objRecordset.EOF -eq $True)&lt;/font&gt; &lt;br&gt;  &lt;font color="#0066cc"&gt;$objRecordset.Close() &lt;br&gt;  $objConnection.Close()&lt;/font&gt; &lt;br&gt;  --------------------------- &lt;br&gt;  The error I am getting is as follows- &lt;br&gt;  &lt;font color="#ff0000"&gt;Exception calling "Open" with "0" argument(s): "Could not find file 'C:\Documents and Settings\ssanket\status.mdb &lt;br&gt;  '." &lt;br&gt;  &lt;/font&gt;&lt;font color="#000000"&gt;---------------------------&lt;/font&gt; &lt;br&gt;  The location of the script is 'c:\scripts', my problem is when I give full path to the mdb file it works fine, but I dont want to do that, the script should accept only the filename, the script file and database file both are in the same folder. The script should ideally look into the same folder first for the database file in absense of a fully defined path, but that is not happening here, can someone tell me what I am doing wrong? &lt;br&gt;  Thanks a bunch! &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=43134</link><pubDate>Tue, 13 Feb 2007 09:40:12 GMT</pubDate></item></channel></rss>
