We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Saving data to database

Hi,

     I have created a datagrid in which I can add new rows and edit them. However I am not getting any useful link regarding saving the data to a SQLite database. Kindly help


5 Replies

JG Jai Ganesh S Syncfusion Team March 7, 2014 12:47 PM UTC

Hi Madhu,

 

Thank you for using Syncfusion products.

 

We have analyzed your query. You can save the datas in SfDataGrid to the database by using SfDataGrid’s “RowValidated event”.

 

Please let us know if you need further assistance.

 

Thank you,

Jai Ganesh S



RE red November 12, 2018 05:41 PM UTC

Can you give us an example  by using "RowValidated event " with sqlserver database and uwp app  please


DY Deivaselvan Y Syncfusion Team November 13, 2018 08:40 AM UTC

Hi Red,

Thank you for contacting Syncfusion support.

We have prepared sample using SQLite DB. We have maintained the database locally to save the insert, update and retrieve the data from the database. For inserting new record by handling RowValidating event and also updating edited data by handling RowValidated event as like below code snippet 
 
// for inserting new record in SQLite DB  
this.datagrid.RowValidating += Datagrid_RowValidating;  
  
private void Datagrid_RowValidating(object sender, Syncfusion.UI.Xaml.Grid.RowValidatingEventArgs e)  
{      
    try  
    {  
        if (database.conn == null 
            return 
        var data = (e.RowData as OrderItem);  
        var id = data.ID;  
        var name = data.Name;  
        var query = "INSERT INTO OrderItem (ID,Name) VALUES ('" + data.ID + "','" + data.Name + "')" 
        database.conn.Query<OrderItem>(query);  
  
    }  
    catch { }  
 
  
//for updating edited record in SQLite DB  
this.datagrid.RowValidated += Datagrid_RowValidated;  
  
private void Datagrid_RowValidated(object sender, Syncfusion.UI.Xaml.Grid.RowValidatedEventArgs e)  
{      
    try  
    {  
        if (database.conn == null 
            return 
        var data = (e.RowData as OrderItem);  
  
        var query1 = "UPDATE OrderItem SET Name='" + data.Name + "' WHERE ID='" + data.ID + "'" 
        database.conn.Query<OrderItem>(query1);  
    }  
    catch { }  
 
 
 
Sample Link :  
 
Please let us know if you need any further assistance. 
 
Regards,
Deivaselvan
 



RE red November 14, 2018 07:48 AM UTC

Thank you very much for your help ,you give me an example with Sqllite that's fine too .
In general , I appreciate your quick response.
This is my first time using your product , You are doing excellent job .

Thanks Deivaselvan Y
  


DY Deivaselvan Y Syncfusion Team November 16, 2018 04:08 AM UTC

Hi Red,

Thanks for your feedback. We are happy to assist you as always. Please let us know if you required any further assistance.

Regards,
Deivaselvan

Loader.
Live Chat Icon For mobile
Up arrow icon