Connection strings

196 views
Skip to first unread message

Seth Edwards

unread,
Apr 6, 2010, 4:30:26 PM4/6/10
to mongodb...@googlegroups.com
Does anyone have an example of what a more complex connection string will look like?

Sam Corder

unread,
Apr 6, 2010, 4:48:23 PM4/6/10
to mongodb...@googlegroups.com
The easiest way to generate one would be to instantiate the MongoConnectionStringBuilder, set your properties on that and save off the ToString() value from that object.

var mcsb = new MongoConnectionStringBuilder(){
    MaximumPoolSize = 100,
    MinimumPoolSize = 10}
mcsb.AddServer("localhost"); //default port
mcsb.AddServer("someotherhost", 27107); //specify port

Console.WriteLine(mcsb.ToString());

Also have a look at the tests.  Here is a long one in there.
"Username=testusername;Password=testpassword;Server=testserver1:555,testserver2;MaximumPoolSize=101;MinimumPoolSize=202;ConnectionTimeout=60;ConnectionLifetime=50", 

Seth Edwards

unread,
Apr 6, 2010, 6:13:37 PM4/6/10
to mongodb...@googlegroups.com
Cool that's what I needed.

Steve Wagner

unread,
Apr 7, 2010, 5:51:08 AM4/7/10
to mongodb...@googlegroups.com
The driver and MongoConnectionStringBuilder are also can parse the
mongodb:// url based connection strings.

Lee

unread,
Apr 11, 2010, 12:18:46 PM4/11/10
to mongodb-csharp
Sorry I'm missing this, but how do you change the connection string to
point to an IP address? I'm looking at the config file, but I also
see "localhost" all over the driver. Can someone shed light where I
change this?

TIA

Lee

On Apr 7, 4:51 am, Steve Wagner <li...@lanwin.de> wrote:
> The driver and MongoConnectionStringBuilder are also can parse the
> mongodb:// url based connection strings.
>
> On 07.04.2010 00:13, Seth Edwards wrote:
>
>
>
> > Cool that's what I needed.
>
> > On Tue, Apr 6, 2010 at 4:48 PM, Sam Corder <sa...@codeargyle.com> wrote:
>
> >> The easiest way to generate one would be to instantiate the
> >> MongoConnectionStringBuilder, set your properties on that and save off the
> >> ToString() value from that object.
>
> >> var mcsb = new MongoConnectionStringBuilder(){
> >>     MaximumPoolSize = 100,
> >>     MinimumPoolSize = 10}
> >> mcsb.AddServer("localhost"); //default port
> >> mcsb.AddServer("someotherhost", 27107); //specify port
>
> >> Console.WriteLine(mcsb.ToString());
>
> >> Also have a look at the tests.  Here is a long one in there.
>

> >> "Username=testusername;Password=testpassword;Server=testserver1:555,testser­ver2;MaximumPoolSize=101;MinimumPoolSize=202;ConnectionTimeout=60;Connectio­nLifetime=50",


>
> >> On Tue, Apr 6, 2010 at 4:30 PM, Seth Edwards <sethaedwa...@gmail.com>wrote:
>
> >>> Does anyone have an example of what a more complex connection string will

> >>> look like?- Hide quoted text -
>
> - Show quoted text -

Steve Wagner

unread,
Apr 11, 2010, 12:33:52 PM4/11/10
to mongodb...@googlegroups.com
Simply use "Server=192.168.1.1" as connection string.

-Steve

Sam Corder

unread,
Apr 11, 2010, 1:44:27 PM4/11/10
to mongodb...@googlegroups.com

We use names because it is a better habit to be in. There isn't a technical reason that you can't use an ip except that later if you need to move or replace your server a name will make life easier.

On Apr 11, 2010 12:34 PM, "Steve Wagner" <li...@lanwin.de> wrote:

Simply use "Server=192.168.1.1" as connection string.

-Steve

On 11.04.2010 18:18, Lee wrote: > all over the driver. Can someone shed light where I > change th...

-- To unsubscribe, reply using "remove me" as the subject.

Lee

unread,
Apr 11, 2010, 2:09:44 PM4/11/10
to mongodb-csharp
Ok thanks. I was thinking along the lines of changing the config,
such as in the simple example to:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="simple" value="Server=192.168.1.15"/>
</appSettings>
</configuration>


I looked in the Project>>Properties>>Settings but did not see an entry
there.

Thanks again
Lee

Lee Everest
www.texastoo.com
http://www.texastoo.com/post/2010/04/04/MongoDB-vs-SQL-Server-INSERT-comparison.aspx

Stuart Johnson

unread,
Apr 19, 2010, 6:42:54 AM4/19/10
to mongodb...@googlegroups.com
How do you create an index using the c# driver?


--
Subscription settings: http://groups.google.com/group/mongodb-csharp/subscribe?hl=en

craiggwilson

unread,
Apr 19, 2010, 7:40:26 AM4/19/10
to mongodb-csharp
var collection = DB.GetCollection("somename");

var meta = collection.MetaData;

meta.CreateIndex(new Document("fieldName", 1), false);

Stuart Johnson

unread,
Apr 19, 2010, 7:45:28 AM4/19/10
to mongodb...@googlegroups.com
Thanks
Reply all
Reply to author
Forward
0 new messages