0

I am using C# official MongoDB nugget library.

I hosted the web service on Windows Azure, and the MongoDB database at Mongolab.

I connected to a server with the code below:

connection = mongodb://user:[email protected]:45077"
_server = MongoServer.Create(connection);

Previously it is working fine and it work fine at local testing server, but at my latest publish I get error below:

ExceptionMessage":"Invalid keyword 'data source'."," ....... at MongoDB.Driver.MongoConnectionStringBuilder.set_Item(String keyword, Object value)

Anyone know what is the problem?

1 Answer 1

1

The following works for me:

var client = new MongoClient("mongodb://user:[email protected]:45077");
var server = client.GetServer();
var database = server.GetDatabase("MyDataBaseName");

If your username or password contains special characters, you might want to encode them.

Please also note that your database username and password may well be different to your MongoLab login!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.