Jump to content
rayzan

ConnectionString - app.config

Recommended Posts

rayzan

Boa a Tarde a Todos,

Estou a desenvolver um projecto em Visual Basic 2010 com SqlServer 2008.

Utilizo a connectionstring da base de dados num ficheiro XML - app.config

Código do ficheiro XML

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  
  <configSections>
  </configSections>
  <connectionStrings>

    <add
      name="conecao" 
      connectionString="Data Source=RAYZAN-PC\SQLEXPRESS;Initial Catalog=bdgestpasse;Integrated Security=True"
      providerName="System.Data.SqlClient"
         
      />
  </connectionStrings>
  
</configuration>

Após muita pesquisa  :wallbash:  ainda não consegui o que pretendia, de uma forma automática alterar a connectionString do ficheiro app.config

Para chamar a connectionstring para efectuar as minhas instruções, utilizo este código

 

Dim conn As SqlConnection
   Dim app As String = ConfigurationManager.ConnectionStrings("conecao").ConnectionString()

   conn = New SqlConnection(app)
   conn.Open()

Alguém pode-me ajudar sff?

Obrigado a Todos

Share this post


Link to post
Share on other sites
rayzan

Rechousa

O que pretendo é aplication.config mas não web.config

Obrigado

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.