Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i am working a LocalDb Application in Xamarin Form.
My Requirement is to save Data Locally using SQLite DB.
i have created successfully Save interface and method. Data is coming from the xamarin forms successfully but only one data is storing in the class object that is

Interface
bool SaveNRCMaterialList(AddMaterialDataIntoLocalDb obj);

Method
public bool SaveNRCMaterialList(AddMaterialDataIntoLocalDb obj)
      {
          GetSqlConnection();
          bool res = false;
          try
          {

              con.Insert(obj);
              res = true;
          }
          catch (Exception ex)
          {
              res = false;
          }
          return res;
      }



Friends i just want to save list data inside the
con.Insert(obj);

can i have tried so many time please guid me how to insert here using list or how we can convert this into a list form

What I have tried:

if (btnsave.Text == "Save")
          {

              AddMaterialDataIntoLocalDb obj = new AddMaterialDataIntoLocalDb();


                  obj.NPD_OFF_S_NO = txtOffSerialNumber.Text;
                  obj.NPD_ALTERNATE_PART_NO = txtNPD_ALTERNATE_PART_NO.Text;


              //obj.NPD_ON_S_NO = txtOffSerialNumber.Text;
              //obj.NPD_ALTERNATE_PART_NO = txtNPD_ALTERNATE_PART_NO.Text;
              //obj.NPD_REQ_ON_PART_NO = txtOnPArtNumbers.Text;
              //obj.NPD_Part_Type = txtPartType.Text;

              //obj.NPD_DESC = txtdesc.Text;
              //obj.NPD_IPC_REF = txtNPD_IPC_REFERENCE.Text;
              //obj.NPD_POS = txtEnterPOS.Text;
              //obj.NPD_REQ_QTY =txtNPD_REQ_QTY.Text;
              //obj.NPD_NEED_DATE = DateTime.Now;
              //obj.NPD_BATCH_REL_NOTE = txtNPD_BATCH_REL_NOTE.Text;
              //obj.NPD_USED_QTY = txtNPD_USED_QTY.Text;
              //obj.NPD_UOM = txtNPD_UOM.Text;
              //obj.NDP_Updated_By = txtNDP_Updated_By.Text;
              //obj.NPD_Inward = txtNPD_Inward.Text;
              //btnsave.Text = "Update";



            bool res=  DependencyService.Get<ISQLiteNRC>().SaveNRCMaterialList(obj);

              try
              {
                  Navigation.PushAsync(new NRCMeterialList());
              }
              catch(Exception ex)
              {

                  DisplayAlert("message", "Save failed", "Ok");
              }
          }
Posted
Updated 7-Feb-23 1:01am

1 solution

According to the code you have posted, obj is not a list but a simple object. If you mean that you want to save each member of the object into a separate field of the database, then you need to redesign your table to accomodate all the different items.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900