Advertisement

08.07.2008 at 07:01AM PDT, ID: 23629302
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.7

Encrypt ConnectionString in ASP.NET / VB 2005/2008 2.0  web.config

Asked by megnin in Microsoft Visual Basic.Net, Programming for ASP.NET

Tags: , ,

I'm trying to encrypt the connection string in my web.config using code and instructions from O'Reilly Windows Dev Center: http://www.ondotnet.com/pub/a/dotnet/2005/02/15/encryptingconnstring.html

In the Page_Load I get, "Name 'Encrypt' is not declared"

and in both the EncryptConnStr() and DecryptConnStr() I get, "'OpenWebConfiguration' is not a member of 'System.Configuration.ConfigurationManager'"

I'm having such a hard time learning VB.NET because it seems like every example I try to follow does not work.  
Thank you for any help with this.
-DavidStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Imports System.Configuration
Imports System.Web.Security
 
Partial Public Class Login
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Encrypt("DataProtectionConfigurationProvider")
    End Sub
    Public Sub EncryptConnStr(ByVal protectionProvider As String)
        '---open the web.config file
        Dim config As Configuration = _
           ConfigurationManager.OpenWebConfiguration( _
           Request.ApplicationPath)
        '---indicate the section to protect
        Dim section As ConfigurationSection = _
           config.Sections("connectionStrings")
        '---specify the protection provider
        section.SectionInformation.ProtectSection(protectionProvider)
        '---Apple the protection and update
        config.Save()
    End Sub
    Public Sub DecryptConnStr()
        Dim config As Configuration = _
           ConfigurationManager.OpenWebConfiguration( _
           Request.ApplicationPath)
        Dim section As ConfigurationSection = _
           config.Sections("connectionStrings")
        section.SectionInformation.UnProtectSection()
        config.Save()
    End Sub
 
 
   Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        'Add Job Titles Data to Database
        Dim DBConn As New SqlConnection("UID=MyUserID;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Kiosks;Data Source=DATABASE;Packet Size=4096;")
        'Dim DBConn As New SqlConnection("Data Source=DATABASE;Initial Catalog=Kiosks;")
        Dim DBCmd As New SqlCommand
        Dim DBAdap As New SqlDataAdapter
        DBConn.Open()
 
        Dim strClientIP As String = ""
        strClientIP = HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") 'Request.ServerVariables("REMOTE_ADDR")
        'strClientIP = Request.UserHostAddress()
        Response.Write(strClientIP)
 
        Try
            'Add Insert Statement 
            DBCmd = New SqlCommand("INSERT INTO Users (FName,LName,PIN,KioskIP,uDate) VALUES (@FName,@LName,@PIN,@KioskIP,getdate())", DBConn)
            'Add Database Parameters
            DBCmd.Parameters.Add("@FName", SqlDbType.VarChar).Value = txtFName.Text
            DBCmd.Parameters.Add("@LName", SqlDbType.VarChar).Value = txtLName.Text
            DBCmd.Parameters.Add("@PIN", SqlDbType.Int).Value = intPIN.Text
            DBCmd.Parameters.Add("@KioskIP", SqlDbType.VarChar).Value = strClientIP   'How to determine the IP?
            'DBCmd.Parameters.Add("@cbSundays", SqlDbType.VarChar).Value = cbSundays.Checked  'Just an example of a checkbox
            'DBCmd.Parameters.Add("@WorkersComp", SqlDbType.VarChar).Value = ddlJobDescriptionPrim.SelectedValue     ' Example of DropDownList
 
            DBCmd.ExecuteNonQuery()
 
        Catch exp As Exception
            Response.Write(exp)
        End Try
 
        'Close Database connection 
        'and Dispose Database objects 
        DBCmd.Dispose()
        DBAdap.Dispose()
        DBConn.Close()
        DBConn = Nothing
 
    End Sub
End Class
[+][-]08.07.2008 at 07:10AM PDT, ID: 22181086

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 07:30AM PDT, ID: 22181302

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 07:31AM PDT, ID: 22181312

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 07:39AM PDT, ID: 22181387

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 07:41AM PDT, ID: 22181415

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 07:42AM PDT, ID: 22181419

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 07:44AM PDT, ID: 22181433

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 08:02AM PDT, ID: 22181619

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 10:02AM PDT, ID: 22182938

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, Programming for ASP.NET
Tags: VB 2008, 'OpenWebConfiguration' is not a member of 'System.Configuration.ConfigurationManager'. \\betaserve\e$\Inetpub\WF1 Intranet Site\Login.aspx.vb,16,12,\\betaserve\e$\Inetpub\WF1 Intranet Site\, Error 2 Name 'Encrypt' is not declared. \\betaserve\e$\Inetpub\WF1 Intranet Site\Login.aspx.vb 11 9 \\betaserve\e$\Inetpub\WF1 Intranet Site\
Sign Up Now!
Solution Provided By: imateyelectronics
Participating Experts: 1
Solution Grade: B
 
 
[+][-]08.07.2008 at 10:08AM PDT, ID: 22183012

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628