Types.hpp error


I have no idea why cannot connect MongoDB Atals test mongocxx program via Visual Studio:

#include <cstdlib>
#include <iostream>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/uri.hpp>

using bsoncxx::builder::stream::close_document;
using bsoncxx::builder::stream::document;
using bsoncxx::builder::stream::finalize;
using bsoncxx::builder::stream::open_document;
mongocxx::instance instance{};// don't put inside main 

int main() {
	//mongocxx::instance inst;
	std::string name = "myname";
	std::string pw = "mypassword";
	mongocxx::client conn{ mongocxx::uri{ "mongodb+srv://"+name+pw+"@cluster0-xokay.mongodb.net/test?retryWrites=true&w=majority" } };
	auto coll = conn["spam"];
	auto res = coll["db"];
	bsoncxx::builder::stream::document document{};
	document << "Data" << "hello";

	return 0;

Environment :

Visual Studio 2015 Community
Boost 1.64
cmake 3.17.2
MongoDB C++ 11 Driver r3.5.0

Don’t you need a colon as separator between name and pw?

1 Like