I am having problems updating a document in MongoDB using VB.NET & the C# Driver.
I have code returning the document I wish to update but I'm not sure of the syntax to continue
Imports MongoDB.Bson
Imports MongoDB.Driver
Imports MongoDB.Driver.Builders
Dim mongo As MongoServer = MongoServer.Create()
mongo.Connect()
Dim db = mongo.GetDatabase("database")
Dim stock = db.GetCollection(Of BsonDocument)("stock")
Dim getDocument = New QueryDocument("productName", "test")
Use the coll.update method. e.g. to set the value of a field
More information on the methods can be found at http://api.mongodb.org/csharp/1.8.1/. Also I would recommend going through the tutorials at http://docs.mongodb.org/ecosystem/drivers/csharp/. The examples are in C# though
See this page on how to do the update:
http://docs.mongodb.org/manual/reference/method/db.collection.update/#update-parameter
My solution, you can use same this block code:
Connect to Mongodb:
Update:
Goodluck!