简体   繁体   English

在随机系统中部署的vb.net应用程序的连接字符串

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

I am facing problem in using vb.net with sql server as DB.. Problem is of connection string ie for 'n' no. 我在将vb.net与sql server作为数据库一起使用时遇到问题。问题是连接字符串,即“ n”号。 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 请分享相同的任何链接或解释

Below is a VB.Net code snippet to retrieve a connection string from the app.config. 下面是一个VB.Net代码片段,用于从app.config中检索连接字符串。 The project will need a reference to System.Configuration in order to use the ConfigurationManager. 为了使用ConfigurationManager,该项目将需要对System.Configuration的引用。

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

An example App.Config: 一个示例App.Config:

<configuration>
    <connectionStrings>
        <add name="myDatabase" connectionString="Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=SSPI" />
    </connectionStrings>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM