Kamis, 23 Desember 2010

SQL object mapper - update a record in table

How to update records in Person table

This sample codes will show how easy using SQL objects.

string connectionString = "...";

// define Person object.
Person person = new Person();

// set data to be updated - Firstname = "New Name"
person.FirstName.Value = "New Name"

// using SQL-object to update Person table
SqlUpdate update = new SqlUpdate(person);
// set connection string
update.ConnectionString = connectionString;

// select FirstName column to update
update.Columns.Add(person.FirstName);

// set Where conditional to update a record with personid = 2
update.Where.Compare(person.PersonId, CompareOperator.Equal, 2);

// execute select Person table
int r = update.Execute();


For more information click here.

Tidak ada komentar:

Posting Komentar