Monthly Archives: November 2009

Working with Access dates

Following on from the previous post about updating records one data type that will be a little awkward to work with is dates. If you use a US locale or any other that uses a date format of Month/Day/Year you … Continue reading

Posted in Powershell | Leave a comment

Updating Access data

The last of of our data manipulation tasks is to update the data – we have already seen how to create, read and delete. 001002003004005006007008009010011012013 function Set-AccessData {[CmdletBinding(SupportsShouldProcess=$true)]param (    [string]$table,    [string]$filter,    [string]$value,    [System.Data.OleDb.OleDbConnection]$connection)    $sql = "UPDATE $table SET $value WHERE $filter"    $cmd = New-Object System.Data.OleDb.OleDbCommand($sql, $connection)        if ($psCmdlet.ShouldProcess("$($connection.DataSource)", "$sql")){$cmd.ExecuteNonQuery()}}   … Continue reading

Posted in Powershell | 7 Comments

Testing Connection to Access database

Many of the functions we have created so far have taken a connection to an Access database as a parameter.  At the time we pass in the connection we don’t actually know if the connection is open. Test-AccessConnection can be … Continue reading

Posted in Powershell | Leave a comment

Removing Access Records

So far we have seen how to add data to a table in an access database – now we want to delete some records.  This is an action that can cause problems especially if we get the wrong records – … Continue reading

Posted in Powershell | Leave a comment

Add Access Record Pt III – parameter sets

Last time we added the option of inputting the table and values to our function but we needed a way to discriminate between that and using a full SQL statement.  We can achieve this by dividing the parameters into parameter … Continue reading

Posted in Powershell | Leave a comment

Export Access data to csv file

We already have all the functionality we need to achieve this. Import-Module accessfunctions$db = Open-AccessDatabase -name test03.mdb -path c:testGet-AccessData -sql "select * from test1" -connection $db | Export-Csv -Path c:testtest1.csv –NoTypeInformation   Open the csv file in Excel and the … Continue reading

Posted in Powershell | Leave a comment

Comments Disabled

I found twenty comments this morning – all adverts for things I don’t want – plastered over recent posts.  I don’t want to spend my time cleaning off inappropriate material from my blog so I have suspended comments on posts … Continue reading

Posted in Rant | Leave a comment