Retrieval of data from database

Hi,

 I need to populate the grid with the data in the database. Since the grid is bound to a item source I am unable to perform a proper retrieval.

Following is the code that I Tried:

"mat.cs" is the file which is bound to the grid.

try





{




var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Test2.db");


using (var db = new SQLite.SQLiteConnection(dbpath))





{




foreach (ExpandoObject ep in (this.DataContext as mat).DynamicOrder)





{




//db = new SQLite.SQLiteConnection(dbpath);


dynamic epObj = ep;


var line = string.Empty;


if (!string.IsNullOrEmpty(epObj.Name))


line = epObj.Name;


Material conobj = new Material();


conobj.Name = epObj.Name;


conobj.Type = epObj.Type;


conobj.Quantity = epObj.Quantity;


List<Material> lstMats = db.Table<Material>().ToList();





}




db.Commit();


db.Dispose();


db.Close();


//var bline = new MessageDialog("Data Inserted");


//await bline.ShowAsync();





}


 


}





1 Reply

GV Ganesan V Syncfusion Team May 2, 2014 01:12 PM UTC

Hi Madhu,

Thank you for using Syncfusion Products.

We have created a sample to achieve your requirement to retrieve data from database and setting this data to the ItemSource of grid.

You can find the sample under the following location:

Please let us know if this solution helps you.

Thanks,

Ganesan V


Attachment: RetriveDataUsingSQLite_a5ecf4de.zip

Loader.
Up arrow icon