本文介绍了为程序设置sqlserver名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有组合框,其中显示服务器名称和sqlserver名称。例如:.\SQLExpress



sqlconnection是:

i have combobox where show server name and sqlserver name. for example : .\SQLExpress

sqlconnection is :

SqlConnection conn = new SqlConnection("Data Source='"+comboBox1.SelectedValue+"';AttachDbFilename=|DataDirectory|\\dbname.Mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");





现在comboBox1.SelectedValue不适用于程序。用户如何选择动态servername和sqlserver名称来连接数据库(sqlserver数据库)?

plz help。



now comboBox1.SelectedValue is not work for program . how user select dynamic servername and sqlserver name for connect to database (sqlserver database) ?
plz help .

推荐答案

SqlConnection conn = new SqlConnection("Data Source='"+comboBox1.Text+"';AttachDbFilename=|DataDirectory|\\dbname.Mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");



Hope这有帮助。


Hope this helps.


这篇关于为程序设置sqlserver名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 18:07