0

I'm trying to create a Database in MongoHQ from C# code. I read that by just calling

server.GetDatabase("DBName");

it creates the DB if it doesn't exist, nevertheless nothing is created.

Is it possible to do what I want to do? I have a free account =/

Thanks in advance

2 Answers2

0

You need to create a collection for the database to get created.

seand
  • 71
  • 2
  • 4
  • Thanks for the quick response. I'm creating the collection as well, but I'm not inserting everything, yet, so I'm going to try that real quick. – Jose Daniel Chacón Bogarín Jun 10 '14 at 05:34
  • I get an invalid credential error when I try to save the collection, but I don't get any errors when making the connection. Could it be because there is no users in the new DB? – Jose Daniel Chacón Bogarín Jun 10 '14 at 05:45
  • Your connectionstring should have your username/password. You could try the sample app found at http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-csharp-driver/#getting-started-with-csharp-driver and use your MonogHQ connectionstring. Or edit your orignial question and add your code. – seand Jun 10 '14 at 17:01
0

this is Jason from MongoHQ.

If you have a free account, you probably already have a database and would not have access to create new databases without either:

a) creating the new database through the MongoHQ web application.

b) using our MongoHQ API to automatically create new databases.

Also, since you don't have admin-level access on the free plans, you will need to specify the database you are accessing and you can then list the collections for that database.

Hope this helps!

Jason McCay
  • 3,295
  • 1
  • 13
  • 8