Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: .NET
Expertise: Beginner
Jun 10, 2008



Application Security Testing: An Integral Part of DevOps

Using Data Wizards in .NET 2.0

When you use the data wizards in .NET 2.0, the connection string property is read only. However, the following code shows you how to change the connection string:

        'set a reference to system.configuration
        'set the following imports stratement above your class 
        'Imports System.Configuration

        ' Get the application configuration file.
        Dim config _
        As System.Configuration.Configuration = _
        ConfigurationManager.OpenExeConfiguration( _

        'the full connection string name.   normally designer generated is assemblyname 
        'below is a sample how i used it with my test app 
        Dim csName As String = "TestRptWO.My.MySettings.DbCon"

        ' Create a connection string element 
        '(use the connection string of your choice; I tested it with SQL Server, 
        but it should work for any provider )
        Dim csSettings _
        As New ConnectionStringSettings( _
        csName, _
        "LocalSqlServer: data source=;Integrated Security=SSPI;" + _
        "Initial Catalog=aspnetdb", "System.Data.SqlClient")

        ' Get the connection strings section.
        Dim csSection _
        As ConnectionStringsSection = _

        'first remove the old section from the collection  
        ' Add the new element.

        ' Save the configuration file.
Michel Posseth
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date