Kamis, 23 Desember 2010

SQL object mapper - insert record to table

How to insert a record into Person table

This sample codes will show how easy using SQL objects.

string connectionString = "...";

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

// set all data properties to insert
person.PersonId.Value = 10;
person.FirstName.Value = "Michael Johnson";
person.Status.Value = true;


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

// select all columns to insert
insert.Columns.Add(person.PersonId);
insert.Columns.Add(person.FirstName);
insert.Columns.Add(person.Status);


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


For more information click here.

Tidak ada komentar:

Posting Komentar