Knight Data Access Layer
Update(String,Dictionary<String,Object>,Dictionary<String,Object>) Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > IDataHelper Interface > Update Method : Update(String,Dictionary<String,Object>,Dictionary<String,Object>) Method
The table to update
What to update
The primary key values
Update a record in the database by a composite primaryKey
Syntax
Overloads Function Update( _
   ByVal tableName As String, _
   ByVal parameters As Dictionary(Of String,Object), _
   ByVal compositeKeys As Dictionary(Of String,Object) _
) As Integer
Dim instance As IDataHelper
Dim tableName As String
Dim parameters As Dictionary(Of String,Object)
Dim compositeKeys As Dictionary(Of String,Object)
Dim value As Integer
 
value = instance.Update(tableName, parameters, compositeKeys)

Parameters

tableName
The table to update
parameters
What to update
compositeKeys
The primary key values

Return Value

Number of records updated
Example
//Get the current thread static safe instance of the helper
IDataHelper db = DataHelper.SessionFactory();
 
//Specify User Name and License Key from the receipt, leave blank for trial mode
//db.UserName = "John Smith 1234";
//db.LicenseKey = "asdfl219==";
 
//Open the database connection
db.OpenConnection();
 
//Create a new Person to save to the database
Person currentPerson = new Person();
currentPerson.FirstName = "John";
currentPerson.LastName = "Smith";
 
//Save it to the database 
db.Save(currentPerson);
 
//Creating parameters
Dictionary<string, object> parms = new Dictionary<string, object>();
parms.Add("FirstName", "John");
parms.Add("LastName", "Smith");
 
//Creating compositeKey
Dictionary<string, object> compositeKeys = new Dictionary<string, object>();
compositeKeys.Add("FirstName", "John");
compositeKeys.Add("LastName", "Smith");
 
//Update a record in the database by a composite key
int result = db.Update("Person", parms, compositeKeys);
 
//Close the database connection
db.CloseConnection();
'Get the current thread static safe instance of the helper
Dim db As IDataHelper = DataHelper.SessionFactory()
 
'Specify User Name and License Key from the receipt, leave blank for trial mode
'db.UserName = "John Smith 1234"
'db.LicenseKey = "asdfl219=="
 
'Open the database connection
db.OpenConnection()
 
'Create a new Person to save to the database
Dim currentPerson As New Person()
currentPerson.FirstName = "John"
currentPerson.LastName = "Smith"
 
'Save it to the database 
db.Save(currentPerson)
 
'Creating parameters
Dim parms As New Dictionary(Of String, Object)()
parms.Add("FirstName", "John")
parms.Add("LastName", "Smith")
 
'Creating compositeKey
Dim compositeKeys As New Dictionary(Of String, Object)()
compositeKeys.Add("FirstName", "John")
compositeKeys.Add("LastName", "Smith")
 
'Update a record in the database by a composite key
Dim result As Integer = db.Update("Person", parms, compositeKeys)
 
'Close the database connection
db.CloseConnection()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IDataHelper Interface
IDataHelper Members
Overload List