I don't know if this is the right forum, but I am having trouble getting an Update to work on a SQLite database. I have 2 places in my script that updates the table, but only one of those ways works. I have looked at the SQL statement and they both look
the same.
Here is the part that works:
function Update-Record ($computerObj)
{
$sqlCmd = "UPDATE Refresh SET
Model = '$($computerObj.Model)', Autologon = '$($computerObj.Autologon)', BCA = '$($computerObj.BCA)', Description = '$($computerObj.Description)', OS = '$($computerObj.OS)', `
Site = '$($computerObj.Site)', Monitor1 = '$($computerObj.Monitor1)', Monitor2 = '$($computerObj.Monitor2)', Printers = '$($computerObj.Printers)', `
DHCPEnabled = '$($computerObj.DHCPEnabled)', IPAddress = '$($computerObj.IPAddress)', SCCMApps = '$($computerObj.SCCMApps)', ManualApps = '$($computerObj.ManualApps)', `
TopConsoleUser = '$($computerObj.TopConsoleUser)', TCU_FirstName = '$($computerObj.TCU_FirstName)', TCU_LastName = '$($computerObj.TCU_LastName)', `
MgrFirstName = '$($computerObj.MgrFirstName)', MgrLastName = '$($computerObj.MgrLastName)' WHERE ComputerName = '$($computerObj.ComputerName)'"
try
{
Invoke-SqliteQuery -datasource $datasource -Query $sqlCmd
}
catch
{
Write-Debug $_.Exception.Message
}
}
The above function works great - I can see the SQLite db file updating its timestamp. Here is the function that does NOT work:
function Update-Record ($computerObj)
{
$datasource = ".\Refresh.sqlite;Version=3"
$sqlcmd = "Update Refresh Set
RefreshDate = '$($computerObj.RefreshDate)', InstallTech = '$($computerObj.InstallTech)', Status = '$($computerObj.Status)' Where ComputerName = '$($computerObj.ComputerName)'"
try
{
Invoke-Sqlitequery -Datasource $datasource -Query $sqlcmd
}
catch
{
Write-Debug $_.Exception.Message
}
}
I verified that the data is in the object before it tries to update the table. I'm at a loss though. This is the last big hurdle I need to clear before I can have users test this. Any help would be greatly appreciated.
Brian