connection string for a vb.net application to be deployed in random system

后端 未结 1 998
栀梦
栀梦 2021-01-26 13:20

I am facing problem in using vb.net with sql server as DB.. Problem is of connection string i.e for \'n\' no. Of systems what shall be the connection string? App after geting de

相关标签:
1条回答
  • 2021-01-26 13:52

    Below is a VB.Net code snippet to retrieve a connection string from the app.config. The project will need a reference to System.Configuration in order to use the ConfigurationManager.

    Dim connectionString As String=System.Configuration.ConfigurationManager.ConnectionStrings("myDatabase").ConnectionString
    

    An example App.Config:

    <configuration>
        <connectionStrings>
            <add name="myDatabase" connectionString="Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=SSPI" />
        </connectionStrings>
    </configuration>
    
    0 讨论(0)
提交回复
热议问题