Knight Data Access Layer
Load DataTable
Basic Tasks C# > Loading Data > Load DataTable

Use SQL to load data into a data table.

 

//Get the current instance of the helper

IDataHelper db = DataHelper.SessionFactory();

 

//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);

 

string sql = "select * from Person";

DataTable dt = db.GetDataTable(sql);