The following is the procedure for doing CRUD operations in MongoDB.
Step 1
Create a folder such as D:\data\db.
Step 2
Download MongoDB binaries from: http://www.mongodb.org/downloads and unzip it to the “D” drive.
Step 3
Double-click on “mongod” inside “.\mongodb-win32-i386-2.6.4\bin”. That will open a new window. Keep this window opened. This will open a port Mongo with a port (in my case it is 27017).
Open http://localhost:27017/.
Step 4
Create a Window application with Visual Studio.
Step 5
Install the official MongoDB C# driver. Run “PM> Install-Package mongocsharpdriver” in the Package Manager Console .
Step 6
To create a database and record:
- MongoServer mongo = MongoServer.Create();
- mongo.Connect();
- var db = mongo.GetDatabase("Organization");
- using (mongo.RequestStart(db))
- {
- var collection = db.GetCollection<BsonDocument>("Employees");
- BsonDocument Employee = new BsonDocument()
- .Add("_id", System.Guid.NewGuid().ToString())
- .Add("Name", txtName.Text)
- .Add("Eamil", txtEmail.Text)
- .Add("Phone", txtPhone.Text);
- collection.Insert(Employee);
- textBox1.Text = textBox1.Text + System.Environment.NewLine + "Inserted....";
- mongo.Disconnect();
- ReadAll();
- }


vimal mPosted Jun 6, 2018, 1:11 AM
How do i read mongodb datas in charts some one pls tell me
Pankaj Kumar ChoudharyPosted Aug 3, 2015, 11:13 AM
Nice Explain Sir....
Gowtham RajamanickamPosted Apr 25, 2015, 6:23 AM
good
Jerthen FranchisePosted Apr 17, 2015, 4:17 AM
Error 'Create' does not exist in the type 'MongoDB.Driver.MongoServer'
NitinPosted Mar 10, 2015, 3:13 AM
great article to get it started over with...
Vithal WadjePosted Nov 3, 2014, 2:18 PM
good one
Dinesh BeniwalPosted Oct 4, 2014, 10:14 AM
Good work Ratnesh, Welcome back.
Saineshwar BageriPosted Oct 4, 2014, 6:13 AM
what is MongoDB and how it is useful