Reputation: 465
I want to add an option to save data locally in my application using the mongo databse tools, I want to configure all the server information from within my application. I have 2 questions.
but on A computer that didn't configure the database setting, the code will not work. my code is :
public void createDB()
{
MongoClient client = new MongoClient();
var db = client.GetDatabase("TVDB");
var coll = db.GetCollection<Media>("Movies");
Media video = new Media("", "");
video.Name = "split";
coll.InsertOne(video);
}
this code works only after manual set the database like the picture above. without it I get in the last line A timeout exception. how can I configure it from my application to make it work (define Server) ?
Upvotes: 0
Views: 194
Reputation: 151594
By using that command you're not "configuring the database", you're running it.
If you don't want to manually run it, but want it to be always running, you should install it as a Windows Service as explained in How to run MongoDB as Windows service?.
You need to install and/or run a MongoDB server in order to use it. Using the API alone is not enough, it's not like SQLite.
Upvotes: 1