private void InsertComponentindb() { try { string connectionstring = string.Format("mongodb://*****:*****@ds053479.mlab.com:53479/dftcalculatordb/?retryWrites=false"); string databaseName = string.Format("dftcalculatordb"); MongoCRUD database = new MongoCRUD(connectionstring, databaseName); string dbcollection = string.Format("componentscollection"); var component = new Component { ComponentName = txtBoxComponentName.Text.ToString(), Model = txtBoxModel.Text.ToString(), Specifications = txtBoxSpecifications.Text.ToString(), Weight = int.Parse(txtBoxWeight.Text) }; MongoCRUD.InsertDocument(dbcollection, component); MessageBox.Show("Details Entered Successfully"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }