By default, it seems like my web application is using LocalSqlServer
as the connection string to use for any application services such as Membership/Roles/Authentication/etc.
Is there any way I can change what the default connection string should be? It seems so arbitrary that the default is "LocalSqlServer" and the only way I was able to find this was by googling for this for about two hours.
I don't want to be forced to have to name my server connection "LocalSqlServer" and I have no idea if this is a preexisting item that I might be overwriting.
Select the TableAdapter or query that has the connection you want to edit. In the Properties window, expand the Connection node. To quickly modify the connection string, edit the ConnectionString property, or click the down arrow on the Connection property and choose New Connection.
If you save your connection string in the udl file, the user can change the connection via an interface by simply double clicking that file. You can set your connection string in the app to point to the udl file. You can also launch the udl interface programmatically if you want.
Applications use connection strings to identify the server instance and database to connect to and to determine what driver, login, etc. to use to connect to the SQL Server instance. Typically, the connection string will be stored in a configuration file somewhere within the application or web server.
Yes, these connection strings can be set in web.config:
Membership
<membership defaultProvider="SqlMembershipProvider">
<providers>
<add
name="SqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="MyMembershipConnectionString"
/>
</providers>
</membership>
Roles
<roleManager defaultProvider ="SqlRoleProvider" >
<providers>
<add
name="SqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="MyRolesConnectionString"
/>
</providers>
</roleManager>
See here for more info: How to: Use the ASP.NET Membership Provider
2 things. Look for, or add a "connectionStringName" property in your membership config.
Here is an example that uses it
<system.web>
...
<membership defaultProvider="MembershipADProvider">
<providers>
<add
name="MembershipADProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="YOUR CONN STRING"
connectionUsername="<domainName>\administrator"
connectionPassword="password"/>
</providers>
</membership>
...
</system.web>
And you need to setup the conn sting of course
<connectionStrings>
<add name="YOUR CONN STRING"
connectionString=
"[ANY ConnectionSTRIN]" />
</connectionStrings>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With