从SQL获取连接 [英] to get connection from sql

查看:60
本文介绍了从SQL获取连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在app.config文件中

In app.config flie

<add name="WindowsFormsApplication1.Properties.Settings.ConnString"
            connectionString="Data Source=KANDAMBY-5C2158;Initial Catalog=ITP;Integrated Security=True"
            providerName="System.Data.SqlClient" />



而不是特定的 source catalog ,当我们发布



instead specific source and catalog ,how can we make it for any data base in any machine when we published the software.

推荐答案

对于这种类型的需求,您需要制作一个实用程序,仅在应用程序安装后首次启动时才向用户询问机器名称和数据库名称一次.因此,您需要动态创建连接字符串并将其存储到app.config/web.config
For this type of requirement you need to make a utility that ask to user for Machine Name and Database name only once when application start first time after installation and accordingly user input you need to make connection string dynamically and store it to app.config/web.config


这篇关于从SQL获取连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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