Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 10th, 2014, 08:53 AM
Registered User
Join Date: Jan 2014
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Define LocalSqlServer dynamically at run time


As it's the first time I ask a question here I hope I'm doing it at the right place...

Here is my question : is there a way to define the LocalSqlServer string dynamically at run time?
I'm using .net 3.5, VS2008, c# and VB and it's for web projects.

Why do I want to do this?
Because I want the LocalSqlServer connection string data (host, login, password) to be centralised and not hard code on the web.config.

Ex: these data will be stored in the server system variables, managed by the IT, the websites will have to load and get these data to create the connectring at startup, there are many websites most of them will be using the same DB for LocalSqlServer.

Has I'm using the membership tables I must specify the LocalSqlServer string.

I hope my question and what I'm trying to do is enought clear... I'm yet far from being fluent in english !


Old January 10th, 2014, 04:06 PM
Friend of Wrox
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts

So you want your users to type in the connection string in when they log in?
Old January 10th, 2014, 05:27 PM
Registered User
Join Date: Jan 2014
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts


No, just to be able to define the connection string for LocalSqlServer at the start of my application.
In this way I can create the connection based on aliases and server variables.
no real server name/ip, userid or password will be used in the code (I use SQL Users for connection)

But with some luck I found, a couple of hours ago, was I looking for!

In the web.config I specify custom Providers for the functionalities (Membership, Roles, WebParts, ...) I use that are using LocalSqlServer connection by default, instead I make then point to a Dummy SQL Connection string and I make my custom Provider be based on a SQL provider class (SqlMembershipProvider, SqlRoleProvider, ...) that is defined in my project.
On these SQL Provider classes I override the Initialize method allowing me to bypass the Dummy connection string and create the connection string as I want based on whatever variables I need.

So for me the topic could be claused!

Any way thanks for your help.
Best Regards


Last edited by hdossantos; January 10th, 2014 at 05:29 PM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing LocalSqlServer with Providers sleepyone BOOK: Beginning ASP.NET 4 : in C# and VB 8 June 13th, 2011 08:26 AM
How do you add content to a tab control dynamically in wcf -- at run time? Bill_Thompson C# 2005 0 June 29th, 2010 10:43 PM
Modifying LocalSqlServer at runtime TwoTrees ASP.NET 3.5 Professionals 7 July 29th, 2008 12:12 PM
Design-Time or Run-Time now ? ALGNET .NET Framework 2.0 1 July 31st, 2006 04:43 AM
Run time Help Dazzer96 Access VBA 2 May 3rd, 2006 07:03 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.