获取连接字符串数据源详细信息

时间:2017-09-27 06:33:45

标签: sql-server vb.net

我的设置表单,其中包含数据源详细信息:

test

我的用户设置是这样的

<userSettings>
    <rScale.My.MySettings>
        <setting name="WBServerIP" serializeAs="String">
            <value />
        </setting>
        <setting name="WBSrvUsr" serializeAs="String">
            <value />
        </setting>
        <setting name="WBSrvPwd" serializeAs="String">
            <value />
        </setting>
        <setting name="WBSrvDB" serializeAs="String">
            <value>WB</value>
        </setting>
        <setting name="DCSServerIP" serializeAs="String">
            <value />
        </setting>
        <setting name="DCSSrvUsr" serializeAs="String">
            <value />
        </setting>
        <setting name="DCSSrvPwd" serializeAs="String">
            <value />
        </setting>
        <setting name="DCSSrvDB" serializeAs="String">
            <value>DCS</value>
        </setting>
    </rScale.My.MySettings>
</userSettings>

所以从这个文本框中如何将细节存储到连接字符串

1 个答案:

答案 0 :(得分:0)

像这样:

Dim connectionString As String = String.Format("Server={0};Database={1};UID={2};Pwd={3}",
                                               My.Settings.WBServerIP,
                                               My.Settings.WBSrvDB,
                                               My.Settings.WBSrvUsr,
                                               My.Settings.WBSrvPwd)