If name
is a string value that represents the name of the connection string:
var connectionString =
ConfigurationManager.ConnectionStrings[name].ConnectionString;
In your example you didn't provide a value for name
, so you'll have to do that before it'll work.