I am trying to implement programmatic access to a Table in the AF library.
I have a table called [User Settings] with columns called [User ID], [KVA Upper] and [KVA Lower]. User ID is a string that is supposed to be the ID of the connecting user and the other 2 are numeric fields.
I have been trying to update this using:
AFTable t = myDatabase.Tables[tableName]; t.Table.BeginLoadData(); t.Table.LoadDataRow(values, true); t.Table.EndLoadData(); t.ApplyChanges(); t.CheckIn();
The problem is that, because there are no key fields, if I try to change any of the numeric values, it creates a new row instead of updating the existing row. To use LoadDataRow, I think there are 2 options:
- I need the [User ID] field to be the primary key but I can't see anywhere in AF System Explorer to set that.
- Otherwise I will need to go through the table row by row to find the one with the matching User ID and then change that row but I can't see anything in the DataTable class to enable me to do that either!
I realise that dataTables are not OSI specific and I have been looking at http://msdn.microsoft.com/en-us/library/9186hy08 which is not helping! Can anyone give me some pointers?
Also, to get the current connection, I have been using
PISystem mySystem; ... mySystem = af[ServerName]; ... string username = mySystem.ConnectionInfo.AccountName
but AccountName is blank. How should I be getting the user credentials?