在随机系统中部署的vb.net应用程序的连接字符串 [英] connection string for a vb.net application to be deployed in random system

查看:75
本文介绍了在随机系统中部署的vb.net应用程序的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将vb.net与sql server作为数据库一起使用时遇到问题。
问题是连接字符串,即
表示 n不。系统的连接字符串是什么?在其他系统中部署后,
应用程序会创建连接路径错误。
应该编码什么,以便自动定义连接字符串。
请分享相同的任何链接或说明

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

推荐答案

下面是一个VB.Net代码片段,用于检索连接来自app.config的字符串。该项目将需要引用System.Configuration才能使用ConfigurationManager。

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

App.Config示例:

An example App.Config:

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

这篇关于在随机系统中部署的vb.net应用程序的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆