1、ini配置文件大致格式
[db1]server = 192.168.0.1
user = sa
passsword = 123
[db2]
server = 192.168.0.2
user = sa
passsword = 123
2、下拉菜单选项,比如是db1,db2
3、在下拉菜单的selectionchanged事件中,参考选中选项,读取ini参数,进行数据库连接即可,比如
string ls_sever,ls_user,ls_pwls_sever = ProfileString("PROFILE.INI", text, "server", "")
ls_user= ProfileString("PROFILE.INI", text, "user ", "")
ls_pw= ProfileString("PROFILE.INI", text, "passsword ", "")
//然后连接数据库即可
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)