Click here to Skip to main content
15,893,381 members
Articles / Programming Languages / Visual Basic

Securing ADO.NET Connection Strings

Rate me:
Please Sign up or sign in to vote.
2.67/5 (11 votes)
25 Aug 20063 min read 51.4K   1.1K   29  
Some possible ways to encrypt and store connection strings in an ADO.NET application.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.PropertyGrid = New System.Windows.Forms.PropertyGrid
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.rbConfig = New System.Windows.Forms.RadioButton
        Me.rbXML = New System.Windows.Forms.RadioButton
        Me.rbRegistry = New System.Windows.Forms.RadioButton
        Me.btnReset = New System.Windows.Forms.Button
        Me.btnDecrypt = New System.Windows.Forms.Button
        Me.btnEncrypt = New System.Windows.Forms.Button
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'PropertyGrid
        '
        Me.PropertyGrid.Location = New System.Drawing.Point(2, 3)
        Me.PropertyGrid.Name = "PropertyGrid"
        Me.PropertyGrid.Size = New System.Drawing.Size(218, 261)
        Me.PropertyGrid.TabIndex = 0
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.rbRegistry)
        Me.GroupBox1.Controls.Add(Me.rbXML)
        Me.GroupBox1.Controls.Add(Me.rbConfig)
        Me.GroupBox1.Location = New System.Drawing.Point(226, 12)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(196, 109)
        Me.GroupBox1.TabIndex = 1
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Store Connection String in:"
        '
        'rbConfig
        '
        Me.rbConfig.AutoSize = True
        Me.rbConfig.Checked = True
        Me.rbConfig.Location = New System.Drawing.Point(25, 19)
        Me.rbConfig.Name = "rbConfig"
        Me.rbConfig.Size = New System.Drawing.Size(106, 17)
        Me.rbConfig.TabIndex = 0
        Me.rbConfig.TabStop = True
        Me.rbConfig.Text = "Configoration File"
        Me.rbConfig.UseVisualStyleBackColor = True
        '
        'rbXML
        '
        Me.rbXML.AutoSize = True
        Me.rbXML.Location = New System.Drawing.Point(25, 51)
        Me.rbXML.Name = "rbXML"
        Me.rbXML.Size = New System.Drawing.Size(66, 17)
        Me.rbXML.TabIndex = 1
        Me.rbXML.Text = "XML File"
        Me.rbXML.UseVisualStyleBackColor = True
        '
        'rbRegistry
        '
        Me.rbRegistry.AutoSize = True
        Me.rbRegistry.Location = New System.Drawing.Point(25, 86)
        Me.rbRegistry.Name = "rbRegistry"
        Me.rbRegistry.Size = New System.Drawing.Size(63, 17)
        Me.rbRegistry.TabIndex = 2
        Me.rbRegistry.Text = "Registry"
        Me.rbRegistry.UseVisualStyleBackColor = True
        '
        'btnReset
        '
        Me.btnReset.Location = New System.Drawing.Point(263, 127)
        Me.btnReset.Name = "btnReset"
        Me.btnReset.Size = New System.Drawing.Size(116, 23)
        Me.btnReset.TabIndex = 5
        Me.btnReset.Text = "Reset PropertyGrid"
        Me.btnReset.UseVisualStyleBackColor = True
        '
        'btnDecrypt
        '
        Me.btnDecrypt.Location = New System.Drawing.Point(328, 233)
        Me.btnDecrypt.Name = "btnDecrypt"
        Me.btnDecrypt.Size = New System.Drawing.Size(96, 23)
        Me.btnDecrypt.TabIndex = 7
        Me.btnDecrypt.Text = "Decrypt-Retrieve"
        Me.btnDecrypt.UseVisualStyleBackColor = True
        '
        'btnEncrypt
        '
        Me.btnEncrypt.Location = New System.Drawing.Point(226, 233)
        Me.btnEncrypt.Name = "btnEncrypt"
        Me.btnEncrypt.Size = New System.Drawing.Size(96, 23)
        Me.btnEncrypt.TabIndex = 6
        Me.btnEncrypt.Text = "Encrypt-Store"
        Me.btnEncrypt.UseVisualStyleBackColor = True
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(429, 268)
        Me.Controls.Add(Me.btnDecrypt)
        Me.Controls.Add(Me.btnEncrypt)
        Me.Controls.Add(Me.btnReset)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.PropertyGrid)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form1"
        Me.Text = "Secure ADO.NET Connection String"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents PropertyGrid As System.Windows.Forms.PropertyGrid
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents rbRegistry As System.Windows.Forms.RadioButton
    Friend WithEvents rbXML As System.Windows.Forms.RadioButton
    Friend WithEvents rbConfig As System.Windows.Forms.RadioButton
    Friend WithEvents btnReset As System.Windows.Forms.Button
    Friend WithEvents btnDecrypt As System.Windows.Forms.Button
    Friend WithEvents btnEncrypt As System.Windows.Forms.Button

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Georgia Georgia
Lecturer in Gori University (Georgia)

Comments and Discussions