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

夙愿已清 提交于 2019-12-04 05:45:26

问题


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 deployed in other system creates connection path error. what shall be coded so that connection string is defined automatically .? please share any link or explanation for the same


回答1:


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>


来源:https://stackoverflow.com/questions/24345138/connection-string-for-a-vb-net-application-to-be-deployed-in-random-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!