Ejemplo n.º 1
0
        /// <summary>
        /// Adds the data to the table
        /// </summary>
        private void addData()
        {
            //Declarations
            User objData = new User { FirstName = txtFirstName.Text, LastName = txtLastName.Text };

            if (!_objDBUtility.addData(txtDBName.Text, txtTable.Text, objData))
                MessageBox.Show("Unable to add!", frmMongoDBDemo.ActiveForm.Text);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the Data base
        /// </summary>
        /// <param name="strDBName"></param>
        /// <returns></returns>
        public Boolean addData(String strDBName, String strTableName, User objData)
        {
            //Declarations
            Boolean blnFlag = false;
            MongoDatabase objDB = getServer().GetDatabase(strDBName);

            try
            {
                //Get the table
                MongoCollection objTable = objDB.GetCollection(strTableName);

                //Insert the data
                objTable.Insert(objData);
                objTable.Save(objData);
                blnFlag = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return blnFlag;
        }