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 7938053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:41:51+00:00 2026-06-03T22:41:51+00:00

I need to know what is the common way to store a SQL server

  • 0

I need to know what is the common way to store a SQL server connection string for a WinForms application in VB.NET.

I have searched the net and I found answers to each of the following questions:

  • How do I read app.config values
  • How to do it in ASP.NET Reference: this SO question.
  • How do I store a connection string (unencrypted thus unsafe)

I would like a full answer on how to store a connection string in VB.NET in app.config (or settings.settings if it’s better) securely.

Is app.config the right place? Can I encrypt these values?

  • 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. Editorial Team
    Editorial Team
    2026-06-03T22:41:52+00:00Added an answer on June 3, 2026 at 10:41 pm

    Simply , the .net framework allows you to do that , see

    http://msdn.microsoft.com/en-us/library/89211k9b(v=vs.80).aspx

    Relevant information:

    This goes into the machine.config file:

    <configProtectedData defaultProvider="RsaProtectedConfigurationProvider">
      <providers>
        <add name="RsaProtectedConfigurationProvider" 
          type="System.Configuration.RsaProtectedConfigurationProvider, ... />
        <add name="DataProtectionConfigurationProvider" 
          type="System.Configuration.DpapiProtectedConfigurationProvider, ... />
      </providers>
    </configProtectedData>
    

    And this is the application code:

    Shared Sub ToggleConfigEncryption(ByVal exeConfigName As String)
        ' Takes the executable file name without the
        ' .config extension.
        Try
            ' Open the configuration file and retrieve 
            ' the connectionStrings section.
            Dim config As Configuration = ConfigurationManager. _
                OpenExeConfiguration(exeConfigName)
    
            Dim section As ConnectionStringsSection = DirectCast( _
                config.GetSection("connectionStrings"), _
                ConnectionStringsSection)
    
            If section.SectionInformation.IsProtected Then
                ' Remove encryption.
                section.SectionInformation.UnprotectSection()
            Else
                ' Encrypt the section.
                section.SectionInformation.ProtectSection( _
                  "DataProtectionConfigurationProvider") 'this is an entry in machine.config
            End If
    
            ' Save the current configuration.
            config.Save()
    
            Console.WriteLine("Protected={0}", _
            section.SectionInformation.IsProtected)
    
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
    End Sub
    

    UPDATE 1

    Thanks @wpcoder, for this link

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

Sidebar

Related Questions

I need to know where and how application settings (connections string) could be stored
I need to know size of objects in my python program. I have for
I have multiple projects that need to pass user login information to common-api project
Does anybody know of a (common case) faster-than-linear way to find the endpoints of
I have the authentication portion of an ASP.NET 3.5 web application complete. I would
I want to know better way to define name-spaces in my projects. We have
Imagine I have one common functionality: series and number (string and integer) of some
I have built a Silverlight\WCF\Sql application and as a part of the testing i
I have a situation where I need to store a general piece of data
I have an iOS application where I use coreData to store my documents. They

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.