Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 77961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:54:44+00:00 2026-05-10T20:54:44+00:00

I normally store all my configs in the registry. Even though I have started

  • 0

I normally store all my configs in the registry. Even though I have started using LINQ I would not like to have the DSN in the web.config, but rather let it stay in the registry and attach it (maybe in the Application Start Event) to the System Config.

How can this be done?

Thanx for any ideas!

edit: to make it clear: I do not want to write to the web.config file, I just want to keep the dsn (encrypted) anywhere else than the web.config, so I have the same web.config on all development stages (local, staginf, live, backup).

Christoph

Solution Code in VB.Net:

1) Add a new Class, with one method, which inherits from the original Datacontext:

Public Class MyDatabaseDataContext  Inherits DatabaseDataContext  Public Sub New()     MyBase.New(Settings.DSN) End Sub   End Class 

2) Use this Class in all Linq Datasources instead of the original Context.

 ContextTypeName='MyProject.MyDatabaseDataContext 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:54:45+00:00Added an answer on May 10, 2026 at 8:54 pm

    Here’s what I do. I have a a base class for my DataContext. It’s called DataContextBase and is generated by sqlmetal.exe. I have a derived class called DataContext which is what is used in my Linq calls. It looks like this:

    public class DataContext : DataContextBase {     public DataContext()         : base(ConnectionHolder.ConnectionString)     {     } } 

    I have a static class in my library called ConnectionHolder which stores the connection string:

    public static class ConnectionHolder {     static string _ConnectionString;      public static string ConnectionString     {         get { return _ConnectionString; }         set { _ConnectionString = value; }     } } 

    (note: this is separate from DataContext because there are places in my app outside of Linq that I use the connection string). At app startup I say ConnectionHolder.ConnectionString = (wherever you store the connection string).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Normally, I would store all application configuration data in the web/app.config and associated xml
Normally the XML files I have to parse are like this: <row id=1> <title>widget<title>
Possible Duplicate: Using ApplicationSettings to store Checked property for WinForms RadioButtons I have three
Normally we store a List in database by the hibernate mapping: <list name=userItems cascade=all
I am using eXist xml database now.Normally, I just store regular xml files in
Normally the code for using the dbContext from Entity Framework looks something like this:
Normally all the document related to an iOS application are stored in a document
Long introduction: Normally all data necessary for my web application are stored in session
I'm using SqlClient.SqlCommand object to run a few stored procs on my db. Normally
I'm working on a Rails app, where I'm using page caching to store static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.