tuncalik
tuncalik

Reputation: 1144

How can I get the connection string for an SQL Express database listed in LINQPad?

Is there an easy way to get the connection string of a database listed in the connection window of LINQPad (other than using the object explorer of Visual Studio)?

Upvotes: 9

Views: 5533

Answers (4)

Blisco
Blisco

Reputation: 620

In LINQPad 8 you no longer have access to this.Database as suggested by other answers, but you can do simply:

this.Connection.ConnectionString

Alternatively and even more simply, you can use:

Util.CurrentCxString

This also works in a static context where this is unavailable.

Upvotes: 0

John S
John S

Reputation: 8351

In LinqPad7 you do:

this.Database.GetDbConnection().ConnectionString

This will show you the connection string.

Upvotes: 0

Mike Brady
Mike Brady

Reputation: 312

In LinqPad 5 if your Language dropdown is set to C# Program and you have a database selected in the Connection dropdown, then you can get your string using

string c = LINQPad.Util.CurrentDataContext.Connection.ConnectionString;

Upvotes: 4

Jay Walker
Jay Walker

Reputation: 4713

Making sgmoore's comment into an answer:

try this.Connection.ConnectionString.Dump();

Upvotes: 17

Related Questions