troubleshooting Question

Securing connection strings and Encrypting

Avatar of bduhaish
bduhaishFlag for Saudi Arabia asked on
7 Comments1 Solution444 ViewsLast Modified:
hi experts,

i was searching for a way to Encrypting the Connection String in the web.config file using .net  and i found this article at
i did every thing was written  but i get this error saying
----  Format of the initialization string does not conform to specification starting at index 0 ------

here are the steps i did:

1- i got the encrypted connection string
2- i paste it in the web.config file ----      
     <add key="ConnectionString"
3- also i was able to decrypt the connection string again
4- in the page load for example that i want to display
i did the flowing steps:
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
            Dim ConStr As SqlConnection
            ConStr = DoCon()
            'Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
            Dim MySQL As String = "Select Top 10 au_id, au_fname + ' ' + au_lname " & _
             "as FullName from Authors"
            Dim ds As DataSet = New DataSet
            Dim Cmd As New SqlDataAdapter(MySQL, ConStr)
            Cmd.Fill(ds, "PBAuthors")
            dgPublishers.DataSource = ds.Tables("PBAuthors").DefaultView
        End If
End Sub

Function DoCon() As SqlConnection
        Dim ConnectionStr As New SqlConnection(ConfigurationSettings.AppSettings().Item("ConnectionString"))
        Return (ConnectionStr)
End Function

That's all, any suggestion please.........

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros