problem with mongoDB
I'm new in MongoDB and I've tried to do a simple code to see if its works or not :
MongoServer server = MongoServer.Create();
MongoDatabase test = server.GetDatabase("test");
MongoCollection<BsonDocument> books =
test.GetCollection<BsonDocument>("books");
BsonDocument book = new BsonDocument {
{ "author", "Ernest Hemingway" },
开发者_运维问答 { "title", "For Whom the Bell Tolls" }
};
books.Insert(book);
but when I run this example it gives me an error :
No connection could be made because the target machine actively refused it 127.0.0.1:27017
I'm using VS2008 .
how to fix this ?! Thank uSorry if I'm stating the obvious but do you have mongodb running, either as a Windows Service or by running mongod
in command line? If it's not running, then you get this error.
Update: I'm new to mongodb too, so I kept (basic) notes and turned it into a "Getting started with MongoDB and .NET" blog post last week. Check through that as that includes all the steps to get up and running with mongodb. Specifically, you need to make sure you started up mongodb.
精彩评论